babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239
  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. private _tempMatrix;
  7513. protected _isWorldMatrixFrozen: boolean;
  7514. /** @hidden */
  7515. _indexInSceneTransformNodesArray: number;
  7516. /**
  7517. * An event triggered after the world matrix is updated
  7518. */
  7519. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7520. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7521. /**
  7522. * Gets a string identifying the name of the class
  7523. * @returns "TransformNode" string
  7524. */
  7525. getClassName(): string;
  7526. /**
  7527. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7528. */
  7529. position: Vector3;
  7530. /**
  7531. * 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)).
  7532. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7533. */
  7534. rotation: Vector3;
  7535. /**
  7536. * 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)).
  7537. */
  7538. scaling: Vector3;
  7539. /**
  7540. * 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).
  7541. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7542. */
  7543. rotationQuaternion: Nullable<Quaternion>;
  7544. /**
  7545. * The forward direction of that transform in world space.
  7546. */
  7547. readonly forward: Vector3;
  7548. /**
  7549. * The up direction of that transform in world space.
  7550. */
  7551. readonly up: Vector3;
  7552. /**
  7553. * The right direction of that transform in world space.
  7554. */
  7555. readonly right: Vector3;
  7556. /**
  7557. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7558. * @param matrix the matrix to copy the pose from
  7559. * @returns this TransformNode.
  7560. */
  7561. updatePoseMatrix(matrix: Matrix): TransformNode;
  7562. /**
  7563. * Returns the mesh Pose matrix.
  7564. * @returns the pose matrix
  7565. */
  7566. getPoseMatrix(): Matrix;
  7567. /** @hidden */
  7568. _isSynchronized(): boolean;
  7569. /** @hidden */
  7570. _initCache(): void;
  7571. /**
  7572. * Flag the transform node as dirty (Forcing it to update everything)
  7573. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7574. * @returns this transform node
  7575. */
  7576. markAsDirty(property: string): TransformNode;
  7577. /**
  7578. * Returns the current mesh absolute position.
  7579. * Returns a Vector3.
  7580. */
  7581. readonly absolutePosition: Vector3;
  7582. /**
  7583. * Sets a new matrix to apply before all other transformation
  7584. * @param matrix defines the transform matrix
  7585. * @returns the current TransformNode
  7586. */
  7587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7588. /**
  7589. * Sets a new pivot matrix to the current node
  7590. * @param matrix defines the new pivot matrix to use
  7591. * @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
  7592. * @returns the current TransformNode
  7593. */
  7594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7595. /**
  7596. * Returns the mesh pivot matrix.
  7597. * Default : Identity.
  7598. * @returns the matrix
  7599. */
  7600. getPivotMatrix(): Matrix;
  7601. /**
  7602. * Prevents the World matrix to be computed any longer.
  7603. * @returns the TransformNode.
  7604. */
  7605. freezeWorldMatrix(): TransformNode;
  7606. /**
  7607. * Allows back the World matrix computation.
  7608. * @returns the TransformNode.
  7609. */
  7610. unfreezeWorldMatrix(): this;
  7611. /**
  7612. * True if the World matrix has been frozen.
  7613. */
  7614. readonly isWorldMatrixFrozen: boolean;
  7615. /**
  7616. * Retuns the mesh absolute position in the World.
  7617. * @returns a Vector3.
  7618. */
  7619. getAbsolutePosition(): Vector3;
  7620. /**
  7621. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7622. * @param absolutePosition the absolute position to set
  7623. * @returns the TransformNode.
  7624. */
  7625. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7626. /**
  7627. * Sets the mesh position in its local space.
  7628. * @param vector3 the position to set in localspace
  7629. * @returns the TransformNode.
  7630. */
  7631. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7632. /**
  7633. * Returns the mesh position in the local space from the current World matrix values.
  7634. * @returns a new Vector3.
  7635. */
  7636. getPositionExpressedInLocalSpace(): Vector3;
  7637. /**
  7638. * Translates the mesh along the passed Vector3 in its local space.
  7639. * @param vector3 the distance to translate in localspace
  7640. * @returns the TransformNode.
  7641. */
  7642. locallyTranslate(vector3: Vector3): TransformNode;
  7643. private static _lookAtVectorCache;
  7644. /**
  7645. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7646. * @param targetPoint the position (must be in same space as current mesh) to look at
  7647. * @param yawCor optional yaw (y-axis) correction in radians
  7648. * @param pitchCor optional pitch (x-axis) correction in radians
  7649. * @param rollCor optional roll (z-axis) correction in radians
  7650. * @param space the choosen space of the target
  7651. * @returns the TransformNode.
  7652. */
  7653. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7654. /**
  7655. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7656. * This Vector3 is expressed in the World space.
  7657. * @param localAxis axis to rotate
  7658. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7659. */
  7660. getDirection(localAxis: Vector3): Vector3;
  7661. /**
  7662. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7663. * localAxis is expressed in the mesh local space.
  7664. * result is computed in the Wordl space from the mesh World matrix.
  7665. * @param localAxis axis to rotate
  7666. * @param result the resulting transformnode
  7667. * @returns this TransformNode.
  7668. */
  7669. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7670. /**
  7671. * Sets this transform node rotation to the given local axis.
  7672. * @param localAxis the axis in local space
  7673. * @param yawCor optional yaw (y-axis) correction in radians
  7674. * @param pitchCor optional pitch (x-axis) correction in radians
  7675. * @param rollCor optional roll (z-axis) correction in radians
  7676. * @returns this TransformNode
  7677. */
  7678. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7679. /**
  7680. * Sets a new pivot point to the current node
  7681. * @param point defines the new pivot point to use
  7682. * @param space defines if the point is in world or local space (local by default)
  7683. * @returns the current TransformNode
  7684. */
  7685. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7686. /**
  7687. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7688. * @returns the pivot point
  7689. */
  7690. getPivotPoint(): Vector3;
  7691. /**
  7692. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7693. * @param result the vector3 to store the result
  7694. * @returns this TransformNode.
  7695. */
  7696. getPivotPointToRef(result: Vector3): TransformNode;
  7697. /**
  7698. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7700. */
  7701. getAbsolutePivotPoint(): Vector3;
  7702. /**
  7703. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7704. * @param result vector3 to store the result
  7705. * @returns this TransformNode.
  7706. */
  7707. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7708. /**
  7709. * Defines the passed node as the parent of the current node.
  7710. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7711. * @param node the node ot set as the parent
  7712. * @returns this TransformNode.
  7713. */
  7714. setParent(node: Nullable<Node>): TransformNode;
  7715. private _nonUniformScaling;
  7716. /**
  7717. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7718. */
  7719. readonly nonUniformScaling: boolean;
  7720. /** @hidden */
  7721. _updateNonUniformScalingState(value: boolean): boolean;
  7722. /**
  7723. * Attach the current TransformNode to another TransformNode associated with a bone
  7724. * @param bone Bone affecting the TransformNode
  7725. * @param affectedTransformNode TransformNode associated with the bone
  7726. * @returns this object
  7727. */
  7728. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7729. /**
  7730. * Detach the transform node if its associated with a bone
  7731. * @returns this object
  7732. */
  7733. detachFromBone(): TransformNode;
  7734. private static _rotationAxisCache;
  7735. /**
  7736. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7737. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7738. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7739. * The passed axis is also normalized.
  7740. * @param axis the axis to rotate around
  7741. * @param amount the amount to rotate in radians
  7742. * @param space Space to rotate in (Default: local)
  7743. * @returns the TransformNode.
  7744. */
  7745. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7746. /**
  7747. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7748. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7749. * The passed axis is also normalized. .
  7750. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7751. * @param point the point to rotate around
  7752. * @param axis the axis to rotate around
  7753. * @param amount the amount to rotate in radians
  7754. * @returns the TransformNode
  7755. */
  7756. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7757. /**
  7758. * Translates the mesh along the axis vector for the passed distance in the given space.
  7759. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7760. * @param axis the axis to translate in
  7761. * @param distance the distance to translate
  7762. * @param space Space to rotate in (Default: local)
  7763. * @returns the TransformNode.
  7764. */
  7765. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7766. /**
  7767. * Adds a rotation step to the mesh current rotation.
  7768. * x, y, z are Euler angles expressed in radians.
  7769. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7770. * This means this rotation is made in the mesh local space only.
  7771. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7772. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7773. * ```javascript
  7774. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7775. * ```
  7776. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7777. * 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.
  7778. * @param x Rotation to add
  7779. * @param y Rotation to add
  7780. * @param z Rotation to add
  7781. * @returns the TransformNode.
  7782. */
  7783. addRotation(x: number, y: number, z: number): TransformNode;
  7784. /**
  7785. * Computes the world matrix of the node
  7786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7787. * @returns the world matrix
  7788. */
  7789. computeWorldMatrix(force?: boolean): Matrix;
  7790. protected _afterComputeWorldMatrix(): void;
  7791. /**
  7792. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7793. * @param func callback function to add
  7794. *
  7795. * @returns the TransformNode.
  7796. */
  7797. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7798. /**
  7799. * Removes a registered callback function.
  7800. * @param func callback function to remove
  7801. * @returns the TransformNode.
  7802. */
  7803. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7804. /**
  7805. * Gets the position of the current mesh in camera space
  7806. * @param camera defines the camera to use
  7807. * @returns a position
  7808. */
  7809. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7810. /**
  7811. * Returns the distance from the mesh to the active camera
  7812. * @param camera defines the camera to use
  7813. * @returns the distance
  7814. */
  7815. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7816. /**
  7817. * Clone the current transform node
  7818. * @param name Name of the new clone
  7819. * @param newParent New parent for the clone
  7820. * @param doNotCloneChildren Do not clone children hierarchy
  7821. * @returns the new transform node
  7822. */
  7823. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7824. /**
  7825. * Serializes the objects information.
  7826. * @param currentSerializationObject defines the object to serialize in
  7827. * @returns the serialized object
  7828. */
  7829. serialize(currentSerializationObject?: any): any;
  7830. /**
  7831. * Returns a new TransformNode object parsed from the source provided.
  7832. * @param parsedTransformNode is the source.
  7833. * @param scene the scne the object belongs to
  7834. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7835. * @returns a new TransformNode object parsed from the source provided.
  7836. */
  7837. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7838. /**
  7839. * Get all child-transformNodes of this node
  7840. * @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
  7841. * @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
  7842. * @returns an array of TransformNode
  7843. */
  7844. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7845. /**
  7846. * Releases resources associated with this transform node.
  7847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7849. */
  7850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7851. }
  7852. }
  7853. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7854. /**
  7855. * Class used to override all child animations of a given target
  7856. */
  7857. export class AnimationPropertiesOverride {
  7858. /**
  7859. * Gets or sets a value indicating if animation blending must be used
  7860. */
  7861. enableBlending: boolean;
  7862. /**
  7863. * Gets or sets the blending speed to use when enableBlending is true
  7864. */
  7865. blendingSpeed: number;
  7866. /**
  7867. * Gets or sets the default loop mode to use
  7868. */
  7869. loopMode: number;
  7870. }
  7871. }
  7872. declare module "babylonjs/Bones/bone" {
  7873. import { Skeleton } from "babylonjs/Bones/skeleton";
  7874. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7875. import { Nullable } from "babylonjs/types";
  7876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7878. import { Node } from "babylonjs/node";
  7879. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7880. /**
  7881. * Class used to store bone information
  7882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7883. */
  7884. export class Bone extends Node {
  7885. /**
  7886. * defines the bone name
  7887. */
  7888. name: string;
  7889. private static _tmpVecs;
  7890. private static _tmpQuat;
  7891. private static _tmpMats;
  7892. /**
  7893. * Gets the list of child bones
  7894. */
  7895. children: Bone[];
  7896. /** Gets the animations associated with this bone */
  7897. animations: import("babylonjs/Animations/animation").Animation[];
  7898. /**
  7899. * Gets or sets bone length
  7900. */
  7901. length: number;
  7902. /**
  7903. * @hidden Internal only
  7904. * Set this value to map this bone to a different index in the transform matrices
  7905. * Set this value to -1 to exclude the bone from the transform matrices
  7906. */
  7907. _index: Nullable<number>;
  7908. private _skeleton;
  7909. private _localMatrix;
  7910. private _restPose;
  7911. private _baseMatrix;
  7912. private _absoluteTransform;
  7913. private _invertedAbsoluteTransform;
  7914. private _parent;
  7915. private _scalingDeterminant;
  7916. private _worldTransform;
  7917. private _localScaling;
  7918. private _localRotation;
  7919. private _localPosition;
  7920. private _needToDecompose;
  7921. private _needToCompose;
  7922. /** @hidden */
  7923. _linkedTransformNode: Nullable<TransformNode>;
  7924. /** @hidden */
  7925. /** @hidden */
  7926. _matrix: Matrix;
  7927. /**
  7928. * Create a new bone
  7929. * @param name defines the bone name
  7930. * @param skeleton defines the parent skeleton
  7931. * @param parentBone defines the parent (can be null if the bone is the root)
  7932. * @param localMatrix defines the local matrix
  7933. * @param restPose defines the rest pose matrix
  7934. * @param baseMatrix defines the base matrix
  7935. * @param index defines index of the bone in the hiearchy
  7936. */
  7937. constructor(
  7938. /**
  7939. * defines the bone name
  7940. */
  7941. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7942. /**
  7943. * Gets the current object class name.
  7944. * @return the class name
  7945. */
  7946. getClassName(): string;
  7947. /**
  7948. * Gets the parent skeleton
  7949. * @returns a skeleton
  7950. */
  7951. getSkeleton(): Skeleton;
  7952. /**
  7953. * Gets parent bone
  7954. * @returns a bone or null if the bone is the root of the bone hierarchy
  7955. */
  7956. getParent(): Nullable<Bone>;
  7957. /**
  7958. * Returns an array containing the root bones
  7959. * @returns an array containing the root bones
  7960. */
  7961. getChildren(): Array<Bone>;
  7962. /**
  7963. * Sets the parent bone
  7964. * @param parent defines the parent (can be null if the bone is the root)
  7965. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7966. */
  7967. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7968. /**
  7969. * Gets the local matrix
  7970. * @returns a matrix
  7971. */
  7972. getLocalMatrix(): Matrix;
  7973. /**
  7974. * Gets the base matrix (initial matrix which remains unchanged)
  7975. * @returns a matrix
  7976. */
  7977. getBaseMatrix(): Matrix;
  7978. /**
  7979. * Gets the rest pose matrix
  7980. * @returns a matrix
  7981. */
  7982. getRestPose(): Matrix;
  7983. /**
  7984. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7985. */
  7986. getWorldMatrix(): Matrix;
  7987. /**
  7988. * Sets the local matrix to rest pose matrix
  7989. */
  7990. returnToRest(): void;
  7991. /**
  7992. * Gets the inverse of the absolute transform matrix.
  7993. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7994. * @returns a matrix
  7995. */
  7996. getInvertedAbsoluteTransform(): Matrix;
  7997. /**
  7998. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7999. * @returns a matrix
  8000. */
  8001. getAbsoluteTransform(): Matrix;
  8002. /**
  8003. * Links with the given transform node.
  8004. * The local matrix of this bone is copied from the transform node every frame.
  8005. * @param transformNode defines the transform node to link to
  8006. */
  8007. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8008. /** Gets or sets current position (in local space) */
  8009. position: Vector3;
  8010. /** Gets or sets current rotation (in local space) */
  8011. rotation: Vector3;
  8012. /** Gets or sets current rotation quaternion (in local space) */
  8013. rotationQuaternion: Quaternion;
  8014. /** Gets or sets current scaling (in local space) */
  8015. scaling: Vector3;
  8016. /**
  8017. * Gets the animation properties override
  8018. */
  8019. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8020. private _decompose;
  8021. private _compose;
  8022. /**
  8023. * Update the base and local matrices
  8024. * @param matrix defines the new base or local matrix
  8025. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8026. * @param updateLocalMatrix defines if the local matrix should be updated
  8027. */
  8028. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8029. /** @hidden */
  8030. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8031. /**
  8032. * Flag the bone as dirty (Forcing it to update everything)
  8033. */
  8034. markAsDirty(): void;
  8035. private _markAsDirtyAndCompose;
  8036. private _markAsDirtyAndDecompose;
  8037. /**
  8038. * Translate the bone in local or world space
  8039. * @param vec The amount to translate the bone
  8040. * @param space The space that the translation is in
  8041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8042. */
  8043. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8044. /**
  8045. * Set the postion of the bone in local or world space
  8046. * @param position The position to set the bone
  8047. * @param space The space that the position is in
  8048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8049. */
  8050. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8051. /**
  8052. * Set the absolute position of the bone (world space)
  8053. * @param position The position to set the bone
  8054. * @param mesh The mesh that this bone is attached to
  8055. */
  8056. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8057. /**
  8058. * Scale the bone on the x, y and z axes (in local space)
  8059. * @param x The amount to scale the bone on the x axis
  8060. * @param y The amount to scale the bone on the y axis
  8061. * @param z The amount to scale the bone on the z axis
  8062. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8063. */
  8064. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8065. /**
  8066. * Set the bone scaling in local space
  8067. * @param scale defines the scaling vector
  8068. */
  8069. setScale(scale: Vector3): void;
  8070. /**
  8071. * Gets the current scaling in local space
  8072. * @returns the current scaling vector
  8073. */
  8074. getScale(): Vector3;
  8075. /**
  8076. * Gets the current scaling in local space and stores it in a target vector
  8077. * @param result defines the target vector
  8078. */
  8079. getScaleToRef(result: Vector3): void;
  8080. /**
  8081. * Set the yaw, pitch, and roll of the bone in local or world space
  8082. * @param yaw The rotation of the bone on the y axis
  8083. * @param pitch The rotation of the bone on the x axis
  8084. * @param roll The rotation of the bone on the z axis
  8085. * @param space The space that the axes of rotation are in
  8086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8087. */
  8088. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8089. /**
  8090. * Add a rotation to the bone on an axis in local or world space
  8091. * @param axis The axis to rotate the bone on
  8092. * @param amount The amount to rotate the bone
  8093. * @param space The space that the axis is in
  8094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8095. */
  8096. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8097. /**
  8098. * Set the rotation of the bone to a particular axis angle in local or world space
  8099. * @param axis The axis to rotate the bone on
  8100. * @param angle The angle that the bone should be rotated to
  8101. * @param space The space that the axis is in
  8102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8103. */
  8104. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8105. /**
  8106. * Set the euler rotation of the bone in local of world space
  8107. * @param rotation The euler rotation that the bone should be set to
  8108. * @param space The space that the rotation is in
  8109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8110. */
  8111. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8112. /**
  8113. * Set the quaternion rotation of the bone in local of world space
  8114. * @param quat The quaternion rotation that the bone should be set to
  8115. * @param space The space that the rotation is in
  8116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8117. */
  8118. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8119. /**
  8120. * Set the rotation matrix of the bone in local of world space
  8121. * @param rotMat The rotation matrix that the bone should be set to
  8122. * @param space The space that the rotation is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8126. private _rotateWithMatrix;
  8127. private _getNegativeRotationToRef;
  8128. /**
  8129. * Get the position of the bone in local or world space
  8130. * @param space The space that the returned position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. * @returns The position of the bone
  8133. */
  8134. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8135. /**
  8136. * Copy the position of the bone to a vector3 in local or world space
  8137. * @param space The space that the returned position is in
  8138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8139. * @param result The vector3 to copy the position to
  8140. */
  8141. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8142. /**
  8143. * Get the absolute position of the bone (world space)
  8144. * @param mesh The mesh that this bone is attached to
  8145. * @returns The absolute position of the bone
  8146. */
  8147. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8148. /**
  8149. * Copy the absolute position of the bone (world space) to the result param
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @param result The vector3 to copy the absolute position to
  8152. */
  8153. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8154. /**
  8155. * Compute the absolute transforms of this bone and its children
  8156. */
  8157. computeAbsoluteTransforms(): void;
  8158. /**
  8159. * Get the world direction from an axis that is in the local space of the bone
  8160. * @param localAxis The local direction that is used to compute the world direction
  8161. * @param mesh The mesh that this bone is attached to
  8162. * @returns The world direction
  8163. */
  8164. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8165. /**
  8166. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8167. * @param localAxis The local direction that is used to compute the world direction
  8168. * @param mesh The mesh that this bone is attached to
  8169. * @param result The vector3 that the world direction will be copied to
  8170. */
  8171. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8172. /**
  8173. * Get the euler rotation of the bone in local or world space
  8174. * @param space The space that the rotation should be in
  8175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8176. * @returns The euler rotation
  8177. */
  8178. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8179. /**
  8180. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8181. * @param space The space that the rotation should be in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. * @param result The vector3 that the rotation should be copied to
  8184. */
  8185. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8186. /**
  8187. * Get the quaternion rotation of the bone in either local or world space
  8188. * @param space The space that the rotation should be in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. * @returns The quaternion rotation
  8191. */
  8192. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8193. /**
  8194. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8195. * @param space The space that the rotation should be in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. * @param result The quaternion that the rotation should be copied to
  8198. */
  8199. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8200. /**
  8201. * Get the rotation matrix of the bone in local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The rotation matrix
  8205. */
  8206. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8207. /**
  8208. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The quaternion that the rotation should be copied to
  8212. */
  8213. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8214. /**
  8215. * Get the world position of a point that is in the local space of the bone
  8216. * @param position The local position
  8217. * @param mesh The mesh that this bone is attached to
  8218. * @returns The world position
  8219. */
  8220. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8221. /**
  8222. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8223. * @param position The local position
  8224. * @param mesh The mesh that this bone is attached to
  8225. * @param result The vector3 that the world position should be copied to
  8226. */
  8227. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8228. /**
  8229. * Get the local position of a point that is in world space
  8230. * @param position The world position
  8231. * @param mesh The mesh that this bone is attached to
  8232. * @returns The local position
  8233. */
  8234. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8235. /**
  8236. * Get the local position of a point that is in world space and copy it to the result param
  8237. * @param position The world position
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @param result The vector3 that the local position should be copied to
  8240. */
  8241. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8242. }
  8243. }
  8244. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8245. import { Nullable } from "babylonjs/types";
  8246. import { Scene } from "babylonjs/scene";
  8247. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8249. /**
  8250. * Class for creating a cube texture
  8251. */
  8252. export class CubeTexture extends BaseTexture {
  8253. private _delayedOnLoad;
  8254. /**
  8255. * The url of the texture
  8256. */
  8257. url: string;
  8258. /**
  8259. * Gets or sets the center of the bounding box associated with the cube texture.
  8260. * It must define where the camera used to render the texture was set
  8261. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8262. */
  8263. boundingBoxPosition: Vector3;
  8264. private _boundingBoxSize;
  8265. /**
  8266. * Gets or sets the size of the bounding box associated with the cube texture
  8267. * When defined, the cubemap will switch to local mode
  8268. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8269. * @example https://www.babylonjs-playground.com/#RNASML
  8270. */
  8271. /**
  8272. * Returns the bounding box size
  8273. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8274. */
  8275. boundingBoxSize: Vector3;
  8276. protected _rotationY: number;
  8277. /**
  8278. * Sets texture matrix rotation angle around Y axis in radians.
  8279. */
  8280. /**
  8281. * Gets texture matrix rotation angle around Y axis radians.
  8282. */
  8283. rotationY: number;
  8284. /**
  8285. * Are mip maps generated for this texture or not.
  8286. */
  8287. readonly noMipmap: boolean;
  8288. private _noMipmap;
  8289. private _files;
  8290. private _extensions;
  8291. private _textureMatrix;
  8292. private _format;
  8293. private _createPolynomials;
  8294. /** @hidden */
  8295. _prefiltered: boolean;
  8296. /**
  8297. * Creates a cube texture from an array of image urls
  8298. * @param files defines an array of image urls
  8299. * @param scene defines the hosting scene
  8300. * @param noMipmap specifies if mip maps are not used
  8301. * @returns a cube texture
  8302. */
  8303. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8304. /**
  8305. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8306. * @param url defines the url of the prefiltered texture
  8307. * @param scene defines the scene the texture is attached to
  8308. * @param forcedExtension defines the extension of the file if different from the url
  8309. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8310. * @return the prefiltered texture
  8311. */
  8312. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8313. /**
  8314. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8315. * as prefiltered data.
  8316. * @param rootUrl defines the url of the texture or the root name of the six images
  8317. * @param scene defines the scene the texture is attached to
  8318. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8319. * @param noMipmap defines if mipmaps should be created or not
  8320. * @param files defines the six files to load for the different faces
  8321. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8322. * @param onError defines a callback triggered in case of error during load
  8323. * @param format defines the internal format to use for the texture once loaded
  8324. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8325. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8326. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8327. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8328. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8329. * @return the cube texture
  8330. */
  8331. 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);
  8332. /**
  8333. * Get the current class name of the texture useful for serialization or dynamic coding.
  8334. * @returns "CubeTexture"
  8335. */
  8336. getClassName(): string;
  8337. /**
  8338. * Update the url (and optional buffer) of this texture if url was null during construction.
  8339. * @param url the url of the texture
  8340. * @param forcedExtension defines the extension to use
  8341. * @param onLoad callback called when the texture is loaded (defaults to null)
  8342. */
  8343. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8344. /**
  8345. * Delays loading of the cube texture
  8346. * @param forcedExtension defines the extension to use
  8347. */
  8348. delayLoad(forcedExtension?: string): void;
  8349. /**
  8350. * Returns the reflection texture matrix
  8351. * @returns the reflection texture matrix
  8352. */
  8353. getReflectionTextureMatrix(): Matrix;
  8354. /**
  8355. * Sets the reflection texture matrix
  8356. * @param value Reflection texture matrix
  8357. */
  8358. setReflectionTextureMatrix(value: Matrix): void;
  8359. /**
  8360. * Parses text to create a cube texture
  8361. * @param parsedTexture define the serialized text to read from
  8362. * @param scene defines the hosting scene
  8363. * @param rootUrl defines the root url of the cube texture
  8364. * @returns a cube texture
  8365. */
  8366. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8367. /**
  8368. * Makes a clone, or deep copy, of the cube texture
  8369. * @returns a new cube texture
  8370. */
  8371. clone(): CubeTexture;
  8372. }
  8373. }
  8374. declare module "babylonjs/Shaders/postprocess.vertex" {
  8375. /** @hidden */
  8376. export var postprocessVertexShader: {
  8377. name: string;
  8378. shader: string;
  8379. };
  8380. }
  8381. declare module "babylonjs/Cameras/targetCamera" {
  8382. import { Nullable } from "babylonjs/types";
  8383. import { Camera } from "babylonjs/Cameras/camera";
  8384. import { Scene } from "babylonjs/scene";
  8385. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8386. /**
  8387. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8388. * This is the base of the follow, arc rotate cameras and Free camera
  8389. * @see http://doc.babylonjs.com/features/cameras
  8390. */
  8391. export class TargetCamera extends Camera {
  8392. private static _RigCamTransformMatrix;
  8393. private static _TargetTransformMatrix;
  8394. private static _TargetFocalPoint;
  8395. /**
  8396. * Define the current direction the camera is moving to
  8397. */
  8398. cameraDirection: Vector3;
  8399. /**
  8400. * Define the current rotation the camera is rotating to
  8401. */
  8402. cameraRotation: Vector2;
  8403. /**
  8404. * When set, the up vector of the camera will be updated by the rotation of the camera
  8405. */
  8406. updateUpVectorFromRotation: boolean;
  8407. private _tmpQuaternion;
  8408. /**
  8409. * Define the current rotation of the camera
  8410. */
  8411. rotation: Vector3;
  8412. /**
  8413. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8414. */
  8415. rotationQuaternion: Quaternion;
  8416. /**
  8417. * Define the current speed of the camera
  8418. */
  8419. speed: number;
  8420. /**
  8421. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8422. * around all axis.
  8423. */
  8424. noRotationConstraint: boolean;
  8425. /**
  8426. * Define the current target of the camera as an object or a position.
  8427. */
  8428. lockedTarget: any;
  8429. /** @hidden */
  8430. _currentTarget: Vector3;
  8431. /** @hidden */
  8432. _initialFocalDistance: number;
  8433. /** @hidden */
  8434. _viewMatrix: Matrix;
  8435. /** @hidden */
  8436. _camMatrix: Matrix;
  8437. /** @hidden */
  8438. _cameraTransformMatrix: Matrix;
  8439. /** @hidden */
  8440. _cameraRotationMatrix: Matrix;
  8441. /** @hidden */
  8442. _referencePoint: Vector3;
  8443. /** @hidden */
  8444. _transformedReferencePoint: Vector3;
  8445. protected _globalCurrentTarget: Vector3;
  8446. protected _globalCurrentUpVector: Vector3;
  8447. /** @hidden */
  8448. _reset: () => void;
  8449. private _defaultUp;
  8450. /**
  8451. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8452. * This is the base of the follow, arc rotate cameras and Free camera
  8453. * @see http://doc.babylonjs.com/features/cameras
  8454. * @param name Defines the name of the camera in the scene
  8455. * @param position Defines the start position of the camera in the scene
  8456. * @param scene Defines the scene the camera belongs to
  8457. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8458. */
  8459. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8460. /**
  8461. * Gets the position in front of the camera at a given distance.
  8462. * @param distance The distance from the camera we want the position to be
  8463. * @returns the position
  8464. */
  8465. getFrontPosition(distance: number): Vector3;
  8466. /** @hidden */
  8467. _getLockedTargetPosition(): Nullable<Vector3>;
  8468. private _storedPosition;
  8469. private _storedRotation;
  8470. private _storedRotationQuaternion;
  8471. /**
  8472. * Store current camera state of the camera (fov, position, rotation, etc..)
  8473. * @returns the camera
  8474. */
  8475. storeState(): Camera;
  8476. /**
  8477. * Restored camera state. You must call storeState() first
  8478. * @returns whether it was successful or not
  8479. * @hidden
  8480. */
  8481. _restoreStateValues(): boolean;
  8482. /** @hidden */
  8483. _initCache(): void;
  8484. /** @hidden */
  8485. _updateCache(ignoreParentClass?: boolean): void;
  8486. /** @hidden */
  8487. _isSynchronizedViewMatrix(): boolean;
  8488. /** @hidden */
  8489. _computeLocalCameraSpeed(): number;
  8490. /**
  8491. * Defines the target the camera should look at.
  8492. * This will automatically adapt alpha beta and radius to fit within the new target.
  8493. * @param target Defines the new target as a Vector or a mesh
  8494. */
  8495. setTarget(target: Vector3): void;
  8496. /**
  8497. * Return the current target position of the camera. This value is expressed in local space.
  8498. * @returns the target position
  8499. */
  8500. getTarget(): Vector3;
  8501. /** @hidden */
  8502. _decideIfNeedsToMove(): boolean;
  8503. /** @hidden */
  8504. _updatePosition(): void;
  8505. /** @hidden */
  8506. _checkInputs(): void;
  8507. protected _updateCameraRotationMatrix(): void;
  8508. /**
  8509. * 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)
  8510. * @returns the current camera
  8511. */
  8512. private _rotateUpVectorWithCameraRotationMatrix;
  8513. private _cachedRotationZ;
  8514. private _cachedQuaternionRotationZ;
  8515. /** @hidden */
  8516. _getViewMatrix(): Matrix;
  8517. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8518. /**
  8519. * @hidden
  8520. */
  8521. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8522. /**
  8523. * @hidden
  8524. */
  8525. _updateRigCameras(): void;
  8526. private _getRigCamPositionAndTarget;
  8527. /**
  8528. * Gets the current object class name.
  8529. * @return the class name
  8530. */
  8531. getClassName(): string;
  8532. }
  8533. }
  8534. declare module "babylonjs/Cameras/cameraInputsManager" {
  8535. import { Nullable } from "babylonjs/types";
  8536. import { Camera } from "babylonjs/Cameras/camera";
  8537. /**
  8538. * @ignore
  8539. * This is a list of all the different input types that are available in the application.
  8540. * Fo instance: ArcRotateCameraGamepadInput...
  8541. */
  8542. export var CameraInputTypes: {};
  8543. /**
  8544. * This is the contract to implement in order to create a new input class.
  8545. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8546. */
  8547. export interface ICameraInput<TCamera extends Camera> {
  8548. /**
  8549. * Defines the camera the input is attached to.
  8550. */
  8551. camera: Nullable<TCamera>;
  8552. /**
  8553. * Gets the class name of the current intput.
  8554. * @returns the class name
  8555. */
  8556. getClassName(): string;
  8557. /**
  8558. * Get the friendly name associated with the input class.
  8559. * @returns the input friendly name
  8560. */
  8561. getSimpleName(): string;
  8562. /**
  8563. * Attach the input controls to a specific dom element to get the input from.
  8564. * @param element Defines the element the controls should be listened from
  8565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8566. */
  8567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8568. /**
  8569. * Detach the current controls from the specified dom element.
  8570. * @param element Defines the element to stop listening the inputs from
  8571. */
  8572. detachControl(element: Nullable<HTMLElement>): void;
  8573. /**
  8574. * Update the current camera state depending on the inputs that have been used this frame.
  8575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8576. */
  8577. checkInputs?: () => void;
  8578. }
  8579. /**
  8580. * Represents a map of input types to input instance or input index to input instance.
  8581. */
  8582. export interface CameraInputsMap<TCamera extends Camera> {
  8583. /**
  8584. * Accessor to the input by input type.
  8585. */
  8586. [name: string]: ICameraInput<TCamera>;
  8587. /**
  8588. * Accessor to the input by input index.
  8589. */
  8590. [idx: number]: ICameraInput<TCamera>;
  8591. }
  8592. /**
  8593. * This represents the input manager used within a camera.
  8594. * It helps dealing with all the different kind of input attached to a camera.
  8595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8596. */
  8597. export class CameraInputsManager<TCamera extends Camera> {
  8598. /**
  8599. * Defines the list of inputs attahed to the camera.
  8600. */
  8601. attached: CameraInputsMap<TCamera>;
  8602. /**
  8603. * Defines the dom element the camera is collecting inputs from.
  8604. * This is null if the controls have not been attached.
  8605. */
  8606. attachedElement: Nullable<HTMLElement>;
  8607. /**
  8608. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8609. */
  8610. noPreventDefault: boolean;
  8611. /**
  8612. * Defined the camera the input manager belongs to.
  8613. */
  8614. camera: TCamera;
  8615. /**
  8616. * Update the current camera state depending on the inputs that have been used this frame.
  8617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8618. */
  8619. checkInputs: () => void;
  8620. /**
  8621. * Instantiate a new Camera Input Manager.
  8622. * @param camera Defines the camera the input manager blongs to
  8623. */
  8624. constructor(camera: TCamera);
  8625. /**
  8626. * Add an input method to a camera
  8627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8628. * @param input camera input method
  8629. */
  8630. add(input: ICameraInput<TCamera>): void;
  8631. /**
  8632. * Remove a specific input method from a camera
  8633. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8634. * @param inputToRemove camera input method
  8635. */
  8636. remove(inputToRemove: ICameraInput<TCamera>): void;
  8637. /**
  8638. * Remove a specific input type from a camera
  8639. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8640. * @param inputType the type of the input to remove
  8641. */
  8642. removeByType(inputType: string): void;
  8643. private _addCheckInputs;
  8644. /**
  8645. * Attach the input controls to the currently attached dom element to listen the events from.
  8646. * @param input Defines the input to attach
  8647. */
  8648. attachInput(input: ICameraInput<TCamera>): void;
  8649. /**
  8650. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8651. * @param element Defines the dom element to collect the events from
  8652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8653. */
  8654. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8655. /**
  8656. * Detach the current manager inputs controls from a specific dom element.
  8657. * @param element Defines the dom element to collect the events from
  8658. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8659. */
  8660. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8661. /**
  8662. * Rebuild the dynamic inputCheck function from the current list of
  8663. * defined inputs in the manager.
  8664. */
  8665. rebuildInputCheck(): void;
  8666. /**
  8667. * Remove all attached input methods from a camera
  8668. */
  8669. clear(): void;
  8670. /**
  8671. * Serialize the current input manager attached to a camera.
  8672. * This ensures than once parsed,
  8673. * the input associated to the camera will be identical to the current ones
  8674. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8675. */
  8676. serialize(serializedCamera: any): void;
  8677. /**
  8678. * Parses an input manager serialized JSON to restore the previous list of inputs
  8679. * and states associated to a camera.
  8680. * @param parsedCamera Defines the JSON to parse
  8681. */
  8682. parse(parsedCamera: any): void;
  8683. }
  8684. }
  8685. declare module "babylonjs/Events/keyboardEvents" {
  8686. /**
  8687. * Gather the list of keyboard event types as constants.
  8688. */
  8689. export class KeyboardEventTypes {
  8690. /**
  8691. * The keydown event is fired when a key becomes active (pressed).
  8692. */
  8693. static readonly KEYDOWN: number;
  8694. /**
  8695. * The keyup event is fired when a key has been released.
  8696. */
  8697. static readonly KEYUP: number;
  8698. }
  8699. /**
  8700. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8701. */
  8702. export class KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Instantiates a new keyboard info.
  8713. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8714. * @param type Defines the type of event (KeyboardEventTypes)
  8715. * @param event Defines the related dom event
  8716. */
  8717. constructor(
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number,
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent);
  8726. }
  8727. /**
  8728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8729. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8730. */
  8731. export class KeyboardInfoPre extends KeyboardInfo {
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number;
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent;
  8740. /**
  8741. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8742. */
  8743. skipOnPointerObservable: boolean;
  8744. /**
  8745. * Instantiates a new keyboard pre info.
  8746. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8747. * @param type Defines the type of event (KeyboardEventTypes)
  8748. * @param event Defines the related dom event
  8749. */
  8750. constructor(
  8751. /**
  8752. * Defines the type of event (KeyboardEventTypes)
  8753. */
  8754. type: number,
  8755. /**
  8756. * Defines the related dom event
  8757. */
  8758. event: KeyboardEvent);
  8759. }
  8760. }
  8761. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8762. import { Nullable } from "babylonjs/types";
  8763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8764. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8765. /**
  8766. * Manage the keyboard inputs to control the movement of a free camera.
  8767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8768. */
  8769. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8770. /**
  8771. * Defines the camera the input is attached to.
  8772. */
  8773. camera: FreeCamera;
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8776. */
  8777. keysUp: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8780. */
  8781. keysDown: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8784. */
  8785. keysLeft: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8788. */
  8789. keysRight: number[];
  8790. private _keys;
  8791. private _onCanvasBlurObserver;
  8792. private _onKeyboardObserver;
  8793. private _engine;
  8794. private _scene;
  8795. /**
  8796. * Attach the input controls to a specific dom element to get the input from.
  8797. * @param element Defines the element the controls should be listened from
  8798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8799. */
  8800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8801. /**
  8802. * Detach the current controls from the specified dom element.
  8803. * @param element Defines the element to stop listening the inputs from
  8804. */
  8805. detachControl(element: Nullable<HTMLElement>): void;
  8806. /**
  8807. * Update the current camera state depending on the inputs that have been used this frame.
  8808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8809. */
  8810. checkInputs(): void;
  8811. /**
  8812. * Gets the class name of the current intput.
  8813. * @returns the class name
  8814. */
  8815. getClassName(): string;
  8816. /** @hidden */
  8817. _onLostFocus(): void;
  8818. /**
  8819. * Get the friendly name associated with the input class.
  8820. * @returns the input friendly name
  8821. */
  8822. getSimpleName(): string;
  8823. }
  8824. }
  8825. declare module "babylonjs/Lights/shadowLight" {
  8826. import { Camera } from "babylonjs/Cameras/camera";
  8827. import { Scene } from "babylonjs/scene";
  8828. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8830. import { Light } from "babylonjs/Lights/light";
  8831. /**
  8832. * Interface describing all the common properties and methods a shadow light needs to implement.
  8833. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8834. * as well as binding the different shadow properties to the effects.
  8835. */
  8836. export interface IShadowLight extends Light {
  8837. /**
  8838. * The light id in the scene (used in scene.findLighById for instance)
  8839. */
  8840. id: string;
  8841. /**
  8842. * The position the shdow will be casted from.
  8843. */
  8844. position: Vector3;
  8845. /**
  8846. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8847. */
  8848. direction: Vector3;
  8849. /**
  8850. * The transformed position. Position of the light in world space taking parenting in account.
  8851. */
  8852. transformedPosition: Vector3;
  8853. /**
  8854. * The transformed direction. Direction of the light in world space taking parenting in account.
  8855. */
  8856. transformedDirection: Vector3;
  8857. /**
  8858. * The friendly name of the light in the scene.
  8859. */
  8860. name: string;
  8861. /**
  8862. * Defines the shadow projection clipping minimum z value.
  8863. */
  8864. shadowMinZ: number;
  8865. /**
  8866. * Defines the shadow projection clipping maximum z value.
  8867. */
  8868. shadowMaxZ: number;
  8869. /**
  8870. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8871. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8872. */
  8873. computeTransformedInformation(): boolean;
  8874. /**
  8875. * Gets the scene the light belongs to.
  8876. * @returns The scene
  8877. */
  8878. getScene(): Scene;
  8879. /**
  8880. * Callback defining a custom Projection Matrix Builder.
  8881. * This can be used to override the default projection matrix computation.
  8882. */
  8883. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8884. /**
  8885. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8886. * @param matrix The materix to updated with the projection information
  8887. * @param viewMatrix The transform matrix of the light
  8888. * @param renderList The list of mesh to render in the map
  8889. * @returns The current light
  8890. */
  8891. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8892. /**
  8893. * Gets the current depth scale used in ESM.
  8894. * @returns The scale
  8895. */
  8896. getDepthScale(): number;
  8897. /**
  8898. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8899. * @returns true if a cube texture needs to be use
  8900. */
  8901. needCube(): boolean;
  8902. /**
  8903. * Detects if the projection matrix requires to be recomputed this frame.
  8904. * @returns true if it requires to be recomputed otherwise, false.
  8905. */
  8906. needProjectionMatrixCompute(): boolean;
  8907. /**
  8908. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8909. */
  8910. forceProjectionMatrixCompute(): void;
  8911. /**
  8912. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8913. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8914. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8915. */
  8916. getShadowDirection(faceIndex?: number): Vector3;
  8917. /**
  8918. * Gets the minZ used for shadow according to both the scene and the light.
  8919. * @param activeCamera The camera we are returning the min for
  8920. * @returns the depth min z
  8921. */
  8922. getDepthMinZ(activeCamera: Camera): number;
  8923. /**
  8924. * Gets the maxZ used for shadow according to both the scene and the light.
  8925. * @param activeCamera The camera we are returning the max for
  8926. * @returns the depth max z
  8927. */
  8928. getDepthMaxZ(activeCamera: Camera): number;
  8929. }
  8930. /**
  8931. * Base implementation IShadowLight
  8932. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8933. */
  8934. export abstract class ShadowLight extends Light implements IShadowLight {
  8935. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8936. protected _position: Vector3;
  8937. protected _setPosition(value: Vector3): void;
  8938. /**
  8939. * Sets the position the shadow will be casted from. Also use as the light position for both
  8940. * point and spot lights.
  8941. */
  8942. /**
  8943. * Sets the position the shadow will be casted from. Also use as the light position for both
  8944. * point and spot lights.
  8945. */
  8946. position: Vector3;
  8947. protected _direction: Vector3;
  8948. protected _setDirection(value: Vector3): void;
  8949. /**
  8950. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8951. * Also use as the light direction on spot and directional lights.
  8952. */
  8953. /**
  8954. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8955. * Also use as the light direction on spot and directional lights.
  8956. */
  8957. direction: Vector3;
  8958. private _shadowMinZ;
  8959. /**
  8960. * Gets the shadow projection clipping minimum z value.
  8961. */
  8962. /**
  8963. * Sets the shadow projection clipping minimum z value.
  8964. */
  8965. shadowMinZ: number;
  8966. private _shadowMaxZ;
  8967. /**
  8968. * Sets the shadow projection clipping maximum z value.
  8969. */
  8970. /**
  8971. * Gets the shadow projection clipping maximum z value.
  8972. */
  8973. shadowMaxZ: number;
  8974. /**
  8975. * Callback defining a custom Projection Matrix Builder.
  8976. * This can be used to override the default projection matrix computation.
  8977. */
  8978. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8979. /**
  8980. * The transformed position. Position of the light in world space taking parenting in account.
  8981. */
  8982. transformedPosition: Vector3;
  8983. /**
  8984. * The transformed direction. Direction of the light in world space taking parenting in account.
  8985. */
  8986. transformedDirection: Vector3;
  8987. private _needProjectionMatrixCompute;
  8988. /**
  8989. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8990. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8991. */
  8992. computeTransformedInformation(): boolean;
  8993. /**
  8994. * Return the depth scale used for the shadow map.
  8995. * @returns the depth scale.
  8996. */
  8997. getDepthScale(): number;
  8998. /**
  8999. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9000. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9001. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9002. */
  9003. getShadowDirection(faceIndex?: number): Vector3;
  9004. /**
  9005. * Returns the ShadowLight absolute position in the World.
  9006. * @returns the position vector in world space
  9007. */
  9008. getAbsolutePosition(): Vector3;
  9009. /**
  9010. * Sets the ShadowLight direction toward the passed target.
  9011. * @param target The point to target in local space
  9012. * @returns the updated ShadowLight direction
  9013. */
  9014. setDirectionToTarget(target: Vector3): Vector3;
  9015. /**
  9016. * Returns the light rotation in euler definition.
  9017. * @returns the x y z rotation in local space.
  9018. */
  9019. getRotation(): Vector3;
  9020. /**
  9021. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9022. * @returns true if a cube texture needs to be use
  9023. */
  9024. needCube(): boolean;
  9025. /**
  9026. * Detects if the projection matrix requires to be recomputed this frame.
  9027. * @returns true if it requires to be recomputed otherwise, false.
  9028. */
  9029. needProjectionMatrixCompute(): boolean;
  9030. /**
  9031. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9032. */
  9033. forceProjectionMatrixCompute(): void;
  9034. /** @hidden */
  9035. _initCache(): void;
  9036. /** @hidden */
  9037. _isSynchronized(): boolean;
  9038. /**
  9039. * Computes the world matrix of the node
  9040. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9041. * @returns the world matrix
  9042. */
  9043. computeWorldMatrix(force?: boolean): Matrix;
  9044. /**
  9045. * Gets the minZ used for shadow according to both the scene and the light.
  9046. * @param activeCamera The camera we are returning the min for
  9047. * @returns the depth min z
  9048. */
  9049. getDepthMinZ(activeCamera: Camera): number;
  9050. /**
  9051. * Gets the maxZ used for shadow according to both the scene and the light.
  9052. * @param activeCamera The camera we are returning the max for
  9053. * @returns the depth max z
  9054. */
  9055. getDepthMaxZ(activeCamera: Camera): number;
  9056. /**
  9057. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9058. * @param matrix The materix to updated with the projection information
  9059. * @param viewMatrix The transform matrix of the light
  9060. * @param renderList The list of mesh to render in the map
  9061. * @returns The current light
  9062. */
  9063. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9064. }
  9065. }
  9066. declare module "babylonjs/Materials/materialHelper" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Engine } from "babylonjs/Engines/engine";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9073. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9075. /**
  9076. * "Static Class" containing the most commonly used helper while dealing with material for
  9077. * rendering purpose.
  9078. *
  9079. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9080. *
  9081. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9082. */
  9083. export class MaterialHelper {
  9084. /**
  9085. * Bind the current view position to an effect.
  9086. * @param effect The effect to be bound
  9087. * @param scene The scene the eyes position is used from
  9088. */
  9089. static BindEyePosition(effect: Effect, scene: Scene): void;
  9090. /**
  9091. * Helps preparing the defines values about the UVs in used in the effect.
  9092. * UVs are shared as much as we can accross channels in the shaders.
  9093. * @param texture The texture we are preparing the UVs for
  9094. * @param defines The defines to update
  9095. * @param key The channel key "diffuse", "specular"... used in the shader
  9096. */
  9097. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9098. /**
  9099. * Binds a texture matrix value to its corrsponding uniform
  9100. * @param texture The texture to bind the matrix for
  9101. * @param uniformBuffer The uniform buffer receivin the data
  9102. * @param key The channel key "diffuse", "specular"... used in the shader
  9103. */
  9104. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9105. /**
  9106. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9107. * @param mesh defines the current mesh
  9108. * @param scene defines the current scene
  9109. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9110. * @param pointsCloud defines if point cloud rendering has to be turned on
  9111. * @param fogEnabled defines if fog has to be turned on
  9112. * @param alphaTest defines if alpha testing has to be turned on
  9113. * @param defines defines the current list of defines
  9114. */
  9115. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9116. /**
  9117. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9118. * @param scene defines the current scene
  9119. * @param engine defines the current engine
  9120. * @param defines specifies the list of active defines
  9121. * @param useInstances defines if instances have to be turned on
  9122. * @param useClipPlane defines if clip plane have to be turned on
  9123. */
  9124. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9125. /**
  9126. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9127. * @param mesh The mesh containing the geometry data we will draw
  9128. * @param defines The defines to update
  9129. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9130. * @param useBones Precise whether bones should be used or not (override mesh info)
  9131. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9132. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9133. * @returns false if defines are considered not dirty and have not been checked
  9134. */
  9135. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9136. /**
  9137. * Prepares the defines related to the light information passed in parameter
  9138. * @param scene The scene we are intending to draw
  9139. * @param mesh The mesh the effect is compiling for
  9140. * @param defines The defines to update
  9141. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9142. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9143. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9144. * @returns true if normals will be required for the rest of the effect
  9145. */
  9146. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9147. /**
  9148. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9149. * that won t be acctive due to defines being turned off.
  9150. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9151. * @param samplersList The samplers list
  9152. * @param defines The defines helping in the list generation
  9153. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9154. */
  9155. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9156. /**
  9157. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9158. * @param defines The defines to update while falling back
  9159. * @param fallbacks The authorized effect fallbacks
  9160. * @param maxSimultaneousLights The maximum number of lights allowed
  9161. * @param rank the current rank of the Effect
  9162. * @returns The newly affected rank
  9163. */
  9164. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9165. /**
  9166. * Prepares the list of attributes required for morph targets according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param mesh The mesh to prepare the morph targets attributes for
  9169. * @param defines The current Defines of the effect
  9170. */
  9171. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the list of attributes required for bones according to the effect defines.
  9174. * @param attribs The current list of supported attribs
  9175. * @param mesh The mesh to prepare the bones attributes for
  9176. * @param defines The current Defines of the effect
  9177. * @param fallbacks The current efffect fallback strategy
  9178. */
  9179. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9180. /**
  9181. * Prepares the list of attributes required for instances according to the effect defines.
  9182. * @param attribs The current list of supported attribs
  9183. * @param defines The current Defines of the effect
  9184. */
  9185. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9186. /**
  9187. * Binds the light shadow information to the effect for the given mesh.
  9188. * @param light The light containing the generator
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param lightIndex The light index in the effect used to render the mesh
  9192. * @param effect The effect we are binding the data to
  9193. */
  9194. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9195. /**
  9196. * Binds the light information to the effect.
  9197. * @param light The light containing the generator
  9198. * @param effect The effect we are binding the data to
  9199. * @param lightIndex The light index in the effect used to render
  9200. */
  9201. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9202. /**
  9203. * Binds the lights information from the scene to the effect for the given mesh.
  9204. * @param scene The scene the lights belongs to
  9205. * @param mesh The mesh we are binding the information to render
  9206. * @param effect The effect we are binding the data to
  9207. * @param defines The generated defines for the effect
  9208. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9209. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9210. */
  9211. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9212. private static _tempFogColor;
  9213. /**
  9214. * Binds the fog information from the scene to the effect for the given mesh.
  9215. * @param scene The scene the lights belongs to
  9216. * @param mesh The mesh we are binding the information to render
  9217. * @param effect The effect we are binding the data to
  9218. * @param linearSpace Defines if the fog effect is applied in linear space
  9219. */
  9220. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9221. /**
  9222. * Binds the bones information from the mesh to the effect.
  9223. * @param mesh The mesh we are binding the information to render
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9227. /**
  9228. * Binds the morph targets information from the mesh to the effect.
  9229. * @param abstractMesh The mesh we are binding the information to render
  9230. * @param effect The effect we are binding the data to
  9231. */
  9232. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9233. /**
  9234. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9235. * @param defines The generated defines used in the effect
  9236. * @param effect The effect we are binding the data to
  9237. * @param scene The scene we are willing to render with logarithmic scale for
  9238. */
  9239. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9240. /**
  9241. * Binds the clip plane information from the scene to the effect.
  9242. * @param scene The scene the clip plane information are extracted from
  9243. * @param effect The effect we are binding the data to
  9244. */
  9245. static BindClipPlane(effect: Effect, scene: Scene): void;
  9246. }
  9247. }
  9248. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9249. /** @hidden */
  9250. export var kernelBlurVaryingDeclaration: {
  9251. name: string;
  9252. shader: string;
  9253. };
  9254. }
  9255. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9256. /** @hidden */
  9257. export var kernelBlurFragment: {
  9258. name: string;
  9259. shader: string;
  9260. };
  9261. }
  9262. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9263. /** @hidden */
  9264. export var kernelBlurFragment2: {
  9265. name: string;
  9266. shader: string;
  9267. };
  9268. }
  9269. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9270. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9273. /** @hidden */
  9274. export var kernelBlurPixelShader: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9280. /** @hidden */
  9281. export var kernelBlurVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9287. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9288. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9289. /** @hidden */
  9290. export var kernelBlurVertexShader: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9296. import { Vector2 } from "babylonjs/Maths/math";
  9297. import { Nullable } from "babylonjs/types";
  9298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9299. import { Camera } from "babylonjs/Cameras/camera";
  9300. import { Effect } from "babylonjs/Materials/effect";
  9301. import { Engine } from "babylonjs/Engines/engine";
  9302. import "babylonjs/Shaders/kernelBlur.fragment";
  9303. import "babylonjs/Shaders/kernelBlur.vertex";
  9304. /**
  9305. * The Blur Post Process which blurs an image based on a kernel and direction.
  9306. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9307. */
  9308. export class BlurPostProcess extends PostProcess {
  9309. /** The direction in which to blur the image. */
  9310. direction: Vector2;
  9311. private blockCompilation;
  9312. protected _kernel: number;
  9313. protected _idealKernel: number;
  9314. protected _packedFloat: boolean;
  9315. private _staticDefines;
  9316. /**
  9317. * Sets the length in pixels of the blur sample region
  9318. */
  9319. /**
  9320. * Gets the length in pixels of the blur sample region
  9321. */
  9322. kernel: number;
  9323. /**
  9324. * Sets wether or not the blur needs to unpack/repack floats
  9325. */
  9326. /**
  9327. * Gets wether or not the blur is unpacking/repacking floats
  9328. */
  9329. packedFloat: boolean;
  9330. /**
  9331. * Creates a new instance BlurPostProcess
  9332. * @param name The name of the effect.
  9333. * @param direction The direction in which to blur the image.
  9334. * @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.
  9335. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9336. * @param camera The camera to apply the render pass to.
  9337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9338. * @param engine The engine which the post process will be applied. (default: current engine)
  9339. * @param reusable If the post process can be reused on the same frame. (default: false)
  9340. * @param textureType Type of textures used when performing the post process. (default: 0)
  9341. * @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)
  9342. */
  9343. constructor(name: string,
  9344. /** The direction in which to blur the image. */
  9345. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9346. /**
  9347. * Updates the effect with the current post process compile time values and recompiles the shader.
  9348. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9349. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9350. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9351. * @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
  9352. * @param onCompiled Called when the shader has been compiled.
  9353. * @param onError Called if there is an error when compiling a shader.
  9354. */
  9355. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9356. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9357. /**
  9358. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9359. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9360. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9361. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9362. * The gaps between physical kernels are compensated for in the weighting of the samples
  9363. * @param idealKernel Ideal blur kernel.
  9364. * @return Nearest best kernel.
  9365. */
  9366. protected _nearestBestKernel(idealKernel: number): number;
  9367. /**
  9368. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9369. * @param x The point on the Gaussian distribution to sample.
  9370. * @return the value of the Gaussian function at x.
  9371. */
  9372. protected _gaussianWeight(x: number): number;
  9373. /**
  9374. * Generates a string that can be used as a floating point number in GLSL.
  9375. * @param x Value to print.
  9376. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9377. * @return GLSL float string.
  9378. */
  9379. protected _glslFloat(x: number, decimalFigures?: number): string;
  9380. }
  9381. }
  9382. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9383. /** @hidden */
  9384. export var shadowMapPixelShader: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9390. /** @hidden */
  9391. export var bonesDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9397. /** @hidden */
  9398. export var morphTargetsVertexGlobalDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9404. /** @hidden */
  9405. export var morphTargetsVertexDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9411. /** @hidden */
  9412. export var instancesDeclaration: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9418. /** @hidden */
  9419. export var helperFunctions: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9425. /** @hidden */
  9426. export var morphTargetsVertex: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9432. /** @hidden */
  9433. export var instancesVertex: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9439. /** @hidden */
  9440. export var bonesVertex: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9446. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9452. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9453. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9454. /** @hidden */
  9455. export var shadowMapVertexShader: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9461. /** @hidden */
  9462. export var depthBoxBlurPixelShader: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9468. import { Nullable } from "babylonjs/types";
  9469. import { Scene } from "babylonjs/scene";
  9470. import { Matrix } from "babylonjs/Maths/math";
  9471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9473. import { Mesh } from "babylonjs/Meshes/mesh";
  9474. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9475. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9476. import { Effect } from "babylonjs/Materials/effect";
  9477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9478. import "babylonjs/Shaders/shadowMap.fragment";
  9479. import "babylonjs/Shaders/shadowMap.vertex";
  9480. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9481. import { Observable } from "babylonjs/Misc/observable";
  9482. /**
  9483. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9484. */
  9485. export interface ICustomShaderOptions {
  9486. /**
  9487. * Gets or sets the custom shader name to use
  9488. */
  9489. shaderName: string;
  9490. /**
  9491. * The list of attribute names used in the shader
  9492. */
  9493. attributes?: string[];
  9494. /**
  9495. * The list of unifrom names used in the shader
  9496. */
  9497. uniforms?: string[];
  9498. /**
  9499. * The list of sampler names used in the shader
  9500. */
  9501. samplers?: string[];
  9502. /**
  9503. * The list of defines used in the shader
  9504. */
  9505. defines?: string[];
  9506. }
  9507. /**
  9508. * Interface to implement to create a shadow generator compatible with BJS.
  9509. */
  9510. export interface IShadowGenerator {
  9511. /**
  9512. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9513. * @returns The render target texture if present otherwise, null
  9514. */
  9515. getShadowMap(): Nullable<RenderTargetTexture>;
  9516. /**
  9517. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9518. * @returns The render target texture if the shadow map is present otherwise, null
  9519. */
  9520. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9521. /**
  9522. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9523. * @param subMesh The submesh we want to render in the shadow map
  9524. * @param useInstances Defines wether will draw in the map using instances
  9525. * @returns true if ready otherwise, false
  9526. */
  9527. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9528. /**
  9529. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9530. * @param defines Defines of the material we want to update
  9531. * @param lightIndex Index of the light in the enabled light list of the material
  9532. */
  9533. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9534. /**
  9535. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9536. * defined in the generator but impacting the effect).
  9537. * It implies the unifroms available on the materials are the standard BJS ones.
  9538. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9539. * @param effect The effect we are binfing the information for
  9540. */
  9541. bindShadowLight(lightIndex: string, effect: Effect): void;
  9542. /**
  9543. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9544. * (eq to shadow prjection matrix * light transform matrix)
  9545. * @returns The transform matrix used to create the shadow map
  9546. */
  9547. getTransformMatrix(): Matrix;
  9548. /**
  9549. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9550. * Cube and 2D textures for instance.
  9551. */
  9552. recreateShadowMap(): void;
  9553. /**
  9554. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9555. * @param onCompiled Callback triggered at the and of the effects compilation
  9556. * @param options Sets of optional options forcing the compilation with different modes
  9557. */
  9558. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9559. useInstances: boolean;
  9560. }>): void;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param options Sets of optional options forcing the compilation with different modes
  9564. * @returns A promise that resolves when the compilation completes
  9565. */
  9566. forceCompilationAsync(options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): Promise<void>;
  9569. /**
  9570. * Serializes the shadow generator setup to a json object.
  9571. * @returns The serialized JSON object
  9572. */
  9573. serialize(): any;
  9574. /**
  9575. * Disposes the Shadow map and related Textures and effects.
  9576. */
  9577. dispose(): void;
  9578. }
  9579. /**
  9580. * Default implementation IShadowGenerator.
  9581. * This is the main object responsible of generating shadows in the framework.
  9582. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9583. */
  9584. export class ShadowGenerator implements IShadowGenerator {
  9585. /**
  9586. * Shadow generator mode None: no filtering applied.
  9587. */
  9588. static readonly FILTER_NONE: number;
  9589. /**
  9590. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9596. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9597. */
  9598. static readonly FILTER_POISSONSAMPLING: number;
  9599. /**
  9600. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9601. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9602. */
  9603. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9604. /**
  9605. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9606. * edge artifacts on steep falloff.
  9607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9608. */
  9609. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9610. /**
  9611. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9612. * edge artifacts on steep falloff.
  9613. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9614. */
  9615. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9616. /**
  9617. * Shadow generator mode PCF: Percentage Closer Filtering
  9618. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9619. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9620. */
  9621. static readonly FILTER_PCF: number;
  9622. /**
  9623. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9624. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9625. * Contact Hardening
  9626. */
  9627. static readonly FILTER_PCSS: number;
  9628. /**
  9629. * Reserved for PCF and PCSS
  9630. * Highest Quality.
  9631. *
  9632. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9633. *
  9634. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9635. */
  9636. static readonly QUALITY_HIGH: number;
  9637. /**
  9638. * Reserved for PCF and PCSS
  9639. * Good tradeoff for quality/perf cross devices
  9640. *
  9641. * Execute PCF on a 3*3 kernel.
  9642. *
  9643. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9644. */
  9645. static readonly QUALITY_MEDIUM: number;
  9646. /**
  9647. * Reserved for PCF and PCSS
  9648. * The lowest quality but the fastest.
  9649. *
  9650. * Execute PCF on a 1*1 kernel.
  9651. *
  9652. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9653. */
  9654. static readonly QUALITY_LOW: number;
  9655. /** Gets or sets the custom shader name to use */
  9656. customShaderOptions: ICustomShaderOptions;
  9657. /**
  9658. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9659. */
  9660. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9661. /**
  9662. * Observable triggered before a mesh is rendered in the shadow map.
  9663. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9664. */
  9665. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9666. private _bias;
  9667. /**
  9668. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9669. */
  9670. /**
  9671. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9672. */
  9673. bias: number;
  9674. private _normalBias;
  9675. /**
  9676. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9677. */
  9678. /**
  9679. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9680. */
  9681. normalBias: number;
  9682. private _blurBoxOffset;
  9683. /**
  9684. * Gets the blur box offset: offset applied during the blur pass.
  9685. * Only useful if useKernelBlur = false
  9686. */
  9687. /**
  9688. * Sets the blur box offset: offset applied during the blur pass.
  9689. * Only useful if useKernelBlur = false
  9690. */
  9691. blurBoxOffset: number;
  9692. private _blurScale;
  9693. /**
  9694. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9695. * 2 means half of the size.
  9696. */
  9697. /**
  9698. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9699. * 2 means half of the size.
  9700. */
  9701. blurScale: number;
  9702. private _blurKernel;
  9703. /**
  9704. * Gets the blur kernel: kernel size of the blur pass.
  9705. * Only useful if useKernelBlur = true
  9706. */
  9707. /**
  9708. * Sets the blur kernel: kernel size of the blur pass.
  9709. * Only useful if useKernelBlur = true
  9710. */
  9711. blurKernel: number;
  9712. private _useKernelBlur;
  9713. /**
  9714. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9715. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9716. */
  9717. /**
  9718. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9719. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9720. */
  9721. useKernelBlur: boolean;
  9722. private _depthScale;
  9723. /**
  9724. * Gets the depth scale used in ESM mode.
  9725. */
  9726. /**
  9727. * Sets the depth scale used in ESM mode.
  9728. * This can override the scale stored on the light.
  9729. */
  9730. depthScale: number;
  9731. private _filter;
  9732. /**
  9733. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9734. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9735. */
  9736. /**
  9737. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9738. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9739. */
  9740. filter: number;
  9741. /**
  9742. * Gets if the current filter is set to Poisson Sampling.
  9743. */
  9744. /**
  9745. * Sets the current filter to Poisson Sampling.
  9746. */
  9747. usePoissonSampling: boolean;
  9748. /**
  9749. * Gets if the current filter is set to ESM.
  9750. */
  9751. /**
  9752. * Sets the current filter is to ESM.
  9753. */
  9754. useExponentialShadowMap: boolean;
  9755. /**
  9756. * Gets if the current filter is set to filtered ESM.
  9757. */
  9758. /**
  9759. * Gets if the current filter is set to filtered ESM.
  9760. */
  9761. useBlurExponentialShadowMap: boolean;
  9762. /**
  9763. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9764. * exponential to prevent steep falloff artifacts).
  9765. */
  9766. /**
  9767. * Sets the current filter to "close ESM" (using the inverse of the
  9768. * exponential to prevent steep falloff artifacts).
  9769. */
  9770. useCloseExponentialShadowMap: boolean;
  9771. /**
  9772. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9773. * exponential to prevent steep falloff artifacts).
  9774. */
  9775. /**
  9776. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9777. * exponential to prevent steep falloff artifacts).
  9778. */
  9779. useBlurCloseExponentialShadowMap: boolean;
  9780. /**
  9781. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9782. */
  9783. /**
  9784. * Sets the current filter to "PCF" (percentage closer filtering).
  9785. */
  9786. usePercentageCloserFiltering: boolean;
  9787. private _filteringQuality;
  9788. /**
  9789. * Gets the PCF or PCSS Quality.
  9790. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9791. */
  9792. /**
  9793. * Sets the PCF or PCSS Quality.
  9794. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9795. */
  9796. filteringQuality: number;
  9797. /**
  9798. * Gets if the current filter is set to "PCSS" (contact hardening).
  9799. */
  9800. /**
  9801. * Sets the current filter to "PCSS" (contact hardening).
  9802. */
  9803. useContactHardeningShadow: boolean;
  9804. private _contactHardeningLightSizeUVRatio;
  9805. /**
  9806. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9807. * Using a ratio helps keeping shape stability independently of the map size.
  9808. *
  9809. * It does not account for the light projection as it was having too much
  9810. * instability during the light setup or during light position changes.
  9811. *
  9812. * Only valid if useContactHardeningShadow is true.
  9813. */
  9814. /**
  9815. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9816. * Using a ratio helps keeping shape stability independently of the map size.
  9817. *
  9818. * It does not account for the light projection as it was having too much
  9819. * instability during the light setup or during light position changes.
  9820. *
  9821. * Only valid if useContactHardeningShadow is true.
  9822. */
  9823. contactHardeningLightSizeUVRatio: number;
  9824. private _darkness;
  9825. /**
  9826. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9827. * 0 means strongest and 1 would means no shadow.
  9828. * @returns the darkness.
  9829. */
  9830. getDarkness(): number;
  9831. /**
  9832. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9833. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9834. * @returns the shadow generator allowing fluent coding.
  9835. */
  9836. setDarkness(darkness: number): ShadowGenerator;
  9837. private _transparencyShadow;
  9838. /**
  9839. * Sets the ability to have transparent shadow (boolean).
  9840. * @param transparent True if transparent else False
  9841. * @returns the shadow generator allowing fluent coding
  9842. */
  9843. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9844. private _shadowMap;
  9845. private _shadowMap2;
  9846. /**
  9847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9848. * @returns The render target texture if present otherwise, null
  9849. */
  9850. getShadowMap(): Nullable<RenderTargetTexture>;
  9851. /**
  9852. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9853. * @returns The render target texture if the shadow map is present otherwise, null
  9854. */
  9855. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9856. /**
  9857. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9858. * @param mesh Mesh to add
  9859. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9860. * @returns the Shadow Generator itself
  9861. */
  9862. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9863. /**
  9864. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9865. * @param mesh Mesh to remove
  9866. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9867. * @returns the Shadow Generator itself
  9868. */
  9869. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9870. /**
  9871. * Controls the extent to which the shadows fade out at the edge of the frustum
  9872. * Used only by directionals and spots
  9873. */
  9874. frustumEdgeFalloff: number;
  9875. private _light;
  9876. /**
  9877. * Returns the associated light object.
  9878. * @returns the light generating the shadow
  9879. */
  9880. getLight(): IShadowLight;
  9881. /**
  9882. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9883. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9884. * It might on the other hand introduce peter panning.
  9885. */
  9886. forceBackFacesOnly: boolean;
  9887. private _scene;
  9888. private _lightDirection;
  9889. private _effect;
  9890. private _viewMatrix;
  9891. private _projectionMatrix;
  9892. private _transformMatrix;
  9893. private _cachedPosition;
  9894. private _cachedDirection;
  9895. private _cachedDefines;
  9896. private _currentRenderID;
  9897. private _boxBlurPostprocess;
  9898. private _kernelBlurXPostprocess;
  9899. private _kernelBlurYPostprocess;
  9900. private _blurPostProcesses;
  9901. private _mapSize;
  9902. private _currentFaceIndex;
  9903. private _currentFaceIndexCache;
  9904. private _textureType;
  9905. private _defaultTextureMatrix;
  9906. /** @hidden */
  9907. static _SceneComponentInitialization: (scene: Scene) => void;
  9908. /**
  9909. * Creates a ShadowGenerator object.
  9910. * A ShadowGenerator is the required tool to use the shadows.
  9911. * Each light casting shadows needs to use its own ShadowGenerator.
  9912. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9913. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9914. * @param light The light object generating the shadows.
  9915. * @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.
  9916. */
  9917. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9918. private _initializeGenerator;
  9919. private _initializeShadowMap;
  9920. private _initializeBlurRTTAndPostProcesses;
  9921. private _renderForShadowMap;
  9922. private _renderSubMeshForShadowMap;
  9923. private _applyFilterValues;
  9924. /**
  9925. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9926. * @param onCompiled Callback triggered at the and of the effects compilation
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. */
  9929. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9930. useInstances: boolean;
  9931. }>): void;
  9932. /**
  9933. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9934. * @param options Sets of optional options forcing the compilation with different modes
  9935. * @returns A promise that resolves when the compilation completes
  9936. */
  9937. forceCompilationAsync(options?: Partial<{
  9938. useInstances: boolean;
  9939. }>): Promise<void>;
  9940. /**
  9941. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9942. * @param subMesh The submesh we want to render in the shadow map
  9943. * @param useInstances Defines wether will draw in the map using instances
  9944. * @returns true if ready otherwise, false
  9945. */
  9946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9947. /**
  9948. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9949. * @param defines Defines of the material we want to update
  9950. * @param lightIndex Index of the light in the enabled light list of the material
  9951. */
  9952. prepareDefines(defines: any, lightIndex: number): void;
  9953. /**
  9954. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9955. * defined in the generator but impacting the effect).
  9956. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9957. * @param effect The effect we are binfing the information for
  9958. */
  9959. bindShadowLight(lightIndex: string, effect: Effect): void;
  9960. /**
  9961. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9962. * (eq to shadow prjection matrix * light transform matrix)
  9963. * @returns The transform matrix used to create the shadow map
  9964. */
  9965. getTransformMatrix(): Matrix;
  9966. /**
  9967. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9968. * Cube and 2D textures for instance.
  9969. */
  9970. recreateShadowMap(): void;
  9971. private _disposeBlurPostProcesses;
  9972. private _disposeRTTandPostProcesses;
  9973. /**
  9974. * Disposes the ShadowGenerator.
  9975. * Returns nothing.
  9976. */
  9977. dispose(): void;
  9978. /**
  9979. * Serializes the shadow generator setup to a json object.
  9980. * @returns The serialized JSON object
  9981. */
  9982. serialize(): any;
  9983. /**
  9984. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9985. * @param parsedShadowGenerator The JSON object to parse
  9986. * @param scene The scene to create the shadow map for
  9987. * @returns The parsed shadow generator
  9988. */
  9989. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9990. }
  9991. }
  9992. declare module "babylonjs/Lights/light" {
  9993. import { Nullable } from "babylonjs/types";
  9994. import { Scene } from "babylonjs/scene";
  9995. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9996. import { Node } from "babylonjs/node";
  9997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9998. import { Effect } from "babylonjs/Materials/effect";
  9999. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10000. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10001. /**
  10002. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10003. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10004. * 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.
  10005. */
  10006. export abstract class Light extends Node {
  10007. /**
  10008. * Falloff Default: light is falling off following the material specification:
  10009. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10010. */
  10011. static readonly FALLOFF_DEFAULT: number;
  10012. /**
  10013. * Falloff Physical: light is falling off following the inverse squared distance law.
  10014. */
  10015. static readonly FALLOFF_PHYSICAL: number;
  10016. /**
  10017. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10018. * to enhance interoperability with other engines.
  10019. */
  10020. static readonly FALLOFF_GLTF: number;
  10021. /**
  10022. * Falloff Standard: light is falling off like in the standard material
  10023. * to enhance interoperability with other materials.
  10024. */
  10025. static readonly FALLOFF_STANDARD: number;
  10026. /**
  10027. * If every light affecting the material is in this lightmapMode,
  10028. * material.lightmapTexture adds or multiplies
  10029. * (depends on material.useLightmapAsShadowmap)
  10030. * after every other light calculations.
  10031. */
  10032. static readonly LIGHTMAP_DEFAULT: number;
  10033. /**
  10034. * material.lightmapTexture as only diffuse lighting from this light
  10035. * adds only specular lighting from this light
  10036. * adds dynamic shadows
  10037. */
  10038. static readonly LIGHTMAP_SPECULAR: number;
  10039. /**
  10040. * material.lightmapTexture as only lighting
  10041. * no light calculation from this light
  10042. * only adds dynamic shadows from this light
  10043. */
  10044. static readonly LIGHTMAP_SHADOWSONLY: number;
  10045. /**
  10046. * Each light type uses the default quantity according to its type:
  10047. * point/spot lights use luminous intensity
  10048. * directional lights use illuminance
  10049. */
  10050. static readonly INTENSITYMODE_AUTOMATIC: number;
  10051. /**
  10052. * lumen (lm)
  10053. */
  10054. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10055. /**
  10056. * candela (lm/sr)
  10057. */
  10058. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10059. /**
  10060. * lux (lm/m^2)
  10061. */
  10062. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10063. /**
  10064. * nit (cd/m^2)
  10065. */
  10066. static readonly INTENSITYMODE_LUMINANCE: number;
  10067. /**
  10068. * Light type const id of the point light.
  10069. */
  10070. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10071. /**
  10072. * Light type const id of the directional light.
  10073. */
  10074. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10075. /**
  10076. * Light type const id of the spot light.
  10077. */
  10078. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10079. /**
  10080. * Light type const id of the hemispheric light.
  10081. */
  10082. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10083. /**
  10084. * Diffuse gives the basic color to an object.
  10085. */
  10086. diffuse: Color3;
  10087. /**
  10088. * Specular produces a highlight color on an object.
  10089. * Note: This is note affecting PBR materials.
  10090. */
  10091. specular: Color3;
  10092. /**
  10093. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10094. * falling off base on range or angle.
  10095. * This can be set to any values in Light.FALLOFF_x.
  10096. *
  10097. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10098. * other types of materials.
  10099. */
  10100. falloffType: number;
  10101. /**
  10102. * Strength of the light.
  10103. * Note: By default it is define in the framework own unit.
  10104. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10105. */
  10106. intensity: number;
  10107. private _range;
  10108. protected _inverseSquaredRange: number;
  10109. /**
  10110. * Defines how far from the source the light is impacting in scene units.
  10111. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10112. */
  10113. /**
  10114. * Defines how far from the source the light is impacting in scene units.
  10115. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10116. */
  10117. range: number;
  10118. /**
  10119. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10120. * of light.
  10121. */
  10122. private _photometricScale;
  10123. private _intensityMode;
  10124. /**
  10125. * Gets the photometric scale used to interpret the intensity.
  10126. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10127. */
  10128. /**
  10129. * Sets the photometric scale used to interpret the intensity.
  10130. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10131. */
  10132. intensityMode: number;
  10133. private _radius;
  10134. /**
  10135. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10136. */
  10137. /**
  10138. * sets the light radius used by PBR Materials to simulate soft area lights.
  10139. */
  10140. radius: number;
  10141. private _renderPriority;
  10142. /**
  10143. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10144. * exceeding the number allowed of the materials.
  10145. */
  10146. renderPriority: number;
  10147. private _shadowEnabled;
  10148. /**
  10149. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10150. * the current shadow generator.
  10151. */
  10152. /**
  10153. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10154. * the current shadow generator.
  10155. */
  10156. shadowEnabled: boolean;
  10157. private _includedOnlyMeshes;
  10158. /**
  10159. * Gets the only meshes impacted by this light.
  10160. */
  10161. /**
  10162. * Sets the only meshes impacted by this light.
  10163. */
  10164. includedOnlyMeshes: AbstractMesh[];
  10165. private _excludedMeshes;
  10166. /**
  10167. * Gets the meshes not impacted by this light.
  10168. */
  10169. /**
  10170. * Sets the meshes not impacted by this light.
  10171. */
  10172. excludedMeshes: AbstractMesh[];
  10173. private _excludeWithLayerMask;
  10174. /**
  10175. * Gets the layer id use to find what meshes are not impacted by the light.
  10176. * Inactive if 0
  10177. */
  10178. /**
  10179. * Sets the layer id use to find what meshes are not impacted by the light.
  10180. * Inactive if 0
  10181. */
  10182. excludeWithLayerMask: number;
  10183. private _includeOnlyWithLayerMask;
  10184. /**
  10185. * Gets the layer id use to find what meshes are impacted by the light.
  10186. * Inactive if 0
  10187. */
  10188. /**
  10189. * Sets the layer id use to find what meshes are impacted by the light.
  10190. * Inactive if 0
  10191. */
  10192. includeOnlyWithLayerMask: number;
  10193. private _lightmapMode;
  10194. /**
  10195. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10196. */
  10197. /**
  10198. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10199. */
  10200. lightmapMode: number;
  10201. /**
  10202. * Shadow generator associted to the light.
  10203. * @hidden Internal use only.
  10204. */
  10205. _shadowGenerator: Nullable<IShadowGenerator>;
  10206. /**
  10207. * @hidden Internal use only.
  10208. */
  10209. _excludedMeshesIds: string[];
  10210. /**
  10211. * @hidden Internal use only.
  10212. */
  10213. _includedOnlyMeshesIds: string[];
  10214. /**
  10215. * The current light unifom buffer.
  10216. * @hidden Internal use only.
  10217. */
  10218. _uniformBuffer: UniformBuffer;
  10219. /**
  10220. * Creates a Light object in the scene.
  10221. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10222. * @param name The firendly name of the light
  10223. * @param scene The scene the light belongs too
  10224. */
  10225. constructor(name: string, scene: Scene);
  10226. protected abstract _buildUniformLayout(): void;
  10227. /**
  10228. * Sets the passed Effect "effect" with the Light information.
  10229. * @param effect The effect to update
  10230. * @param lightIndex The index of the light in the effect to update
  10231. * @returns The light
  10232. */
  10233. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10234. /**
  10235. * Returns the string "Light".
  10236. * @returns the class name
  10237. */
  10238. getClassName(): string;
  10239. /** @hidden */
  10240. readonly _isLight: boolean;
  10241. /**
  10242. * Converts the light information to a readable string for debug purpose.
  10243. * @param fullDetails Supports for multiple levels of logging within scene loading
  10244. * @returns the human readable light info
  10245. */
  10246. toString(fullDetails?: boolean): string;
  10247. /** @hidden */
  10248. protected _syncParentEnabledState(): void;
  10249. /**
  10250. * Set the enabled state of this node.
  10251. * @param value - the new enabled state
  10252. */
  10253. setEnabled(value: boolean): void;
  10254. /**
  10255. * Returns the Light associated shadow generator if any.
  10256. * @return the associated shadow generator.
  10257. */
  10258. getShadowGenerator(): Nullable<IShadowGenerator>;
  10259. /**
  10260. * Returns a Vector3, the absolute light position in the World.
  10261. * @returns the world space position of the light
  10262. */
  10263. getAbsolutePosition(): Vector3;
  10264. /**
  10265. * Specifies if the light will affect the passed mesh.
  10266. * @param mesh The mesh to test against the light
  10267. * @return true the mesh is affected otherwise, false.
  10268. */
  10269. canAffectMesh(mesh: AbstractMesh): boolean;
  10270. /**
  10271. * Sort function to order lights for rendering.
  10272. * @param a First Light object to compare to second.
  10273. * @param b Second Light object to compare first.
  10274. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10275. */
  10276. static CompareLightsPriority(a: Light, b: Light): number;
  10277. /**
  10278. * Releases resources associated with this node.
  10279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10281. */
  10282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10283. /**
  10284. * Returns the light type ID (integer).
  10285. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10286. */
  10287. getTypeID(): number;
  10288. /**
  10289. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10290. * @returns the scaled intensity in intensity mode unit
  10291. */
  10292. getScaledIntensity(): number;
  10293. /**
  10294. * Returns a new Light object, named "name", from the current one.
  10295. * @param name The name of the cloned light
  10296. * @returns the new created light
  10297. */
  10298. clone(name: string): Nullable<Light>;
  10299. /**
  10300. * Serializes the current light into a Serialization object.
  10301. * @returns the serialized object.
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10306. * This new light is named "name" and added to the passed scene.
  10307. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10308. * @param name The friendly name of the light
  10309. * @param scene The scene the new light will belong to
  10310. * @returns the constructor function
  10311. */
  10312. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10313. /**
  10314. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10315. * @param parsedLight The JSON representation of the light
  10316. * @param scene The scene to create the parsed light in
  10317. * @returns the created light after parsing
  10318. */
  10319. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10320. private _hookArrayForExcluded;
  10321. private _hookArrayForIncludedOnly;
  10322. private _resyncMeshes;
  10323. /**
  10324. * Forces the meshes to update their light related information in their rendering used effects
  10325. * @hidden Internal Use Only
  10326. */
  10327. _markMeshesAsLightDirty(): void;
  10328. /**
  10329. * Recomputes the cached photometric scale if needed.
  10330. */
  10331. private _computePhotometricScale;
  10332. /**
  10333. * Returns the Photometric Scale according to the light type and intensity mode.
  10334. */
  10335. private _getPhotometricScale;
  10336. /**
  10337. * Reorder the light in the scene according to their defined priority.
  10338. * @hidden Internal Use Only
  10339. */
  10340. _reorderLightsInScene(): void;
  10341. /**
  10342. * Prepares the list of defines specific to the light type.
  10343. * @param defines the list of defines
  10344. * @param lightIndex defines the index of the light for the effect
  10345. */
  10346. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10347. }
  10348. }
  10349. declare module "babylonjs/Actions/action" {
  10350. import { Observable } from "babylonjs/Misc/observable";
  10351. import { Condition } from "babylonjs/Actions/condition";
  10352. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10353. import { ActionManager } from "babylonjs/Actions/actionManager";
  10354. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10355. /**
  10356. * Interface used to define Action
  10357. */
  10358. export interface IAction {
  10359. /**
  10360. * Trigger for the action
  10361. */
  10362. trigger: number;
  10363. /** Options of the trigger */
  10364. triggerOptions: any;
  10365. /**
  10366. * Gets the trigger parameters
  10367. * @returns the trigger parameters
  10368. */
  10369. getTriggerParameter(): any;
  10370. /**
  10371. * Internal only - executes current action event
  10372. * @hidden
  10373. */
  10374. _executeCurrent(evt?: ActionEvent): void;
  10375. /**
  10376. * Serialize placeholder for child classes
  10377. * @param parent of child
  10378. * @returns the serialized object
  10379. */
  10380. serialize(parent: any): any;
  10381. /**
  10382. * Internal only
  10383. * @hidden
  10384. */
  10385. _prepare(): void;
  10386. /**
  10387. * Internal only - manager for action
  10388. * @hidden
  10389. */
  10390. _actionManager: AbstractActionManager;
  10391. }
  10392. /**
  10393. * The action to be carried out following a trigger
  10394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10395. */
  10396. export class Action implements IAction {
  10397. /** the trigger, with or without parameters, for the action */
  10398. triggerOptions: any;
  10399. /**
  10400. * Trigger for the action
  10401. */
  10402. trigger: number;
  10403. /**
  10404. * Internal only - manager for action
  10405. * @hidden
  10406. */
  10407. _actionManager: ActionManager;
  10408. private _nextActiveAction;
  10409. private _child;
  10410. private _condition?;
  10411. private _triggerParameter;
  10412. /**
  10413. * An event triggered prior to action being executed.
  10414. */
  10415. onBeforeExecuteObservable: Observable<Action>;
  10416. /**
  10417. * Creates a new Action
  10418. * @param triggerOptions the trigger, with or without parameters, for the action
  10419. * @param condition an optional determinant of action
  10420. */
  10421. constructor(
  10422. /** the trigger, with or without parameters, for the action */
  10423. triggerOptions: any, condition?: Condition);
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _prepare(): void;
  10429. /**
  10430. * Gets the trigger parameters
  10431. * @returns the trigger parameters
  10432. */
  10433. getTriggerParameter(): any;
  10434. /**
  10435. * Internal only - executes current action event
  10436. * @hidden
  10437. */
  10438. _executeCurrent(evt?: ActionEvent): void;
  10439. /**
  10440. * Execute placeholder for child classes
  10441. * @param evt optional action event
  10442. */
  10443. execute(evt?: ActionEvent): void;
  10444. /**
  10445. * Skips to next active action
  10446. */
  10447. skipToNextActiveAction(): void;
  10448. /**
  10449. * Adds action to chain of actions, may be a DoNothingAction
  10450. * @param action defines the next action to execute
  10451. * @returns The action passed in
  10452. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10453. */
  10454. then(action: Action): Action;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _getProperty(propertyPath: string): string;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getEffectiveTarget(target: any, propertyPath: string): any;
  10465. /**
  10466. * Serialize placeholder for child classes
  10467. * @param parent of child
  10468. * @returns the serialized object
  10469. */
  10470. serialize(parent: any): any;
  10471. /**
  10472. * Internal only called by serialize
  10473. * @hidden
  10474. */
  10475. protected _serialize(serializedAction: any, parent?: any): any;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. static _SerializeValueAsString: (value: any) => string;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10486. name: string;
  10487. targetType: string;
  10488. value: string;
  10489. };
  10490. }
  10491. }
  10492. declare module "babylonjs/Actions/condition" {
  10493. import { ActionManager } from "babylonjs/Actions/actionManager";
  10494. /**
  10495. * A Condition applied to an Action
  10496. */
  10497. export class Condition {
  10498. /**
  10499. * Internal only - manager for action
  10500. * @hidden
  10501. */
  10502. _actionManager: ActionManager;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. _evaluationId: number;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _currentResult: boolean;
  10513. /**
  10514. * Creates a new Condition
  10515. * @param actionManager the manager of the action the condition is applied to
  10516. */
  10517. constructor(actionManager: ActionManager);
  10518. /**
  10519. * Check if the current condition is valid
  10520. * @returns a boolean
  10521. */
  10522. isValid(): boolean;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. _getProperty(propertyPath: string): string;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getEffectiveTarget(target: any, propertyPath: string): any;
  10533. /**
  10534. * Serialize placeholder for child classes
  10535. * @returns the serialized object
  10536. */
  10537. serialize(): any;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. protected _serialize(serializedCondition: any): any;
  10543. }
  10544. /**
  10545. * Defines specific conditional operators as extensions of Condition
  10546. */
  10547. export class ValueCondition extends Condition {
  10548. /** path to specify the property of the target the conditional operator uses */
  10549. propertyPath: string;
  10550. /** the value compared by the conditional operator against the current value of the property */
  10551. value: any;
  10552. /** the conditional operator, default ValueCondition.IsEqual */
  10553. operator: number;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsEqual;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsDifferent;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsGreater;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsLesser;
  10574. /**
  10575. * returns the number for IsEqual
  10576. */
  10577. static readonly IsEqual: number;
  10578. /**
  10579. * Returns the number for IsDifferent
  10580. */
  10581. static readonly IsDifferent: number;
  10582. /**
  10583. * Returns the number for IsGreater
  10584. */
  10585. static readonly IsGreater: number;
  10586. /**
  10587. * Returns the number for IsLesser
  10588. */
  10589. static readonly IsLesser: number;
  10590. /**
  10591. * Internal only The action manager for the condition
  10592. * @hidden
  10593. */
  10594. _actionManager: ActionManager;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. private _target;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _effectiveTarget;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _property;
  10610. /**
  10611. * Creates a new ValueCondition
  10612. * @param actionManager manager for the action the condition applies to
  10613. * @param target for the action
  10614. * @param propertyPath path to specify the property of the target the conditional operator uses
  10615. * @param value the value compared by the conditional operator against the current value of the property
  10616. * @param operator the conditional operator, default ValueCondition.IsEqual
  10617. */
  10618. constructor(actionManager: ActionManager, target: any,
  10619. /** path to specify the property of the target the conditional operator uses */
  10620. propertyPath: string,
  10621. /** the value compared by the conditional operator against the current value of the property */
  10622. value: any,
  10623. /** the conditional operator, default ValueCondition.IsEqual */
  10624. operator?: number);
  10625. /**
  10626. * Compares the given value with the property value for the specified conditional operator
  10627. * @returns the result of the comparison
  10628. */
  10629. isValid(): boolean;
  10630. /**
  10631. * Serialize the ValueCondition into a JSON compatible object
  10632. * @returns serialization object
  10633. */
  10634. serialize(): any;
  10635. /**
  10636. * Gets the name of the conditional operator for the ValueCondition
  10637. * @param operator the conditional operator
  10638. * @returns the name
  10639. */
  10640. static GetOperatorName(operator: number): string;
  10641. }
  10642. /**
  10643. * Defines a predicate condition as an extension of Condition
  10644. */
  10645. export class PredicateCondition extends Condition {
  10646. /** defines the predicate function used to validate the condition */
  10647. predicate: () => boolean;
  10648. /**
  10649. * Internal only - manager for action
  10650. * @hidden
  10651. */
  10652. _actionManager: ActionManager;
  10653. /**
  10654. * Creates a new PredicateCondition
  10655. * @param actionManager manager for the action the condition applies to
  10656. * @param predicate defines the predicate function used to validate the condition
  10657. */
  10658. constructor(actionManager: ActionManager,
  10659. /** defines the predicate function used to validate the condition */
  10660. predicate: () => boolean);
  10661. /**
  10662. * @returns the validity of the predicate condition
  10663. */
  10664. isValid(): boolean;
  10665. }
  10666. /**
  10667. * Defines a state condition as an extension of Condition
  10668. */
  10669. export class StateCondition extends Condition {
  10670. /** Value to compare with target state */
  10671. value: string;
  10672. /**
  10673. * Internal only - manager for action
  10674. * @hidden
  10675. */
  10676. _actionManager: ActionManager;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _target;
  10682. /**
  10683. * Creates a new StateCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target of the condition
  10686. * @param value to compare with target state
  10687. */
  10688. constructor(actionManager: ActionManager, target: any,
  10689. /** Value to compare with target state */
  10690. value: string);
  10691. /**
  10692. * Gets a boolean indicating if the current condition is met
  10693. * @returns the validity of the state
  10694. */
  10695. isValid(): boolean;
  10696. /**
  10697. * Serialize the StateCondition into a JSON compatible object
  10698. * @returns serialization object
  10699. */
  10700. serialize(): any;
  10701. }
  10702. }
  10703. declare module "babylonjs/Actions/directActions" {
  10704. import { Action } from "babylonjs/Actions/action";
  10705. import { Condition } from "babylonjs/Actions/condition";
  10706. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10707. /**
  10708. * This defines an action responsible to toggle a boolean once triggered.
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10710. */
  10711. export class SwitchBooleanAction extends Action {
  10712. /**
  10713. * The path to the boolean property in the target object
  10714. */
  10715. propertyPath: string;
  10716. private _target;
  10717. private _effectiveTarget;
  10718. private _property;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the boolean
  10723. * @param propertyPath defines the path to the boolean property in the target object
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10727. /** @hidden */
  10728. _prepare(): void;
  10729. /**
  10730. * Execute the action toggle the boolean value.
  10731. */
  10732. execute(): void;
  10733. /**
  10734. * Serializes the actions and its related information.
  10735. * @param parent defines the object to serialize in
  10736. * @returns the serialized object
  10737. */
  10738. serialize(parent: any): any;
  10739. }
  10740. /**
  10741. * This defines an action responsible to set a the state field of the target
  10742. * to a desired value once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class SetStateAction extends Action {
  10746. /**
  10747. * The value to store in the state field.
  10748. */
  10749. value: string;
  10750. private _target;
  10751. /**
  10752. * Instantiate the action
  10753. * @param triggerOptions defines the trigger options
  10754. * @param target defines the object containing the state property
  10755. * @param value defines the value to store in the state field
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10759. /**
  10760. * Execute the action and store the value on the target state property.
  10761. */
  10762. execute(): void;
  10763. /**
  10764. * Serializes the actions and its related information.
  10765. * @param parent defines the object to serialize in
  10766. * @returns the serialized object
  10767. */
  10768. serialize(parent: any): any;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set a property of the target
  10772. * to a desired value once triggered.
  10773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10774. */
  10775. export class SetValueAction extends Action {
  10776. /**
  10777. * The path of the property to set in the target.
  10778. */
  10779. propertyPath: string;
  10780. /**
  10781. * The value to set in the property
  10782. */
  10783. value: any;
  10784. private _target;
  10785. private _effectiveTarget;
  10786. private _property;
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param target defines the object containing the property
  10791. * @param propertyPath defines the path of the property to set in the target
  10792. * @param value defines the value to set in the property
  10793. * @param condition defines the trigger related conditions
  10794. */
  10795. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10796. /** @hidden */
  10797. _prepare(): void;
  10798. /**
  10799. * Execute the action and set the targetted property to the desired value.
  10800. */
  10801. execute(): void;
  10802. /**
  10803. * Serializes the actions and its related information.
  10804. * @param parent defines the object to serialize in
  10805. * @returns the serialized object
  10806. */
  10807. serialize(parent: any): any;
  10808. }
  10809. /**
  10810. * This defines an action responsible to increment the target value
  10811. * to a desired value once triggered.
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10813. */
  10814. export class IncrementValueAction extends Action {
  10815. /**
  10816. * The path of the property to increment in the target.
  10817. */
  10818. propertyPath: string;
  10819. /**
  10820. * The value we should increment the property by.
  10821. */
  10822. value: any;
  10823. private _target;
  10824. private _effectiveTarget;
  10825. private _property;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the object containing the property
  10830. * @param propertyPath defines the path of the property to increment in the target
  10831. * @param value defines the value value we should increment the property by
  10832. * @param condition defines the trigger related conditions
  10833. */
  10834. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10835. /** @hidden */
  10836. _prepare(): void;
  10837. /**
  10838. * Execute the action and increment the target of the value amount.
  10839. */
  10840. execute(): void;
  10841. /**
  10842. * Serializes the actions and its related information.
  10843. * @param parent defines the object to serialize in
  10844. * @returns the serialized object
  10845. */
  10846. serialize(parent: any): any;
  10847. }
  10848. /**
  10849. * This defines an action responsible to start an animation once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class PlayAnimationAction extends Action {
  10853. /**
  10854. * Where the animation should start (animation frame)
  10855. */
  10856. from: number;
  10857. /**
  10858. * Where the animation should stop (animation frame)
  10859. */
  10860. to: number;
  10861. /**
  10862. * Define if the animation should loop or stop after the first play.
  10863. */
  10864. loop?: boolean;
  10865. private _target;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the target animation or animation name
  10870. * @param from defines from where the animation should start (animation frame)
  10871. * @param end defines where the animation should stop (animation frame)
  10872. * @param loop defines if the animation should loop or stop after the first play
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action and play the animation.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to stop an animation once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class StopAnimationAction extends Action {
  10894. private _target;
  10895. /**
  10896. * Instantiate the action
  10897. * @param triggerOptions defines the trigger options
  10898. * @param target defines the target animation or animation name
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, target: any, condition?: Condition);
  10902. /** @hidden */
  10903. _prepare(): void;
  10904. /**
  10905. * Execute the action and stop the animation.
  10906. */
  10907. execute(): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible that does nothing once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class DoNothingAction extends Action {
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param condition defines the trigger related conditions
  10924. */
  10925. constructor(triggerOptions?: any, condition?: Condition);
  10926. /**
  10927. * Execute the action and do nothing.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible to trigger several actions once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class CombineAction extends Action {
  10942. /**
  10943. * The list of aggregated animations to run.
  10944. */
  10945. children: Action[];
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param children defines the list of aggregated animations to run
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10953. /** @hidden */
  10954. _prepare(): void;
  10955. /**
  10956. * Execute the action and executes all the aggregated actions.
  10957. */
  10958. execute(evt: ActionEvent): void;
  10959. /**
  10960. * Serializes the actions and its related information.
  10961. * @param parent defines the object to serialize in
  10962. * @returns the serialized object
  10963. */
  10964. serialize(parent: any): any;
  10965. }
  10966. /**
  10967. * This defines an action responsible to run code (external event) once triggered.
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10969. */
  10970. export class ExecuteCodeAction extends Action {
  10971. /**
  10972. * The callback function to run.
  10973. */
  10974. func: (evt: ActionEvent) => void;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param func defines the callback function to run
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10982. /**
  10983. * Execute the action and run the attached code.
  10984. */
  10985. execute(evt: ActionEvent): void;
  10986. }
  10987. /**
  10988. * This defines an action responsible to set the parent property of the target once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class SetParentAction extends Action {
  10992. private _parent;
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target containing the parent property
  10998. * @param parent defines from where the animation should start (animation frame)
  10999. * @param condition defines the trigger related conditions
  11000. */
  11001. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11002. /** @hidden */
  11003. _prepare(): void;
  11004. /**
  11005. * Execute the action and set the parent property.
  11006. */
  11007. execute(): void;
  11008. /**
  11009. * Serializes the actions and its related information.
  11010. * @param parent defines the object to serialize in
  11011. * @returns the serialized object
  11012. */
  11013. serialize(parent: any): any;
  11014. }
  11015. }
  11016. declare module "babylonjs/Actions/actionManager" {
  11017. import { Nullable } from "babylonjs/types";
  11018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11019. import { Scene } from "babylonjs/scene";
  11020. import { IAction } from "babylonjs/Actions/action";
  11021. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11022. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11023. /**
  11024. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11025. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11027. */
  11028. export class ActionManager extends AbstractActionManager {
  11029. /**
  11030. * Nothing
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly NothingTrigger: number;
  11034. /**
  11035. * On pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnPickTrigger: number;
  11039. /**
  11040. * On left pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnLeftPickTrigger: number;
  11044. /**
  11045. * On right pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnRightPickTrigger: number;
  11049. /**
  11050. * On center pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnCenterPickTrigger: number;
  11054. /**
  11055. * On pick down
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnPickDownTrigger: number;
  11059. /**
  11060. * On double pick
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnDoublePickTrigger: number;
  11064. /**
  11065. * On pick up
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnPickUpTrigger: number;
  11069. /**
  11070. * On pick out.
  11071. * This trigger will only be raised if you also declared a OnPickDown
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPickOutTrigger: number;
  11075. /**
  11076. * On long press
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnLongPressTrigger: number;
  11080. /**
  11081. * On pointer over
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnPointerOverTrigger: number;
  11085. /**
  11086. * On pointer out
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOutTrigger: number;
  11090. /**
  11091. * On every frame
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnEveryFrameTrigger: number;
  11095. /**
  11096. * On intersection enter
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnIntersectionEnterTrigger: number;
  11100. /**
  11101. * On intersection exit
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionExitTrigger: number;
  11105. /**
  11106. * On key down
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnKeyDownTrigger: number;
  11110. /**
  11111. * On key up
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyUpTrigger: number;
  11115. private _scene;
  11116. /**
  11117. * Creates a new action manager
  11118. * @param scene defines the hosting scene
  11119. */
  11120. constructor(scene: Scene);
  11121. /**
  11122. * Releases all associated resources
  11123. */
  11124. dispose(): void;
  11125. /**
  11126. * Gets hosting scene
  11127. * @returns the hosting scene
  11128. */
  11129. getScene(): Scene;
  11130. /**
  11131. * Does this action manager handles actions of any of the given triggers
  11132. * @param triggers defines the triggers to be tested
  11133. * @return a boolean indicating whether one (or more) of the triggers is handled
  11134. */
  11135. hasSpecificTriggers(triggers: number[]): boolean;
  11136. /**
  11137. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11138. * speed.
  11139. * @param triggerA defines the trigger to be tested
  11140. * @param triggerB defines the trigger to be tested
  11141. * @return a boolean indicating whether one (or more) of the triggers is handled
  11142. */
  11143. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11144. /**
  11145. * Does this action manager handles actions of a given trigger
  11146. * @param trigger defines the trigger to be tested
  11147. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11148. * @return whether the trigger is handled
  11149. */
  11150. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11151. /**
  11152. * Does this action manager has pointer triggers
  11153. */
  11154. readonly hasPointerTriggers: boolean;
  11155. /**
  11156. * Does this action manager has pick triggers
  11157. */
  11158. readonly hasPickTriggers: boolean;
  11159. /**
  11160. * Registers an action to this action manager
  11161. * @param action defines the action to be registered
  11162. * @return the action amended (prepared) after registration
  11163. */
  11164. registerAction(action: IAction): Nullable<IAction>;
  11165. /**
  11166. * Unregisters an action to this action manager
  11167. * @param action defines the action to be unregistered
  11168. * @return a boolean indicating whether the action has been unregistered
  11169. */
  11170. unregisterAction(action: IAction): Boolean;
  11171. /**
  11172. * Process a specific trigger
  11173. * @param trigger defines the trigger to process
  11174. * @param evt defines the event details to be processed
  11175. */
  11176. processTrigger(trigger: number, evt?: IActionEvent): void;
  11177. /** @hidden */
  11178. _getEffectiveTarget(target: any, propertyPath: string): any;
  11179. /** @hidden */
  11180. _getProperty(propertyPath: string): string;
  11181. /**
  11182. * Serialize this manager to a JSON object
  11183. * @param name defines the property name to store this manager
  11184. * @returns a JSON representation of this manager
  11185. */
  11186. serialize(name: string): any;
  11187. /**
  11188. * Creates a new ActionManager from a JSON data
  11189. * @param parsedActions defines the JSON data to read from
  11190. * @param object defines the hosting mesh
  11191. * @param scene defines the hosting scene
  11192. */
  11193. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11194. /**
  11195. * Get a trigger name by index
  11196. * @param trigger defines the trigger index
  11197. * @returns a trigger name
  11198. */
  11199. static GetTriggerName(trigger: number): string;
  11200. }
  11201. }
  11202. declare module "babylonjs/Culling/ray" {
  11203. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11204. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11206. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11207. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11208. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11209. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11210. /**
  11211. * Class representing a ray with position and direction
  11212. */
  11213. export class Ray {
  11214. /** origin point */
  11215. origin: Vector3;
  11216. /** direction */
  11217. direction: Vector3;
  11218. /** length of the ray */
  11219. length: number;
  11220. private static readonly TmpVector3;
  11221. private _tmpRay;
  11222. /**
  11223. * Creates a new ray
  11224. * @param origin origin point
  11225. * @param direction direction
  11226. * @param length length of the ray
  11227. */
  11228. constructor(
  11229. /** origin point */
  11230. origin: Vector3,
  11231. /** direction */
  11232. direction: Vector3,
  11233. /** length of the ray */
  11234. length?: number);
  11235. /**
  11236. * Checks if the ray intersects a box
  11237. * @param minimum bound of the box
  11238. * @param maximum bound of the box
  11239. * @param intersectionTreshold extra extend to be added to the box in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * Checks if the ray intersects a box
  11245. * @param box the bounding box to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11247. * @returns if the box was hit
  11248. */
  11249. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a sphere
  11252. * @param sphere the bounding sphere to check
  11253. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11254. * @returns true if it hits the sphere
  11255. */
  11256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11257. /**
  11258. * If the ray hits a triange
  11259. * @param vertex0 triangle vertex
  11260. * @param vertex1 triangle vertex
  11261. * @param vertex2 triangle vertex
  11262. * @returns intersection information if hit
  11263. */
  11264. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11265. /**
  11266. * Checks if ray intersects a plane
  11267. * @param plane the plane to check
  11268. * @returns the distance away it was hit
  11269. */
  11270. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param mesh the mesh to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @returns picking info of the intersecton
  11276. */
  11277. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11278. /**
  11279. * Checks if ray intersects a mesh
  11280. * @param meshes the meshes to check
  11281. * @param fastCheck if only the bounding box should checked
  11282. * @param results array to store result in
  11283. * @returns Array of picking infos
  11284. */
  11285. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11286. private _comparePickingInfo;
  11287. private static smallnum;
  11288. private static rayl;
  11289. /**
  11290. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11291. * @param sega the first point of the segment to test the intersection against
  11292. * @param segb the second point of the segment to test the intersection against
  11293. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11294. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11295. */
  11296. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11297. /**
  11298. * Update the ray from viewport position
  11299. * @param x position
  11300. * @param y y position
  11301. * @param viewportWidth viewport width
  11302. * @param viewportHeight viewport height
  11303. * @param world world matrix
  11304. * @param view view matrix
  11305. * @param projection projection matrix
  11306. * @returns this ray updated
  11307. */
  11308. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11309. /**
  11310. * Creates a ray with origin and direction of 0,0,0
  11311. * @returns the new ray
  11312. */
  11313. static Zero(): Ray;
  11314. /**
  11315. * Creates a new ray from screen space and viewport
  11316. * @param x position
  11317. * @param y y position
  11318. * @param viewportWidth viewport width
  11319. * @param viewportHeight viewport height
  11320. * @param world world matrix
  11321. * @param view view matrix
  11322. * @param projection projection matrix
  11323. * @returns new ray
  11324. */
  11325. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11326. /**
  11327. * 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
  11328. * transformed to the given world matrix.
  11329. * @param origin The origin point
  11330. * @param end The end point
  11331. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11332. * @returns the new ray
  11333. */
  11334. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @returns the resulting new ray
  11340. */
  11341. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11342. /**
  11343. * Transforms a ray by a matrix
  11344. * @param ray ray to transform
  11345. * @param matrix matrix to apply
  11346. * @param result ray to store result in
  11347. */
  11348. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11349. /**
  11350. * Unproject a ray from screen space to object space
  11351. * @param sourceX defines the screen space x coordinate to use
  11352. * @param sourceY defines the screen space y coordinate to use
  11353. * @param viewportWidth defines the current width of the viewport
  11354. * @param viewportHeight defines the current height of the viewport
  11355. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11356. * @param view defines the view matrix to use
  11357. * @param projection defines the projection matrix to use
  11358. */
  11359. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11360. }
  11361. /**
  11362. * Type used to define predicate used to select faces when a mesh intersection is detected
  11363. */
  11364. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11365. module "babylonjs/scene" {
  11366. interface Scene {
  11367. /** @hidden */
  11368. _tempPickingRay: Nullable<Ray>;
  11369. /** @hidden */
  11370. _cachedRayForTransform: Ray;
  11371. /** @hidden */
  11372. _pickWithRayInverseMatrix: Matrix;
  11373. /** @hidden */
  11374. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11375. /** @hidden */
  11376. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11377. }
  11378. }
  11379. }
  11380. declare module "babylonjs/sceneComponent" {
  11381. import { Scene } from "babylonjs/scene";
  11382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11384. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11385. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11386. import { Nullable } from "babylonjs/types";
  11387. import { Camera } from "babylonjs/Cameras/camera";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11390. import { AbstractScene } from "babylonjs/abstractScene";
  11391. /**
  11392. * Groups all the scene component constants in one place to ease maintenance.
  11393. * @hidden
  11394. */
  11395. export class SceneComponentConstants {
  11396. static readonly NAME_EFFECTLAYER: string;
  11397. static readonly NAME_LAYER: string;
  11398. static readonly NAME_LENSFLARESYSTEM: string;
  11399. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11400. static readonly NAME_PARTICLESYSTEM: string;
  11401. static readonly NAME_GAMEPAD: string;
  11402. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11403. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11404. static readonly NAME_DEPTHRENDERER: string;
  11405. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11406. static readonly NAME_SPRITE: string;
  11407. static readonly NAME_OUTLINERENDERER: string;
  11408. static readonly NAME_PROCEDURALTEXTURE: string;
  11409. static readonly NAME_SHADOWGENERATOR: string;
  11410. static readonly NAME_OCTREE: string;
  11411. static readonly NAME_PHYSICSENGINE: string;
  11412. static readonly NAME_AUDIO: string;
  11413. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11414. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11417. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11418. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11419. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11420. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11421. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11422. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11423. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11424. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11425. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11426. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11427. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11428. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11431. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11432. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11433. static readonly STEP_AFTERRENDER_AUDIO: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11438. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11439. static readonly STEP_POINTERMOVE_SPRITE: number;
  11440. static readonly STEP_POINTERDOWN_SPRITE: number;
  11441. static readonly STEP_POINTERUP_SPRITE: number;
  11442. }
  11443. /**
  11444. * This represents a scene component.
  11445. *
  11446. * This is used to decouple the dependency the scene is having on the different workloads like
  11447. * layers, post processes...
  11448. */
  11449. export interface ISceneComponent {
  11450. /**
  11451. * The name of the component. Each component must have a unique name.
  11452. */
  11453. name: string;
  11454. /**
  11455. * The scene the component belongs to.
  11456. */
  11457. scene: Scene;
  11458. /**
  11459. * Register the component to one instance of a scene.
  11460. */
  11461. register(): void;
  11462. /**
  11463. * Rebuilds the elements related to this component in case of
  11464. * context lost for instance.
  11465. */
  11466. rebuild(): void;
  11467. /**
  11468. * Disposes the component and the associated ressources.
  11469. */
  11470. dispose(): void;
  11471. }
  11472. /**
  11473. * This represents a SERIALIZABLE scene component.
  11474. *
  11475. * This extends Scene Component to add Serialization methods on top.
  11476. */
  11477. export interface ISceneSerializableComponent extends ISceneComponent {
  11478. /**
  11479. * Adds all the element from the container to the scene
  11480. * @param container the container holding the elements
  11481. */
  11482. addFromContainer(container: AbstractScene): void;
  11483. /**
  11484. * Removes all the elements in the container from the scene
  11485. * @param container contains the elements to remove
  11486. */
  11487. removeFromContainer(container: AbstractScene): void;
  11488. /**
  11489. * Serializes the component data to the specified json object
  11490. * @param serializationObject The object to serialize to
  11491. */
  11492. serialize(serializationObject: any): void;
  11493. }
  11494. /**
  11495. * Strong typing of a Mesh related stage step action
  11496. */
  11497. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11498. /**
  11499. * Strong typing of a Evaluate Sub Mesh related stage step action
  11500. */
  11501. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11502. /**
  11503. * Strong typing of a Active Mesh related stage step action
  11504. */
  11505. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11506. /**
  11507. * Strong typing of a Camera related stage step action
  11508. */
  11509. export type CameraStageAction = (camera: Camera) => void;
  11510. /**
  11511. * Strong typing of a Render Target related stage step action
  11512. */
  11513. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11514. /**
  11515. * Strong typing of a RenderingGroup related stage step action
  11516. */
  11517. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11518. /**
  11519. * Strong typing of a Mesh Render related stage step action
  11520. */
  11521. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11522. /**
  11523. * Strong typing of a simple stage step action
  11524. */
  11525. export type SimpleStageAction = () => void;
  11526. /**
  11527. * Strong typing of a render target action.
  11528. */
  11529. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11530. /**
  11531. * Strong typing of a pointer move action.
  11532. */
  11533. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11534. /**
  11535. * Strong typing of a pointer up/down action.
  11536. */
  11537. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11538. /**
  11539. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11540. * @hidden
  11541. */
  11542. export class Stage<T extends Function> extends Array<{
  11543. index: number;
  11544. component: ISceneComponent;
  11545. action: T;
  11546. }> {
  11547. /**
  11548. * Hide ctor from the rest of the world.
  11549. * @param items The items to add.
  11550. */
  11551. private constructor();
  11552. /**
  11553. * Creates a new Stage.
  11554. * @returns A new instance of a Stage
  11555. */
  11556. static Create<T extends Function>(): Stage<T>;
  11557. /**
  11558. * Registers a step in an ordered way in the targeted stage.
  11559. * @param index Defines the position to register the step in
  11560. * @param component Defines the component attached to the step
  11561. * @param action Defines the action to launch during the step
  11562. */
  11563. registerStep(index: number, component: ISceneComponent, action: T): void;
  11564. /**
  11565. * Clears all the steps from the stage.
  11566. */
  11567. clear(): void;
  11568. }
  11569. }
  11570. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11571. import { Nullable } from "babylonjs/types";
  11572. import { Observable } from "babylonjs/Misc/observable";
  11573. import { Scene } from "babylonjs/scene";
  11574. import { Sprite } from "babylonjs/Sprites/sprite";
  11575. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11576. import { Ray } from "babylonjs/Culling/ray";
  11577. import { Camera } from "babylonjs/Cameras/camera";
  11578. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11579. import { ISceneComponent } from "babylonjs/sceneComponent";
  11580. module "babylonjs/scene" {
  11581. interface Scene {
  11582. /** @hidden */
  11583. _pointerOverSprite: Nullable<Sprite>;
  11584. /** @hidden */
  11585. _pickedDownSprite: Nullable<Sprite>;
  11586. /** @hidden */
  11587. _tempSpritePickingRay: Nullable<Ray>;
  11588. /**
  11589. * All of the sprite managers added to this scene
  11590. * @see http://doc.babylonjs.com/babylon101/sprites
  11591. */
  11592. spriteManagers: Array<ISpriteManager>;
  11593. /**
  11594. * An event triggered when sprites rendering is about to start
  11595. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11596. */
  11597. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11598. /**
  11599. * An event triggered when sprites rendering is done
  11600. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11601. */
  11602. onAfterSpritesRenderingObservable: Observable<Scene>;
  11603. /** @hidden */
  11604. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11605. /** Launch a ray to try to pick a sprite in the scene
  11606. * @param x position on screen
  11607. * @param y position on screen
  11608. * @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
  11609. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11610. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11611. * @returns a PickingInfo
  11612. */
  11613. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11614. /** Use the given ray to pick a sprite in the scene
  11615. * @param ray The ray (in world space) to use to pick meshes
  11616. * @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
  11617. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11618. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11619. * @returns a PickingInfo
  11620. */
  11621. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11622. /**
  11623. * Force the sprite under the pointer
  11624. * @param sprite defines the sprite to use
  11625. */
  11626. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11627. /**
  11628. * Gets the sprite under the pointer
  11629. * @returns a Sprite or null if no sprite is under the pointer
  11630. */
  11631. getPointerOverSprite(): Nullable<Sprite>;
  11632. }
  11633. }
  11634. /**
  11635. * Defines the sprite scene component responsible to manage sprites
  11636. * in a given scene.
  11637. */
  11638. export class SpriteSceneComponent implements ISceneComponent {
  11639. /**
  11640. * The component name helpfull to identify the component in the list of scene components.
  11641. */
  11642. readonly name: string;
  11643. /**
  11644. * The scene the component belongs to.
  11645. */
  11646. scene: Scene;
  11647. /** @hidden */
  11648. private _spritePredicate;
  11649. /**
  11650. * Creates a new instance of the component for the given scene
  11651. * @param scene Defines the scene to register the component in
  11652. */
  11653. constructor(scene: Scene);
  11654. /**
  11655. * Registers the component in a given scene
  11656. */
  11657. register(): void;
  11658. /**
  11659. * Rebuilds the elements related to this component in case of
  11660. * context lost for instance.
  11661. */
  11662. rebuild(): void;
  11663. /**
  11664. * Disposes the component and the associated ressources.
  11665. */
  11666. dispose(): void;
  11667. private _pickSpriteButKeepRay;
  11668. private _pointerMove;
  11669. private _pointerDown;
  11670. private _pointerUp;
  11671. }
  11672. }
  11673. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11674. /** @hidden */
  11675. export var fogFragmentDeclaration: {
  11676. name: string;
  11677. shader: string;
  11678. };
  11679. }
  11680. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11681. /** @hidden */
  11682. export var fogFragment: {
  11683. name: string;
  11684. shader: string;
  11685. };
  11686. }
  11687. declare module "babylonjs/Shaders/sprites.fragment" {
  11688. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11689. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11690. /** @hidden */
  11691. export var spritesPixelShader: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11697. /** @hidden */
  11698. export var fogVertexDeclaration: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.vertex" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11705. /** @hidden */
  11706. export var spritesVertexShader: {
  11707. name: string;
  11708. shader: string;
  11709. };
  11710. }
  11711. declare module "babylonjs/Sprites/spriteManager" {
  11712. import { IDisposable, Scene } from "babylonjs/scene";
  11713. import { Nullable } from "babylonjs/types";
  11714. import { Observable } from "babylonjs/Misc/observable";
  11715. import { Sprite } from "babylonjs/Sprites/sprite";
  11716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11717. import { Camera } from "babylonjs/Cameras/camera";
  11718. import { Texture } from "babylonjs/Materials/Textures/texture";
  11719. import "babylonjs/Shaders/sprites.fragment";
  11720. import "babylonjs/Shaders/sprites.vertex";
  11721. import { Ray } from "babylonjs/Culling/ray";
  11722. /**
  11723. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11724. */
  11725. export interface ISpriteManager extends IDisposable {
  11726. /**
  11727. * Restricts the camera to viewing objects with the same layerMask.
  11728. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11729. */
  11730. layerMask: number;
  11731. /**
  11732. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11733. */
  11734. isPickable: boolean;
  11735. /**
  11736. * Specifies the rendering group id for this mesh (0 by default)
  11737. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11738. */
  11739. renderingGroupId: number;
  11740. /**
  11741. * Defines the list of sprites managed by the manager.
  11742. */
  11743. sprites: Array<Sprite>;
  11744. /**
  11745. * Tests the intersection of a sprite with a specific ray.
  11746. * @param ray The ray we are sending to test the collision
  11747. * @param camera The camera space we are sending rays in
  11748. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11749. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11750. * @returns picking info or null.
  11751. */
  11752. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11753. /**
  11754. * Renders the list of sprites on screen.
  11755. */
  11756. render(): void;
  11757. }
  11758. /**
  11759. * Class used to manage multiple sprites on the same spritesheet
  11760. * @see http://doc.babylonjs.com/babylon101/sprites
  11761. */
  11762. export class SpriteManager implements ISpriteManager {
  11763. /** defines the manager's name */
  11764. name: string;
  11765. /** Gets the list of sprites */
  11766. sprites: Sprite[];
  11767. /** Gets or sets the rendering group id (0 by default) */
  11768. renderingGroupId: number;
  11769. /** Gets or sets camera layer mask */
  11770. layerMask: number;
  11771. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11772. fogEnabled: boolean;
  11773. /** Gets or sets a boolean indicating if the sprites are pickable */
  11774. isPickable: boolean;
  11775. /** Defines the default width of a cell in the spritesheet */
  11776. cellWidth: number;
  11777. /** Defines the default height of a cell in the spritesheet */
  11778. cellHeight: number;
  11779. /**
  11780. * An event triggered when the manager is disposed.
  11781. */
  11782. onDisposeObservable: Observable<SpriteManager>;
  11783. private _onDisposeObserver;
  11784. /**
  11785. * Callback called when the manager is disposed
  11786. */
  11787. onDispose: () => void;
  11788. private _capacity;
  11789. private _spriteTexture;
  11790. private _epsilon;
  11791. private _scene;
  11792. private _vertexData;
  11793. private _buffer;
  11794. private _vertexBuffers;
  11795. private _indexBuffer;
  11796. private _effectBase;
  11797. private _effectFog;
  11798. /**
  11799. * Gets or sets the spritesheet texture
  11800. */
  11801. texture: Texture;
  11802. /**
  11803. * Creates a new sprite manager
  11804. * @param name defines the manager's name
  11805. * @param imgUrl defines the sprite sheet url
  11806. * @param capacity defines the maximum allowed number of sprites
  11807. * @param cellSize defines the size of a sprite cell
  11808. * @param scene defines the hosting scene
  11809. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11810. * @param samplingMode defines the smapling mode to use with spritesheet
  11811. */
  11812. constructor(
  11813. /** defines the manager's name */
  11814. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Render all child sprites
  11827. */
  11828. render(): void;
  11829. /**
  11830. * Release associated resources
  11831. */
  11832. dispose(): void;
  11833. }
  11834. }
  11835. declare module "babylonjs/Sprites/sprite" {
  11836. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11837. import { Nullable } from "babylonjs/types";
  11838. import { ActionManager } from "babylonjs/Actions/actionManager";
  11839. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11840. /**
  11841. * Class used to represent a sprite
  11842. * @see http://doc.babylonjs.com/babylon101/sprites
  11843. */
  11844. export class Sprite {
  11845. /** defines the name */
  11846. name: string;
  11847. /** Gets or sets the current world position */
  11848. position: Vector3;
  11849. /** Gets or sets the main color */
  11850. color: Color4;
  11851. /** Gets or sets the width */
  11852. width: number;
  11853. /** Gets or sets the height */
  11854. height: number;
  11855. /** Gets or sets rotation angle */
  11856. angle: number;
  11857. /** Gets or sets the cell index in the sprite sheet */
  11858. cellIndex: number;
  11859. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11860. invertU: number;
  11861. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11862. invertV: number;
  11863. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11864. disposeWhenFinishedAnimating: boolean;
  11865. /** Gets the list of attached animations */
  11866. animations: Animation[];
  11867. /** Gets or sets a boolean indicating if the sprite can be picked */
  11868. isPickable: boolean;
  11869. /**
  11870. * Gets or sets the associated action manager
  11871. */
  11872. actionManager: Nullable<ActionManager>;
  11873. private _animationStarted;
  11874. private _loopAnimation;
  11875. private _fromIndex;
  11876. private _toIndex;
  11877. private _delay;
  11878. private _direction;
  11879. private _manager;
  11880. private _time;
  11881. private _onAnimationEnd;
  11882. /**
  11883. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11884. */
  11885. isVisible: boolean;
  11886. /**
  11887. * Gets or sets the sprite size
  11888. */
  11889. size: number;
  11890. /**
  11891. * Creates a new Sprite
  11892. * @param name defines the name
  11893. * @param manager defines the manager
  11894. */
  11895. constructor(
  11896. /** defines the name */
  11897. name: string, manager: ISpriteManager);
  11898. /**
  11899. * Starts an animation
  11900. * @param from defines the initial key
  11901. * @param to defines the end key
  11902. * @param loop defines if the animation must loop
  11903. * @param delay defines the start delay (in ms)
  11904. * @param onAnimationEnd defines a callback to call when animation ends
  11905. */
  11906. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11907. /** Stops current animation (if any) */
  11908. stopAnimation(): void;
  11909. /** @hidden */
  11910. _animate(deltaTime: number): void;
  11911. /** Release associated resources */
  11912. dispose(): void;
  11913. }
  11914. }
  11915. declare module "babylonjs/Collisions/pickingInfo" {
  11916. import { Nullable } from "babylonjs/types";
  11917. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11919. import { Sprite } from "babylonjs/Sprites/sprite";
  11920. import { Ray } from "babylonjs/Culling/ray";
  11921. /**
  11922. * Information about the result of picking within a scene
  11923. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11924. */
  11925. export class PickingInfo {
  11926. /** @hidden */
  11927. _pickingUnavailable: boolean;
  11928. /**
  11929. * If the pick collided with an object
  11930. */
  11931. hit: boolean;
  11932. /**
  11933. * Distance away where the pick collided
  11934. */
  11935. distance: number;
  11936. /**
  11937. * The location of pick collision
  11938. */
  11939. pickedPoint: Nullable<Vector3>;
  11940. /**
  11941. * The mesh corresponding the the pick collision
  11942. */
  11943. pickedMesh: Nullable<AbstractMesh>;
  11944. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11945. bu: number;
  11946. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11947. bv: number;
  11948. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11949. faceId: number;
  11950. /** Id of the the submesh that was picked */
  11951. subMeshId: number;
  11952. /** If a sprite was picked, this will be the sprite the pick collided with */
  11953. pickedSprite: Nullable<Sprite>;
  11954. /**
  11955. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11956. */
  11957. originMesh: Nullable<AbstractMesh>;
  11958. /**
  11959. * The ray that was used to perform the picking.
  11960. */
  11961. ray: Nullable<Ray>;
  11962. /**
  11963. * Gets the normal correspodning to the face the pick collided with
  11964. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11965. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11966. * @returns The normal correspodning to the face the pick collided with
  11967. */
  11968. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11969. /**
  11970. * Gets the texture coordinates of where the pick occured
  11971. * @returns the vector containing the coordnates of the texture
  11972. */
  11973. getTextureCoordinates(): Nullable<Vector2>;
  11974. }
  11975. }
  11976. declare module "babylonjs/Events/pointerEvents" {
  11977. import { Nullable } from "babylonjs/types";
  11978. import { Vector2 } from "babylonjs/Maths/math";
  11979. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11980. import { Ray } from "babylonjs/Culling/ray";
  11981. /**
  11982. * Gather the list of pointer event types as constants.
  11983. */
  11984. export class PointerEventTypes {
  11985. /**
  11986. * 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.
  11987. */
  11988. static readonly POINTERDOWN: number;
  11989. /**
  11990. * The pointerup event is fired when a pointer is no longer active.
  11991. */
  11992. static readonly POINTERUP: number;
  11993. /**
  11994. * The pointermove event is fired when a pointer changes coordinates.
  11995. */
  11996. static readonly POINTERMOVE: number;
  11997. /**
  11998. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11999. */
  12000. static readonly POINTERWHEEL: number;
  12001. /**
  12002. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12003. */
  12004. static readonly POINTERPICK: number;
  12005. /**
  12006. * The pointertap event is fired when a the object has been touched and released without drag.
  12007. */
  12008. static readonly POINTERTAP: number;
  12009. /**
  12010. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12011. */
  12012. static readonly POINTERDOUBLETAP: number;
  12013. }
  12014. /**
  12015. * Base class of pointer info types.
  12016. */
  12017. export class PointerInfoBase {
  12018. /**
  12019. * Defines the type of event (PointerEventTypes)
  12020. */
  12021. type: number;
  12022. /**
  12023. * Defines the related dom event
  12024. */
  12025. event: PointerEvent | MouseWheelEvent;
  12026. /**
  12027. * Instantiates the base class of pointers info.
  12028. * @param type Defines the type of event (PointerEventTypes)
  12029. * @param event Defines the related dom event
  12030. */
  12031. constructor(
  12032. /**
  12033. * Defines the type of event (PointerEventTypes)
  12034. */
  12035. type: number,
  12036. /**
  12037. * Defines the related dom event
  12038. */
  12039. event: PointerEvent | MouseWheelEvent);
  12040. }
  12041. /**
  12042. * This class is used to store pointer related info for the onPrePointerObservable event.
  12043. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12044. */
  12045. export class PointerInfoPre extends PointerInfoBase {
  12046. /**
  12047. * Ray from a pointer if availible (eg. 6dof controller)
  12048. */
  12049. ray: Nullable<Ray>;
  12050. /**
  12051. * Defines the local position of the pointer on the canvas.
  12052. */
  12053. localPosition: Vector2;
  12054. /**
  12055. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12056. */
  12057. skipOnPointerObservable: boolean;
  12058. /**
  12059. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12060. * @param type Defines the type of event (PointerEventTypes)
  12061. * @param event Defines the related dom event
  12062. * @param localX Defines the local x coordinates of the pointer when the event occured
  12063. * @param localY Defines the local y coordinates of the pointer when the event occured
  12064. */
  12065. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12066. }
  12067. /**
  12068. * This type contains all the data related to a pointer event in Babylon.js.
  12069. * 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.
  12070. */
  12071. export class PointerInfo extends PointerInfoBase {
  12072. /**
  12073. * Defines the picking info associated to the info (if any)\
  12074. */
  12075. pickInfo: Nullable<PickingInfo>;
  12076. /**
  12077. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12078. * @param type Defines the type of event (PointerEventTypes)
  12079. * @param event Defines the related dom event
  12080. * @param pickInfo Defines the picking info associated to the info (if any)\
  12081. */
  12082. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>);
  12087. }
  12088. /**
  12089. * Data relating to a touch event on the screen.
  12090. */
  12091. export interface PointerTouch {
  12092. /**
  12093. * X coordinate of touch.
  12094. */
  12095. x: number;
  12096. /**
  12097. * Y coordinate of touch.
  12098. */
  12099. y: number;
  12100. /**
  12101. * Id of touch. Unique for each finger.
  12102. */
  12103. pointerId: number;
  12104. /**
  12105. * Event type passed from DOM.
  12106. */
  12107. type: any;
  12108. }
  12109. }
  12110. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12111. import { Nullable } from "babylonjs/types";
  12112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12114. /**
  12115. * Manage the mouse inputs to control the movement of a free camera.
  12116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12117. */
  12118. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12119. /**
  12120. * Define if touch is enabled in the mouse input
  12121. */
  12122. touchEnabled: boolean;
  12123. /**
  12124. * Defines the camera the input is attached to.
  12125. */
  12126. camera: FreeCamera;
  12127. /**
  12128. * Defines the buttons associated with the input to handle camera move.
  12129. */
  12130. buttons: number[];
  12131. /**
  12132. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12133. */
  12134. angularSensibility: number;
  12135. private _pointerInput;
  12136. private _onMouseMove;
  12137. private _observer;
  12138. private previousPosition;
  12139. /**
  12140. * Manage the mouse inputs to control the movement of a free camera.
  12141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12142. * @param touchEnabled Defines if touch is enabled or not
  12143. */
  12144. constructor(
  12145. /**
  12146. * Define if touch is enabled in the mouse input
  12147. */
  12148. touchEnabled?: boolean);
  12149. /**
  12150. * Attach the input controls to a specific dom element to get the input from.
  12151. * @param element Defines the element the controls should be listened from
  12152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12153. */
  12154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12155. /**
  12156. * Called on JS contextmenu event.
  12157. * Override this method to provide functionality.
  12158. */
  12159. protected onContextMenu(evt: PointerEvent): void;
  12160. /**
  12161. * Detach the current controls from the specified dom element.
  12162. * @param element Defines the element to stop listening the inputs from
  12163. */
  12164. detachControl(element: Nullable<HTMLElement>): void;
  12165. /**
  12166. * Gets the class name of the current intput.
  12167. * @returns the class name
  12168. */
  12169. getClassName(): string;
  12170. /**
  12171. * Get the friendly name associated with the input class.
  12172. * @returns the input friendly name
  12173. */
  12174. getSimpleName(): string;
  12175. }
  12176. }
  12177. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12178. import { Nullable } from "babylonjs/types";
  12179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12180. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12181. /**
  12182. * Manage the touch inputs to control the movement of a free camera.
  12183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12184. */
  12185. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12186. /**
  12187. * Defines the camera the input is attached to.
  12188. */
  12189. camera: FreeCamera;
  12190. /**
  12191. * Defines the touch sensibility for rotation.
  12192. * The higher the faster.
  12193. */
  12194. touchAngularSensibility: number;
  12195. /**
  12196. * Defines the touch sensibility for move.
  12197. * The higher the faster.
  12198. */
  12199. touchMoveSensibility: number;
  12200. private _offsetX;
  12201. private _offsetY;
  12202. private _pointerPressed;
  12203. private _pointerInput;
  12204. private _observer;
  12205. private _onLostFocus;
  12206. /**
  12207. * Attach the input controls to a specific dom element to get the input from.
  12208. * @param element Defines the element the controls should be listened from
  12209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12210. */
  12211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12212. /**
  12213. * Detach the current controls from the specified dom element.
  12214. * @param element Defines the element to stop listening the inputs from
  12215. */
  12216. detachControl(element: Nullable<HTMLElement>): void;
  12217. /**
  12218. * Update the current camera state depending on the inputs that have been used this frame.
  12219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12220. */
  12221. checkInputs(): void;
  12222. /**
  12223. * Gets the class name of the current intput.
  12224. * @returns the class name
  12225. */
  12226. getClassName(): string;
  12227. /**
  12228. * Get the friendly name associated with the input class.
  12229. * @returns the input friendly name
  12230. */
  12231. getSimpleName(): string;
  12232. }
  12233. }
  12234. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12235. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12236. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12237. /**
  12238. * Default Inputs manager for the FreeCamera.
  12239. * It groups all the default supported inputs for ease of use.
  12240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12241. */
  12242. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12243. /**
  12244. * Instantiates a new FreeCameraInputsManager.
  12245. * @param camera Defines the camera the inputs belong to
  12246. */
  12247. constructor(camera: FreeCamera);
  12248. /**
  12249. * Add keyboard input support to the input manager.
  12250. * @returns the current input manager
  12251. */
  12252. addKeyboard(): FreeCameraInputsManager;
  12253. /**
  12254. * Add mouse input support to the input manager.
  12255. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12256. * @returns the current input manager
  12257. */
  12258. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12259. /**
  12260. * Add touch input support to the input manager.
  12261. * @returns the current input manager
  12262. */
  12263. addTouch(): FreeCameraInputsManager;
  12264. }
  12265. }
  12266. declare module "babylonjs/Cameras/freeCamera" {
  12267. import { Vector3 } from "babylonjs/Maths/math";
  12268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12269. import { Scene } from "babylonjs/scene";
  12270. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12271. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12272. /**
  12273. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12274. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12276. */
  12277. export class FreeCamera extends TargetCamera {
  12278. /**
  12279. * Define the collision ellipsoid of the camera.
  12280. * This is helpful to simulate a camera body like the player body around the camera
  12281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12282. */
  12283. ellipsoid: Vector3;
  12284. /**
  12285. * Define an offset for the position of the ellipsoid around the camera.
  12286. * This can be helpful to determine the center of the body near the gravity center of the body
  12287. * instead of its head.
  12288. */
  12289. ellipsoidOffset: Vector3;
  12290. /**
  12291. * Enable or disable collisions of the camera with the rest of the scene objects.
  12292. */
  12293. checkCollisions: boolean;
  12294. /**
  12295. * Enable or disable gravity on the camera.
  12296. */
  12297. applyGravity: boolean;
  12298. /**
  12299. * Define the input manager associated to the camera.
  12300. */
  12301. inputs: FreeCameraInputsManager;
  12302. /**
  12303. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12304. * Higher values reduce sensitivity.
  12305. */
  12306. /**
  12307. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12308. * Higher values reduce sensitivity.
  12309. */
  12310. angularSensibility: number;
  12311. /**
  12312. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12313. */
  12314. keysUp: number[];
  12315. /**
  12316. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12317. */
  12318. keysDown: number[];
  12319. /**
  12320. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12321. */
  12322. keysLeft: number[];
  12323. /**
  12324. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12325. */
  12326. keysRight: number[];
  12327. /**
  12328. * Event raised when the camera collide with a mesh in the scene.
  12329. */
  12330. onCollide: (collidedMesh: AbstractMesh) => void;
  12331. private _collider;
  12332. private _needMoveForGravity;
  12333. private _oldPosition;
  12334. private _diffPosition;
  12335. private _newPosition;
  12336. /** @hidden */
  12337. _localDirection: Vector3;
  12338. /** @hidden */
  12339. _transformedDirection: Vector3;
  12340. /**
  12341. * Instantiates a Free Camera.
  12342. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12343. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12344. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12345. * @param name Define the name of the camera in the scene
  12346. * @param position Define the start position of the camera in the scene
  12347. * @param scene Define the scene the camera belongs to
  12348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12349. */
  12350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12351. /**
  12352. * Attached controls to the current camera.
  12353. * @param element Defines the element the controls should be listened from
  12354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12355. */
  12356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12357. /**
  12358. * Detach the current controls from the camera.
  12359. * The camera will stop reacting to inputs.
  12360. * @param element Defines the element to stop listening the inputs from
  12361. */
  12362. detachControl(element: HTMLElement): void;
  12363. private _collisionMask;
  12364. /**
  12365. * Define a collision mask to limit the list of object the camera can collide with
  12366. */
  12367. collisionMask: number;
  12368. /** @hidden */
  12369. _collideWithWorld(displacement: Vector3): void;
  12370. private _onCollisionPositionChange;
  12371. /** @hidden */
  12372. _checkInputs(): void;
  12373. /** @hidden */
  12374. _decideIfNeedsToMove(): boolean;
  12375. /** @hidden */
  12376. _updatePosition(): void;
  12377. /**
  12378. * Destroy the camera and release the current resources hold by it.
  12379. */
  12380. dispose(): void;
  12381. /**
  12382. * Gets the current object class name.
  12383. * @return the class name
  12384. */
  12385. getClassName(): string;
  12386. }
  12387. }
  12388. declare module "babylonjs/Gamepads/gamepad" {
  12389. import { Observable } from "babylonjs/Misc/observable";
  12390. /**
  12391. * Represents a gamepad control stick position
  12392. */
  12393. export class StickValues {
  12394. /**
  12395. * The x component of the control stick
  12396. */
  12397. x: number;
  12398. /**
  12399. * The y component of the control stick
  12400. */
  12401. y: number;
  12402. /**
  12403. * Initializes the gamepad x and y control stick values
  12404. * @param x The x component of the gamepad control stick value
  12405. * @param y The y component of the gamepad control stick value
  12406. */
  12407. constructor(
  12408. /**
  12409. * The x component of the control stick
  12410. */
  12411. x: number,
  12412. /**
  12413. * The y component of the control stick
  12414. */
  12415. y: number);
  12416. }
  12417. /**
  12418. * An interface which manages callbacks for gamepad button changes
  12419. */
  12420. export interface GamepadButtonChanges {
  12421. /**
  12422. * Called when a gamepad has been changed
  12423. */
  12424. changed: boolean;
  12425. /**
  12426. * Called when a gamepad press event has been triggered
  12427. */
  12428. pressChanged: boolean;
  12429. /**
  12430. * Called when a touch event has been triggered
  12431. */
  12432. touchChanged: boolean;
  12433. /**
  12434. * Called when a value has changed
  12435. */
  12436. valueChanged: boolean;
  12437. }
  12438. /**
  12439. * Represents a gamepad
  12440. */
  12441. export class Gamepad {
  12442. /**
  12443. * The id of the gamepad
  12444. */
  12445. id: string;
  12446. /**
  12447. * The index of the gamepad
  12448. */
  12449. index: number;
  12450. /**
  12451. * The browser gamepad
  12452. */
  12453. browserGamepad: any;
  12454. /**
  12455. * Specifies what type of gamepad this represents
  12456. */
  12457. type: number;
  12458. private _leftStick;
  12459. private _rightStick;
  12460. /** @hidden */
  12461. _isConnected: boolean;
  12462. private _leftStickAxisX;
  12463. private _leftStickAxisY;
  12464. private _rightStickAxisX;
  12465. private _rightStickAxisY;
  12466. /**
  12467. * Triggered when the left control stick has been changed
  12468. */
  12469. private _onleftstickchanged;
  12470. /**
  12471. * Triggered when the right control stick has been changed
  12472. */
  12473. private _onrightstickchanged;
  12474. /**
  12475. * Represents a gamepad controller
  12476. */
  12477. static GAMEPAD: number;
  12478. /**
  12479. * Represents a generic controller
  12480. */
  12481. static GENERIC: number;
  12482. /**
  12483. * Represents an XBox controller
  12484. */
  12485. static XBOX: number;
  12486. /**
  12487. * Represents a pose-enabled controller
  12488. */
  12489. static POSE_ENABLED: number;
  12490. /**
  12491. * Specifies whether the left control stick should be Y-inverted
  12492. */
  12493. protected _invertLeftStickY: boolean;
  12494. /**
  12495. * Specifies if the gamepad has been connected
  12496. */
  12497. readonly isConnected: boolean;
  12498. /**
  12499. * Initializes the gamepad
  12500. * @param id The id of the gamepad
  12501. * @param index The index of the gamepad
  12502. * @param browserGamepad The browser gamepad
  12503. * @param leftStickX The x component of the left joystick
  12504. * @param leftStickY The y component of the left joystick
  12505. * @param rightStickX The x component of the right joystick
  12506. * @param rightStickY The y component of the right joystick
  12507. */
  12508. constructor(
  12509. /**
  12510. * The id of the gamepad
  12511. */
  12512. id: string,
  12513. /**
  12514. * The index of the gamepad
  12515. */
  12516. index: number,
  12517. /**
  12518. * The browser gamepad
  12519. */
  12520. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12521. /**
  12522. * Callback triggered when the left joystick has changed
  12523. * @param callback
  12524. */
  12525. onleftstickchanged(callback: (values: StickValues) => void): void;
  12526. /**
  12527. * Callback triggered when the right joystick has changed
  12528. * @param callback
  12529. */
  12530. onrightstickchanged(callback: (values: StickValues) => void): void;
  12531. /**
  12532. * Gets the left joystick
  12533. */
  12534. /**
  12535. * Sets the left joystick values
  12536. */
  12537. leftStick: StickValues;
  12538. /**
  12539. * Gets the right joystick
  12540. */
  12541. /**
  12542. * Sets the right joystick value
  12543. */
  12544. rightStick: StickValues;
  12545. /**
  12546. * Updates the gamepad joystick positions
  12547. */
  12548. update(): void;
  12549. /**
  12550. * Disposes the gamepad
  12551. */
  12552. dispose(): void;
  12553. }
  12554. /**
  12555. * Represents a generic gamepad
  12556. */
  12557. export class GenericPad extends Gamepad {
  12558. private _buttons;
  12559. private _onbuttondown;
  12560. private _onbuttonup;
  12561. /**
  12562. * Observable triggered when a button has been pressed
  12563. */
  12564. onButtonDownObservable: Observable<number>;
  12565. /**
  12566. * Observable triggered when a button has been released
  12567. */
  12568. onButtonUpObservable: Observable<number>;
  12569. /**
  12570. * Callback triggered when a button has been pressed
  12571. * @param callback Called when a button has been pressed
  12572. */
  12573. onbuttondown(callback: (buttonPressed: number) => void): void;
  12574. /**
  12575. * Callback triggered when a button has been released
  12576. * @param callback Called when a button has been released
  12577. */
  12578. onbuttonup(callback: (buttonReleased: number) => void): void;
  12579. /**
  12580. * Initializes the generic gamepad
  12581. * @param id The id of the generic gamepad
  12582. * @param index The index of the generic gamepad
  12583. * @param browserGamepad The browser gamepad
  12584. */
  12585. constructor(id: string, index: number, browserGamepad: any);
  12586. private _setButtonValue;
  12587. /**
  12588. * Updates the generic gamepad
  12589. */
  12590. update(): void;
  12591. /**
  12592. * Disposes the generic gamepad
  12593. */
  12594. dispose(): void;
  12595. }
  12596. }
  12597. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12598. import { Observable } from "babylonjs/Misc/observable";
  12599. import { Nullable } from "babylonjs/types";
  12600. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12603. import { Ray } from "babylonjs/Culling/ray";
  12604. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12605. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12606. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12607. /**
  12608. * Defines the types of pose enabled controllers that are supported
  12609. */
  12610. export enum PoseEnabledControllerType {
  12611. /**
  12612. * HTC Vive
  12613. */
  12614. VIVE = 0,
  12615. /**
  12616. * Oculus Rift
  12617. */
  12618. OCULUS = 1,
  12619. /**
  12620. * Windows mixed reality
  12621. */
  12622. WINDOWS = 2,
  12623. /**
  12624. * Samsung gear VR
  12625. */
  12626. GEAR_VR = 3,
  12627. /**
  12628. * Google Daydream
  12629. */
  12630. DAYDREAM = 4,
  12631. /**
  12632. * Generic
  12633. */
  12634. GENERIC = 5
  12635. }
  12636. /**
  12637. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12638. */
  12639. export interface MutableGamepadButton {
  12640. /**
  12641. * Value of the button/trigger
  12642. */
  12643. value: number;
  12644. /**
  12645. * If the button/trigger is currently touched
  12646. */
  12647. touched: boolean;
  12648. /**
  12649. * If the button/trigger is currently pressed
  12650. */
  12651. pressed: boolean;
  12652. }
  12653. /**
  12654. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12655. * @hidden
  12656. */
  12657. export interface ExtendedGamepadButton extends GamepadButton {
  12658. /**
  12659. * If the button/trigger is currently pressed
  12660. */
  12661. readonly pressed: boolean;
  12662. /**
  12663. * If the button/trigger is currently touched
  12664. */
  12665. readonly touched: boolean;
  12666. /**
  12667. * Value of the button/trigger
  12668. */
  12669. readonly value: number;
  12670. }
  12671. /** @hidden */
  12672. export interface _GamePadFactory {
  12673. /**
  12674. * Returns wether or not the current gamepad can be created for this type of controller.
  12675. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12676. * @returns true if it can be created, otherwise false
  12677. */
  12678. canCreate(gamepadInfo: any): boolean;
  12679. /**
  12680. * Creates a new instance of the Gamepad.
  12681. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12682. * @returns the new gamepad instance
  12683. */
  12684. create(gamepadInfo: any): Gamepad;
  12685. }
  12686. /**
  12687. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12688. */
  12689. export class PoseEnabledControllerHelper {
  12690. /** @hidden */
  12691. static _ControllerFactories: _GamePadFactory[];
  12692. /** @hidden */
  12693. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12694. /**
  12695. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12696. * @param vrGamepad the gamepad to initialized
  12697. * @returns a vr controller of the type the gamepad identified as
  12698. */
  12699. static InitiateController(vrGamepad: any): Gamepad;
  12700. }
  12701. /**
  12702. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12703. */
  12704. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12705. private _deviceRoomPosition;
  12706. private _deviceRoomRotationQuaternion;
  12707. /**
  12708. * The device position in babylon space
  12709. */
  12710. devicePosition: Vector3;
  12711. /**
  12712. * The device rotation in babylon space
  12713. */
  12714. deviceRotationQuaternion: Quaternion;
  12715. /**
  12716. * The scale factor of the device in babylon space
  12717. */
  12718. deviceScaleFactor: number;
  12719. /**
  12720. * (Likely devicePosition should be used instead) The device position in its room space
  12721. */
  12722. position: Vector3;
  12723. /**
  12724. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12725. */
  12726. rotationQuaternion: Quaternion;
  12727. /**
  12728. * The type of controller (Eg. Windows mixed reality)
  12729. */
  12730. controllerType: PoseEnabledControllerType;
  12731. protected _calculatedPosition: Vector3;
  12732. private _calculatedRotation;
  12733. /**
  12734. * The raw pose from the device
  12735. */
  12736. rawPose: DevicePose;
  12737. private _trackPosition;
  12738. private _maxRotationDistFromHeadset;
  12739. private _draggedRoomRotation;
  12740. /**
  12741. * @hidden
  12742. */
  12743. _disableTrackPosition(fixedPosition: Vector3): void;
  12744. /**
  12745. * Internal, the mesh attached to the controller
  12746. * @hidden
  12747. */
  12748. _mesh: Nullable<AbstractMesh>;
  12749. private _poseControlledCamera;
  12750. private _leftHandSystemQuaternion;
  12751. /**
  12752. * Internal, matrix used to convert room space to babylon space
  12753. * @hidden
  12754. */
  12755. _deviceToWorld: Matrix;
  12756. /**
  12757. * Node to be used when casting a ray from the controller
  12758. * @hidden
  12759. */
  12760. _pointingPoseNode: Nullable<TransformNode>;
  12761. /**
  12762. * Name of the child mesh that can be used to cast a ray from the controller
  12763. */
  12764. static readonly POINTING_POSE: string;
  12765. /**
  12766. * Creates a new PoseEnabledController from a gamepad
  12767. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12768. */
  12769. constructor(browserGamepad: any);
  12770. private _workingMatrix;
  12771. /**
  12772. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12773. */
  12774. update(): void;
  12775. /**
  12776. * Updates only the pose device and mesh without doing any button event checking
  12777. */
  12778. protected _updatePoseAndMesh(): void;
  12779. /**
  12780. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12781. * @param poseData raw pose fromthe device
  12782. */
  12783. updateFromDevice(poseData: DevicePose): void;
  12784. /**
  12785. * @hidden
  12786. */
  12787. _meshAttachedObservable: Observable<AbstractMesh>;
  12788. /**
  12789. * Attaches a mesh to the controller
  12790. * @param mesh the mesh to be attached
  12791. */
  12792. attachToMesh(mesh: AbstractMesh): void;
  12793. /**
  12794. * Attaches the controllers mesh to a camera
  12795. * @param camera the camera the mesh should be attached to
  12796. */
  12797. attachToPoseControlledCamera(camera: TargetCamera): void;
  12798. /**
  12799. * Disposes of the controller
  12800. */
  12801. dispose(): void;
  12802. /**
  12803. * The mesh that is attached to the controller
  12804. */
  12805. readonly mesh: Nullable<AbstractMesh>;
  12806. /**
  12807. * Gets the ray of the controller in the direction the controller is pointing
  12808. * @param length the length the resulting ray should be
  12809. * @returns a ray in the direction the controller is pointing
  12810. */
  12811. getForwardRay(length?: number): Ray;
  12812. }
  12813. }
  12814. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12815. import { Observable } from "babylonjs/Misc/observable";
  12816. import { Scene } from "babylonjs/scene";
  12817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12818. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12819. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12820. /**
  12821. * Defines the WebVRController object that represents controllers tracked in 3D space
  12822. */
  12823. export abstract class WebVRController extends PoseEnabledController {
  12824. /**
  12825. * Internal, the default controller model for the controller
  12826. */
  12827. protected _defaultModel: AbstractMesh;
  12828. /**
  12829. * Fired when the trigger state has changed
  12830. */
  12831. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12832. /**
  12833. * Fired when the main button state has changed
  12834. */
  12835. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12836. /**
  12837. * Fired when the secondary button state has changed
  12838. */
  12839. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12840. /**
  12841. * Fired when the pad state has changed
  12842. */
  12843. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12844. /**
  12845. * Fired when controllers stick values have changed
  12846. */
  12847. onPadValuesChangedObservable: Observable<StickValues>;
  12848. /**
  12849. * Array of button availible on the controller
  12850. */
  12851. protected _buttons: Array<MutableGamepadButton>;
  12852. private _onButtonStateChange;
  12853. /**
  12854. * Fired when a controller button's state has changed
  12855. * @param callback the callback containing the button that was modified
  12856. */
  12857. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12858. /**
  12859. * X and Y axis corrisponding to the controllers joystick
  12860. */
  12861. pad: StickValues;
  12862. /**
  12863. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12864. */
  12865. hand: string;
  12866. /**
  12867. * The default controller model for the controller
  12868. */
  12869. readonly defaultModel: AbstractMesh;
  12870. /**
  12871. * Creates a new WebVRController from a gamepad
  12872. * @param vrGamepad the gamepad that the WebVRController should be created from
  12873. */
  12874. constructor(vrGamepad: any);
  12875. /**
  12876. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12877. */
  12878. update(): void;
  12879. /**
  12880. * Function to be called when a button is modified
  12881. */
  12882. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12883. /**
  12884. * Loads a mesh and attaches it to the controller
  12885. * @param scene the scene the mesh should be added to
  12886. * @param meshLoaded callback for when the mesh has been loaded
  12887. */
  12888. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12889. private _setButtonValue;
  12890. private _changes;
  12891. private _checkChanges;
  12892. /**
  12893. * Disposes of th webVRCOntroller
  12894. */
  12895. dispose(): void;
  12896. }
  12897. }
  12898. declare module "babylonjs/Lights/hemisphericLight" {
  12899. import { Nullable } from "babylonjs/types";
  12900. import { Scene } from "babylonjs/scene";
  12901. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12902. import { Effect } from "babylonjs/Materials/effect";
  12903. import { Light } from "babylonjs/Lights/light";
  12904. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12905. /**
  12906. * The HemisphericLight simulates the ambient environment light,
  12907. * so the passed direction is the light reflection direction, not the incoming direction.
  12908. */
  12909. export class HemisphericLight extends Light {
  12910. /**
  12911. * The groundColor is the light in the opposite direction to the one specified during creation.
  12912. * 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.
  12913. */
  12914. groundColor: Color3;
  12915. /**
  12916. * The light reflection direction, not the incoming direction.
  12917. */
  12918. direction: Vector3;
  12919. /**
  12920. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12921. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12922. * The HemisphericLight can't cast shadows.
  12923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12924. * @param name The friendly name of the light
  12925. * @param direction The direction of the light reflection
  12926. * @param scene The scene the light belongs to
  12927. */
  12928. constructor(name: string, direction: Vector3, scene: Scene);
  12929. protected _buildUniformLayout(): void;
  12930. /**
  12931. * Returns the string "HemisphericLight".
  12932. * @return The class name
  12933. */
  12934. getClassName(): string;
  12935. /**
  12936. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12937. * Returns the updated direction.
  12938. * @param target The target the direction should point to
  12939. * @return The computed direction
  12940. */
  12941. setDirectionToTarget(target: Vector3): Vector3;
  12942. /**
  12943. * Returns the shadow generator associated to the light.
  12944. * @returns Always null for hemispheric lights because it does not support shadows.
  12945. */
  12946. getShadowGenerator(): Nullable<IShadowGenerator>;
  12947. /**
  12948. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12949. * @param effect The effect to update
  12950. * @param lightIndex The index of the light in the effect to update
  12951. * @returns The hemispheric light
  12952. */
  12953. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12954. /**
  12955. * Computes the world matrix of the node
  12956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12957. * @param useWasUpdatedFlag defines a reserved property
  12958. * @returns the world matrix
  12959. */
  12960. computeWorldMatrix(): Matrix;
  12961. /**
  12962. * Returns the integer 3.
  12963. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12964. */
  12965. getTypeID(): number;
  12966. /**
  12967. * Prepares the list of defines specific to the light type.
  12968. * @param defines the list of defines
  12969. * @param lightIndex defines the index of the light for the effect
  12970. */
  12971. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12972. }
  12973. }
  12974. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12975. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12976. import { Nullable } from "babylonjs/types";
  12977. import { Observable } from "babylonjs/Misc/observable";
  12978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12979. import { Scene } from "babylonjs/scene";
  12980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12981. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12982. import { Node } from "babylonjs/node";
  12983. import { Ray } from "babylonjs/Culling/ray";
  12984. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12985. /**
  12986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12987. * IMPORTANT!! The data is right-hand data.
  12988. * @export
  12989. * @interface DevicePose
  12990. */
  12991. export interface DevicePose {
  12992. /**
  12993. * The position of the device, values in array are [x,y,z].
  12994. */
  12995. readonly position: Nullable<Float32Array>;
  12996. /**
  12997. * The linearVelocity of the device, values in array are [x,y,z].
  12998. */
  12999. readonly linearVelocity: Nullable<Float32Array>;
  13000. /**
  13001. * The linearAcceleration of the device, values in array are [x,y,z].
  13002. */
  13003. readonly linearAcceleration: Nullable<Float32Array>;
  13004. /**
  13005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13006. */
  13007. readonly orientation: Nullable<Float32Array>;
  13008. /**
  13009. * The angularVelocity of the device, values in array are [x,y,z].
  13010. */
  13011. readonly angularVelocity: Nullable<Float32Array>;
  13012. /**
  13013. * The angularAcceleration of the device, values in array are [x,y,z].
  13014. */
  13015. readonly angularAcceleration: Nullable<Float32Array>;
  13016. }
  13017. /**
  13018. * Interface representing a pose controlled object in Babylon.
  13019. * A pose controlled object has both regular pose values as well as pose values
  13020. * from an external device such as a VR head mounted display
  13021. */
  13022. export interface PoseControlled {
  13023. /**
  13024. * The position of the object in babylon space.
  13025. */
  13026. position: Vector3;
  13027. /**
  13028. * The rotation quaternion of the object in babylon space.
  13029. */
  13030. rotationQuaternion: Quaternion;
  13031. /**
  13032. * The position of the device in babylon space.
  13033. */
  13034. devicePosition?: Vector3;
  13035. /**
  13036. * The rotation quaternion of the device in babylon space.
  13037. */
  13038. deviceRotationQuaternion: Quaternion;
  13039. /**
  13040. * The raw pose coming from the device.
  13041. */
  13042. rawPose: Nullable<DevicePose>;
  13043. /**
  13044. * The scale of the device to be used when translating from device space to babylon space.
  13045. */
  13046. deviceScaleFactor: number;
  13047. /**
  13048. * Updates the poseControlled values based on the input device pose.
  13049. * @param poseData the pose data to update the object with
  13050. */
  13051. updateFromDevice(poseData: DevicePose): void;
  13052. }
  13053. /**
  13054. * Set of options to customize the webVRCamera
  13055. */
  13056. export interface WebVROptions {
  13057. /**
  13058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13059. */
  13060. trackPosition?: boolean;
  13061. /**
  13062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13063. */
  13064. positionScale?: number;
  13065. /**
  13066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13067. */
  13068. displayName?: string;
  13069. /**
  13070. * Should the native controller meshes be initialized. (default: true)
  13071. */
  13072. controllerMeshes?: boolean;
  13073. /**
  13074. * Creating a default HemiLight only on controllers. (default: true)
  13075. */
  13076. defaultLightingOnControllers?: boolean;
  13077. /**
  13078. * If you don't want to use the default VR button of the helper. (default: false)
  13079. */
  13080. useCustomVRButton?: boolean;
  13081. /**
  13082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13083. */
  13084. customVRButton?: HTMLButtonElement;
  13085. /**
  13086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13087. */
  13088. rayLength?: number;
  13089. /**
  13090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13091. */
  13092. defaultHeight?: number;
  13093. }
  13094. /**
  13095. * This represents a WebVR camera.
  13096. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13097. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13098. */
  13099. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13100. private webVROptions;
  13101. /**
  13102. * @hidden
  13103. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13104. */
  13105. _vrDevice: any;
  13106. /**
  13107. * The rawPose of the vrDevice.
  13108. */
  13109. rawPose: Nullable<DevicePose>;
  13110. private _onVREnabled;
  13111. private _specsVersion;
  13112. private _attached;
  13113. private _frameData;
  13114. protected _descendants: Array<Node>;
  13115. private _deviceRoomPosition;
  13116. /** @hidden */
  13117. _deviceRoomRotationQuaternion: Quaternion;
  13118. private _standingMatrix;
  13119. /**
  13120. * Represents device position in babylon space.
  13121. */
  13122. devicePosition: Vector3;
  13123. /**
  13124. * Represents device rotation in babylon space.
  13125. */
  13126. deviceRotationQuaternion: Quaternion;
  13127. /**
  13128. * The scale of the device to be used when translating from device space to babylon space.
  13129. */
  13130. deviceScaleFactor: number;
  13131. private _deviceToWorld;
  13132. private _worldToDevice;
  13133. /**
  13134. * References to the webVR controllers for the vrDevice.
  13135. */
  13136. controllers: Array<WebVRController>;
  13137. /**
  13138. * Emits an event when a controller is attached.
  13139. */
  13140. onControllersAttachedObservable: Observable<WebVRController[]>;
  13141. /**
  13142. * Emits an event when a controller's mesh has been loaded;
  13143. */
  13144. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13145. /**
  13146. * Emits an event when the HMD's pose has been updated.
  13147. */
  13148. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13149. private _poseSet;
  13150. /**
  13151. * If the rig cameras be used as parent instead of this camera.
  13152. */
  13153. rigParenting: boolean;
  13154. private _lightOnControllers;
  13155. private _defaultHeight?;
  13156. /**
  13157. * Instantiates a WebVRFreeCamera.
  13158. * @param name The name of the WebVRFreeCamera
  13159. * @param position The starting anchor position for the camera
  13160. * @param scene The scene the camera belongs to
  13161. * @param webVROptions a set of customizable options for the webVRCamera
  13162. */
  13163. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13164. /**
  13165. * Gets the device distance from the ground in meters.
  13166. * @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.
  13167. */
  13168. deviceDistanceToRoomGround(): number;
  13169. /**
  13170. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13171. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13172. */
  13173. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13174. /**
  13175. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13176. * @returns A promise with a boolean set to if the standing matrix is supported.
  13177. */
  13178. useStandingMatrixAsync(): Promise<boolean>;
  13179. /**
  13180. * Disposes the camera
  13181. */
  13182. dispose(): void;
  13183. /**
  13184. * Gets a vrController by name.
  13185. * @param name The name of the controller to retreive
  13186. * @returns the controller matching the name specified or null if not found
  13187. */
  13188. getControllerByName(name: string): Nullable<WebVRController>;
  13189. private _leftController;
  13190. /**
  13191. * The controller corrisponding to the users left hand.
  13192. */
  13193. readonly leftController: Nullable<WebVRController>;
  13194. private _rightController;
  13195. /**
  13196. * The controller corrisponding to the users right hand.
  13197. */
  13198. readonly rightController: Nullable<WebVRController>;
  13199. /**
  13200. * Casts a ray forward from the vrCamera's gaze.
  13201. * @param length Length of the ray (default: 100)
  13202. * @returns the ray corrisponding to the gaze
  13203. */
  13204. getForwardRay(length?: number): Ray;
  13205. /**
  13206. * @hidden
  13207. * Updates the camera based on device's frame data
  13208. */
  13209. _checkInputs(): void;
  13210. /**
  13211. * Updates the poseControlled values based on the input device pose.
  13212. * @param poseData Pose coming from the device
  13213. */
  13214. updateFromDevice(poseData: DevicePose): void;
  13215. private _htmlElementAttached;
  13216. private _detachIfAttached;
  13217. /**
  13218. * WebVR's attach control will start broadcasting frames to the device.
  13219. * Note that in certain browsers (chrome for example) this function must be called
  13220. * within a user-interaction callback. Example:
  13221. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13222. *
  13223. * @param element html element to attach the vrDevice to
  13224. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13225. */
  13226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13227. /**
  13228. * Detaches the camera from the html element and disables VR
  13229. *
  13230. * @param element html element to detach from
  13231. */
  13232. detachControl(element: HTMLElement): void;
  13233. /**
  13234. * @returns the name of this class
  13235. */
  13236. getClassName(): string;
  13237. /**
  13238. * Calls resetPose on the vrDisplay
  13239. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13240. */
  13241. resetToCurrentRotation(): void;
  13242. /**
  13243. * @hidden
  13244. * Updates the rig cameras (left and right eye)
  13245. */
  13246. _updateRigCameras(): void;
  13247. private _workingVector;
  13248. private _oneVector;
  13249. private _workingMatrix;
  13250. private updateCacheCalled;
  13251. private _correctPositionIfNotTrackPosition;
  13252. /**
  13253. * @hidden
  13254. * Updates the cached values of the camera
  13255. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13256. */
  13257. _updateCache(ignoreParentClass?: boolean): void;
  13258. /**
  13259. * @hidden
  13260. * Get current device position in babylon world
  13261. */
  13262. _computeDevicePosition(): void;
  13263. /**
  13264. * Updates the current device position and rotation in the babylon world
  13265. */
  13266. update(): void;
  13267. /**
  13268. * @hidden
  13269. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13270. * @returns an identity matrix
  13271. */
  13272. _getViewMatrix(): Matrix;
  13273. private _tmpMatrix;
  13274. /**
  13275. * This function is called by the two RIG cameras.
  13276. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13277. * @hidden
  13278. */
  13279. _getWebVRViewMatrix(): Matrix;
  13280. /** @hidden */
  13281. _getWebVRProjectionMatrix(): Matrix;
  13282. private _onGamepadConnectedObserver;
  13283. private _onGamepadDisconnectedObserver;
  13284. private _updateCacheWhenTrackingDisabledObserver;
  13285. /**
  13286. * Initializes the controllers and their meshes
  13287. */
  13288. initControllers(): void;
  13289. }
  13290. }
  13291. declare module "babylonjs/PostProcesses/postProcess" {
  13292. import { Nullable } from "babylonjs/types";
  13293. import { SmartArray } from "babylonjs/Misc/smartArray";
  13294. import { Observable } from "babylonjs/Misc/observable";
  13295. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13296. import { Camera } from "babylonjs/Cameras/camera";
  13297. import { Effect } from "babylonjs/Materials/effect";
  13298. import "babylonjs/Shaders/postprocess.vertex";
  13299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13300. import { Engine } from "babylonjs/Engines/engine";
  13301. /**
  13302. * Size options for a post process
  13303. */
  13304. export type PostProcessOptions = {
  13305. width: number;
  13306. height: number;
  13307. };
  13308. /**
  13309. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13310. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13311. */
  13312. export class PostProcess {
  13313. /** Name of the PostProcess. */
  13314. name: string;
  13315. /**
  13316. * Gets or sets the unique id of the post process
  13317. */
  13318. uniqueId: number;
  13319. /**
  13320. * Width of the texture to apply the post process on
  13321. */
  13322. width: number;
  13323. /**
  13324. * Height of the texture to apply the post process on
  13325. */
  13326. height: number;
  13327. /**
  13328. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13329. * @hidden
  13330. */
  13331. _outputTexture: Nullable<InternalTexture>;
  13332. /**
  13333. * Sampling mode used by the shader
  13334. * See https://doc.babylonjs.com/classes/3.1/texture
  13335. */
  13336. renderTargetSamplingMode: number;
  13337. /**
  13338. * Clear color to use when screen clearing
  13339. */
  13340. clearColor: Color4;
  13341. /**
  13342. * If the buffer needs to be cleared before applying the post process. (default: true)
  13343. * Should be set to false if shader will overwrite all previous pixels.
  13344. */
  13345. autoClear: boolean;
  13346. /**
  13347. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13348. */
  13349. alphaMode: number;
  13350. /**
  13351. * Sets the setAlphaBlendConstants of the babylon engine
  13352. */
  13353. alphaConstants: Color4;
  13354. /**
  13355. * Animations to be used for the post processing
  13356. */
  13357. animations: import("babylonjs/Animations/animation").Animation[];
  13358. /**
  13359. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13360. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13361. */
  13362. enablePixelPerfectMode: boolean;
  13363. /**
  13364. * Force the postprocess to be applied without taking in account viewport
  13365. */
  13366. forceFullscreenViewport: boolean;
  13367. /**
  13368. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13369. *
  13370. * | Value | Type | Description |
  13371. * | ----- | ----------------------------------- | ----------- |
  13372. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13373. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13374. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13375. *
  13376. */
  13377. scaleMode: number;
  13378. /**
  13379. * Force textures to be a power of two (default: false)
  13380. */
  13381. alwaysForcePOT: boolean;
  13382. private _samples;
  13383. /**
  13384. * Number of sample textures (default: 1)
  13385. */
  13386. samples: number;
  13387. /**
  13388. * Modify the scale of the post process to be the same as the viewport (default: false)
  13389. */
  13390. adaptScaleToCurrentViewport: boolean;
  13391. private _camera;
  13392. private _scene;
  13393. private _engine;
  13394. private _options;
  13395. private _reusable;
  13396. private _textureType;
  13397. /**
  13398. * Smart array of input and output textures for the post process.
  13399. * @hidden
  13400. */
  13401. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13402. /**
  13403. * The index in _textures that corresponds to the output texture.
  13404. * @hidden
  13405. */
  13406. _currentRenderTextureInd: number;
  13407. private _effect;
  13408. private _samplers;
  13409. private _fragmentUrl;
  13410. private _vertexUrl;
  13411. private _parameters;
  13412. private _scaleRatio;
  13413. protected _indexParameters: any;
  13414. private _shareOutputWithPostProcess;
  13415. private _texelSize;
  13416. private _forcedOutputTexture;
  13417. /**
  13418. * Returns the fragment url or shader name used in the post process.
  13419. * @returns the fragment url or name in the shader store.
  13420. */
  13421. getEffectName(): string;
  13422. /**
  13423. * An event triggered when the postprocess is activated.
  13424. */
  13425. onActivateObservable: Observable<Camera>;
  13426. private _onActivateObserver;
  13427. /**
  13428. * A function that is added to the onActivateObservable
  13429. */
  13430. onActivate: Nullable<(camera: Camera) => void>;
  13431. /**
  13432. * An event triggered when the postprocess changes its size.
  13433. */
  13434. onSizeChangedObservable: Observable<PostProcess>;
  13435. private _onSizeChangedObserver;
  13436. /**
  13437. * A function that is added to the onSizeChangedObservable
  13438. */
  13439. onSizeChanged: (postProcess: PostProcess) => void;
  13440. /**
  13441. * An event triggered when the postprocess applies its effect.
  13442. */
  13443. onApplyObservable: Observable<Effect>;
  13444. private _onApplyObserver;
  13445. /**
  13446. * A function that is added to the onApplyObservable
  13447. */
  13448. onApply: (effect: Effect) => void;
  13449. /**
  13450. * An event triggered before rendering the postprocess
  13451. */
  13452. onBeforeRenderObservable: Observable<Effect>;
  13453. private _onBeforeRenderObserver;
  13454. /**
  13455. * A function that is added to the onBeforeRenderObservable
  13456. */
  13457. onBeforeRender: (effect: Effect) => void;
  13458. /**
  13459. * An event triggered after rendering the postprocess
  13460. */
  13461. onAfterRenderObservable: Observable<Effect>;
  13462. private _onAfterRenderObserver;
  13463. /**
  13464. * A function that is added to the onAfterRenderObservable
  13465. */
  13466. onAfterRender: (efect: Effect) => void;
  13467. /**
  13468. * 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
  13469. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13470. */
  13471. inputTexture: InternalTexture;
  13472. /**
  13473. * Gets the camera which post process is applied to.
  13474. * @returns The camera the post process is applied to.
  13475. */
  13476. getCamera(): Camera;
  13477. /**
  13478. * Gets the texel size of the postprocess.
  13479. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13480. */
  13481. readonly texelSize: Vector2;
  13482. /**
  13483. * Creates a new instance PostProcess
  13484. * @param name The name of the PostProcess.
  13485. * @param fragmentUrl The url of the fragment shader to be used.
  13486. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13487. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13488. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13489. * @param camera The camera to apply the render pass to.
  13490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13491. * @param engine The engine which the post process will be applied. (default: current engine)
  13492. * @param reusable If the post process can be reused on the same frame. (default: false)
  13493. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13494. * @param textureType Type of textures used when performing the post process. (default: 0)
  13495. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13496. * @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
  13497. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13498. */
  13499. constructor(
  13500. /** Name of the PostProcess. */
  13501. 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);
  13502. /**
  13503. * Gets a string idenfifying the name of the class
  13504. * @returns "PostProcess" string
  13505. */
  13506. getClassName(): string;
  13507. /**
  13508. * Gets the engine which this post process belongs to.
  13509. * @returns The engine the post process was enabled with.
  13510. */
  13511. getEngine(): Engine;
  13512. /**
  13513. * The effect that is created when initializing the post process.
  13514. * @returns The created effect corrisponding the the postprocess.
  13515. */
  13516. getEffect(): Effect;
  13517. /**
  13518. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13519. * @param postProcess The post process to share the output with.
  13520. * @returns This post process.
  13521. */
  13522. shareOutputWith(postProcess: PostProcess): PostProcess;
  13523. /**
  13524. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13525. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13526. */
  13527. useOwnOutput(): void;
  13528. /**
  13529. * Updates the effect with the current post process compile time values and recompiles the shader.
  13530. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13531. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13532. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13533. * @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
  13534. * @param onCompiled Called when the shader has been compiled.
  13535. * @param onError Called if there is an error when compiling a shader.
  13536. */
  13537. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13538. /**
  13539. * The post process is reusable if it can be used multiple times within one frame.
  13540. * @returns If the post process is reusable
  13541. */
  13542. isReusable(): boolean;
  13543. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13544. markTextureDirty(): void;
  13545. /**
  13546. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13547. * 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.
  13548. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13549. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13550. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13551. * @returns The target texture that was bound to be written to.
  13552. */
  13553. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13554. /**
  13555. * If the post process is supported.
  13556. */
  13557. readonly isSupported: boolean;
  13558. /**
  13559. * The aspect ratio of the output texture.
  13560. */
  13561. readonly aspectRatio: number;
  13562. /**
  13563. * Get a value indicating if the post-process is ready to be used
  13564. * @returns true if the post-process is ready (shader is compiled)
  13565. */
  13566. isReady(): boolean;
  13567. /**
  13568. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13569. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13570. */
  13571. apply(): Nullable<Effect>;
  13572. private _disposeTextures;
  13573. /**
  13574. * Disposes the post process.
  13575. * @param camera The camera to dispose the post process on.
  13576. */
  13577. dispose(camera?: Camera): void;
  13578. }
  13579. }
  13580. declare module "babylonjs/PostProcesses/postProcessManager" {
  13581. import { Nullable } from "babylonjs/types";
  13582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13584. import { Scene } from "babylonjs/scene";
  13585. /**
  13586. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13587. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13588. */
  13589. export class PostProcessManager {
  13590. private _scene;
  13591. private _indexBuffer;
  13592. private _vertexBuffers;
  13593. /**
  13594. * Creates a new instance PostProcess
  13595. * @param scene The scene that the post process is associated with.
  13596. */
  13597. constructor(scene: Scene);
  13598. private _prepareBuffers;
  13599. private _buildIndexBuffer;
  13600. /**
  13601. * Rebuilds the vertex buffers of the manager.
  13602. * @hidden
  13603. */
  13604. _rebuild(): void;
  13605. /**
  13606. * Prepares a frame to be run through a post process.
  13607. * @param sourceTexture The input texture to the post procesess. (default: null)
  13608. * @param postProcesses An array of post processes to be run. (default: null)
  13609. * @returns True if the post processes were able to be run.
  13610. * @hidden
  13611. */
  13612. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13613. /**
  13614. * Manually render a set of post processes to a texture.
  13615. * @param postProcesses An array of post processes to be run.
  13616. * @param targetTexture The target texture to render to.
  13617. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13618. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13619. * @param lodLevel defines which lod of the texture to render to
  13620. */
  13621. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13622. /**
  13623. * Finalize the result of the output of the postprocesses.
  13624. * @param doNotPresent If true the result will not be displayed to the screen.
  13625. * @param targetTexture The target texture to render to.
  13626. * @param faceIndex The index of the face to bind the target texture to.
  13627. * @param postProcesses The array of post processes to render.
  13628. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13629. * @hidden
  13630. */
  13631. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13632. /**
  13633. * Disposes of the post process manager.
  13634. */
  13635. dispose(): void;
  13636. }
  13637. }
  13638. declare module "babylonjs/Layers/layerSceneComponent" {
  13639. import { Scene } from "babylonjs/scene";
  13640. import { ISceneComponent } from "babylonjs/sceneComponent";
  13641. import { Layer } from "babylonjs/Layers/layer";
  13642. module "babylonjs/abstractScene" {
  13643. interface AbstractScene {
  13644. /**
  13645. * The list of layers (background and foreground) of the scene
  13646. */
  13647. layers: Array<Layer>;
  13648. }
  13649. }
  13650. /**
  13651. * Defines the layer scene component responsible to manage any layers
  13652. * in a given scene.
  13653. */
  13654. export class LayerSceneComponent implements ISceneComponent {
  13655. /**
  13656. * The component name helpfull to identify the component in the list of scene components.
  13657. */
  13658. readonly name: string;
  13659. /**
  13660. * The scene the component belongs to.
  13661. */
  13662. scene: Scene;
  13663. private _engine;
  13664. /**
  13665. * Creates a new instance of the component for the given scene
  13666. * @param scene Defines the scene to register the component in
  13667. */
  13668. constructor(scene: Scene);
  13669. /**
  13670. * Registers the component in a given scene
  13671. */
  13672. register(): void;
  13673. /**
  13674. * Rebuilds the elements related to this component in case of
  13675. * context lost for instance.
  13676. */
  13677. rebuild(): void;
  13678. /**
  13679. * Disposes the component and the associated ressources.
  13680. */
  13681. dispose(): void;
  13682. private _draw;
  13683. private _drawCameraPredicate;
  13684. private _drawCameraBackground;
  13685. private _drawCameraForeground;
  13686. private _drawRenderTargetPredicate;
  13687. private _drawRenderTargetBackground;
  13688. private _drawRenderTargetForeground;
  13689. }
  13690. }
  13691. declare module "babylonjs/Shaders/layer.fragment" {
  13692. /** @hidden */
  13693. export var layerPixelShader: {
  13694. name: string;
  13695. shader: string;
  13696. };
  13697. }
  13698. declare module "babylonjs/Shaders/layer.vertex" {
  13699. /** @hidden */
  13700. export var layerVertexShader: {
  13701. name: string;
  13702. shader: string;
  13703. };
  13704. }
  13705. declare module "babylonjs/Layers/layer" {
  13706. import { Observable } from "babylonjs/Misc/observable";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { Scene } from "babylonjs/scene";
  13709. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13710. import { Texture } from "babylonjs/Materials/Textures/texture";
  13711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13712. import "babylonjs/Shaders/layer.fragment";
  13713. import "babylonjs/Shaders/layer.vertex";
  13714. /**
  13715. * This represents a full screen 2d layer.
  13716. * This can be useful to display a picture in the background of your scene for instance.
  13717. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13718. */
  13719. export class Layer {
  13720. /**
  13721. * Define the name of the layer.
  13722. */
  13723. name: string;
  13724. /**
  13725. * Define the texture the layer should display.
  13726. */
  13727. texture: Nullable<Texture>;
  13728. /**
  13729. * Is the layer in background or foreground.
  13730. */
  13731. isBackground: boolean;
  13732. /**
  13733. * Define the color of the layer (instead of texture).
  13734. */
  13735. color: Color4;
  13736. /**
  13737. * Define the scale of the layer in order to zoom in out of the texture.
  13738. */
  13739. scale: Vector2;
  13740. /**
  13741. * Define an offset for the layer in order to shift the texture.
  13742. */
  13743. offset: Vector2;
  13744. /**
  13745. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13746. */
  13747. alphaBlendingMode: number;
  13748. /**
  13749. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13750. * Alpha test will not mix with the background color in case of transparency.
  13751. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13752. */
  13753. alphaTest: boolean;
  13754. /**
  13755. * Define a mask to restrict the layer to only some of the scene cameras.
  13756. */
  13757. layerMask: number;
  13758. /**
  13759. * Define the list of render target the layer is visible into.
  13760. */
  13761. renderTargetTextures: RenderTargetTexture[];
  13762. /**
  13763. * Define if the layer is only used in renderTarget or if it also
  13764. * renders in the main frame buffer of the canvas.
  13765. */
  13766. renderOnlyInRenderTargetTextures: boolean;
  13767. private _scene;
  13768. private _vertexBuffers;
  13769. private _indexBuffer;
  13770. private _effect;
  13771. private _alphaTestEffect;
  13772. /**
  13773. * An event triggered when the layer is disposed.
  13774. */
  13775. onDisposeObservable: Observable<Layer>;
  13776. private _onDisposeObserver;
  13777. /**
  13778. * Back compatibility with callback before the onDisposeObservable existed.
  13779. * The set callback will be triggered when the layer has been disposed.
  13780. */
  13781. onDispose: () => void;
  13782. /**
  13783. * An event triggered before rendering the scene
  13784. */
  13785. onBeforeRenderObservable: Observable<Layer>;
  13786. private _onBeforeRenderObserver;
  13787. /**
  13788. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13789. * The set callback will be triggered just before rendering the layer.
  13790. */
  13791. onBeforeRender: () => void;
  13792. /**
  13793. * An event triggered after rendering the scene
  13794. */
  13795. onAfterRenderObservable: Observable<Layer>;
  13796. private _onAfterRenderObserver;
  13797. /**
  13798. * Back compatibility with callback before the onAfterRenderObservable existed.
  13799. * The set callback will be triggered just after rendering the layer.
  13800. */
  13801. onAfterRender: () => void;
  13802. /**
  13803. * Instantiates a new layer.
  13804. * This represents a full screen 2d layer.
  13805. * This can be useful to display a picture in the background of your scene for instance.
  13806. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13807. * @param name Define the name of the layer in the scene
  13808. * @param imgUrl Define the url of the texture to display in the layer
  13809. * @param scene Define the scene the layer belongs to
  13810. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13811. * @param color Defines a color for the layer
  13812. */
  13813. constructor(
  13814. /**
  13815. * Define the name of the layer.
  13816. */
  13817. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13818. private _createIndexBuffer;
  13819. /** @hidden */
  13820. _rebuild(): void;
  13821. /**
  13822. * Renders the layer in the scene.
  13823. */
  13824. render(): void;
  13825. /**
  13826. * Disposes and releases the associated ressources.
  13827. */
  13828. dispose(): void;
  13829. }
  13830. }
  13831. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13832. import { Scene } from "babylonjs/scene";
  13833. import { ISceneComponent } from "babylonjs/sceneComponent";
  13834. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13835. module "babylonjs/abstractScene" {
  13836. interface AbstractScene {
  13837. /**
  13838. * The list of procedural textures added to the scene
  13839. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13840. */
  13841. proceduralTextures: Array<ProceduralTexture>;
  13842. }
  13843. }
  13844. /**
  13845. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13846. * in a given scene.
  13847. */
  13848. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13849. /**
  13850. * The component name helpfull to identify the component in the list of scene components.
  13851. */
  13852. readonly name: string;
  13853. /**
  13854. * The scene the component belongs to.
  13855. */
  13856. scene: Scene;
  13857. /**
  13858. * Creates a new instance of the component for the given scene
  13859. * @param scene Defines the scene to register the component in
  13860. */
  13861. constructor(scene: Scene);
  13862. /**
  13863. * Registers the component in a given scene
  13864. */
  13865. register(): void;
  13866. /**
  13867. * Rebuilds the elements related to this component in case of
  13868. * context lost for instance.
  13869. */
  13870. rebuild(): void;
  13871. /**
  13872. * Disposes the component and the associated ressources.
  13873. */
  13874. dispose(): void;
  13875. private _beforeClear;
  13876. }
  13877. }
  13878. declare module "babylonjs/Shaders/procedural.vertex" {
  13879. /** @hidden */
  13880. export var proceduralVertexShader: {
  13881. name: string;
  13882. shader: string;
  13883. };
  13884. }
  13885. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13886. import { Observable } from "babylonjs/Misc/observable";
  13887. import { Nullable } from "babylonjs/types";
  13888. import { Scene } from "babylonjs/scene";
  13889. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13890. import { Effect } from "babylonjs/Materials/effect";
  13891. import { Texture } from "babylonjs/Materials/Textures/texture";
  13892. import "babylonjs/Shaders/procedural.vertex";
  13893. /**
  13894. * 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.
  13895. * This is the base class of any Procedural texture and contains most of the shareable code.
  13896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13897. */
  13898. export class ProceduralTexture extends Texture {
  13899. isCube: boolean;
  13900. /**
  13901. * Define if the texture is enabled or not (disabled texture will not render)
  13902. */
  13903. isEnabled: boolean;
  13904. /**
  13905. * Define if the texture must be cleared before rendering (default is true)
  13906. */
  13907. autoClear: boolean;
  13908. /**
  13909. * Callback called when the texture is generated
  13910. */
  13911. onGenerated: () => void;
  13912. /**
  13913. * Event raised when the texture is generated
  13914. */
  13915. onGeneratedObservable: Observable<ProceduralTexture>;
  13916. /** @hidden */
  13917. _generateMipMaps: boolean;
  13918. /** @hidden **/
  13919. _effect: Effect;
  13920. /** @hidden */
  13921. _textures: {
  13922. [key: string]: Texture;
  13923. };
  13924. private _size;
  13925. private _currentRefreshId;
  13926. private _refreshRate;
  13927. private _vertexBuffers;
  13928. private _indexBuffer;
  13929. private _uniforms;
  13930. private _samplers;
  13931. private _fragment;
  13932. private _floats;
  13933. private _ints;
  13934. private _floatsArrays;
  13935. private _colors3;
  13936. private _colors4;
  13937. private _vectors2;
  13938. private _vectors3;
  13939. private _matrices;
  13940. private _fallbackTexture;
  13941. private _fallbackTextureUsed;
  13942. private _engine;
  13943. private _cachedDefines;
  13944. private _contentUpdateId;
  13945. private _contentData;
  13946. /**
  13947. * Instantiates a new procedural texture.
  13948. * 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.
  13949. * This is the base class of any Procedural texture and contains most of the shareable code.
  13950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13951. * @param name Define the name of the texture
  13952. * @param size Define the size of the texture to create
  13953. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13954. * @param scene Define the scene the texture belongs to
  13955. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13956. * @param generateMipMaps Define if the texture should creates mip maps or not
  13957. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13958. */
  13959. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13960. /**
  13961. * The effect that is created when initializing the post process.
  13962. * @returns The created effect corrisponding the the postprocess.
  13963. */
  13964. getEffect(): Effect;
  13965. /**
  13966. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13967. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13968. */
  13969. getContent(): Nullable<ArrayBufferView>;
  13970. private _createIndexBuffer;
  13971. /** @hidden */
  13972. _rebuild(): void;
  13973. /**
  13974. * Resets the texture in order to recreate its associated resources.
  13975. * This can be called in case of context loss
  13976. */
  13977. reset(): void;
  13978. protected _getDefines(): string;
  13979. /**
  13980. * Is the texture ready to be used ? (rendered at least once)
  13981. * @returns true if ready, otherwise, false.
  13982. */
  13983. isReady(): boolean;
  13984. /**
  13985. * Resets the refresh counter of the texture and start bak from scratch.
  13986. * Could be useful to regenerate the texture if it is setup to render only once.
  13987. */
  13988. resetRefreshCounter(): void;
  13989. /**
  13990. * Set the fragment shader to use in order to render the texture.
  13991. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13992. */
  13993. setFragment(fragment: any): void;
  13994. /**
  13995. * Define the refresh rate of the texture or the rendering frequency.
  13996. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13997. */
  13998. refreshRate: number;
  13999. /** @hidden */
  14000. _shouldRender(): boolean;
  14001. /**
  14002. * Get the size the texture is rendering at.
  14003. * @returns the size (texture is always squared)
  14004. */
  14005. getRenderSize(): number;
  14006. /**
  14007. * Resize the texture to new value.
  14008. * @param size Define the new size the texture should have
  14009. * @param generateMipMaps Define whether the new texture should create mip maps
  14010. */
  14011. resize(size: number, generateMipMaps: boolean): void;
  14012. private _checkUniform;
  14013. /**
  14014. * Set a texture in the shader program used to render.
  14015. * @param name Define the name of the uniform samplers as defined in the shader
  14016. * @param texture Define the texture to bind to this sampler
  14017. * @return the texture itself allowing "fluent" like uniform updates
  14018. */
  14019. setTexture(name: string, texture: Texture): ProceduralTexture;
  14020. /**
  14021. * Set a float in the shader.
  14022. * @param name Define the name of the uniform as defined in the shader
  14023. * @param value Define the value to give to the uniform
  14024. * @return the texture itself allowing "fluent" like uniform updates
  14025. */
  14026. setFloat(name: string, value: number): ProceduralTexture;
  14027. /**
  14028. * Set a int in the shader.
  14029. * @param name Define the name of the uniform as defined in the shader
  14030. * @param value Define the value to give to the uniform
  14031. * @return the texture itself allowing "fluent" like uniform updates
  14032. */
  14033. setInt(name: string, value: number): ProceduralTexture;
  14034. /**
  14035. * Set an array of floats in the shader.
  14036. * @param name Define the name of the uniform as defined in the shader
  14037. * @param value Define the value to give to the uniform
  14038. * @return the texture itself allowing "fluent" like uniform updates
  14039. */
  14040. setFloats(name: string, value: number[]): ProceduralTexture;
  14041. /**
  14042. * Set a vec3 in the shader from a Color3.
  14043. * @param name Define the name of the uniform as defined in the shader
  14044. * @param value Define the value to give to the uniform
  14045. * @return the texture itself allowing "fluent" like uniform updates
  14046. */
  14047. setColor3(name: string, value: Color3): ProceduralTexture;
  14048. /**
  14049. * Set a vec4 in the shader from a Color4.
  14050. * @param name Define the name of the uniform as defined in the shader
  14051. * @param value Define the value to give to the uniform
  14052. * @return the texture itself allowing "fluent" like uniform updates
  14053. */
  14054. setColor4(name: string, value: Color4): ProceduralTexture;
  14055. /**
  14056. * Set a vec2 in the shader from a Vector2.
  14057. * @param name Define the name of the uniform as defined in the shader
  14058. * @param value Define the value to give to the uniform
  14059. * @return the texture itself allowing "fluent" like uniform updates
  14060. */
  14061. setVector2(name: string, value: Vector2): ProceduralTexture;
  14062. /**
  14063. * Set a vec3 in the shader from a Vector3.
  14064. * @param name Define the name of the uniform as defined in the shader
  14065. * @param value Define the value to give to the uniform
  14066. * @return the texture itself allowing "fluent" like uniform updates
  14067. */
  14068. setVector3(name: string, value: Vector3): ProceduralTexture;
  14069. /**
  14070. * Set a mat4 in the shader from a MAtrix.
  14071. * @param name Define the name of the uniform as defined in the shader
  14072. * @param value Define the value to give to the uniform
  14073. * @return the texture itself allowing "fluent" like uniform updates
  14074. */
  14075. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14076. /**
  14077. * Render the texture to its associated render target.
  14078. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14079. */
  14080. render(useCameraPostProcess?: boolean): void;
  14081. /**
  14082. * Clone the texture.
  14083. * @returns the cloned texture
  14084. */
  14085. clone(): ProceduralTexture;
  14086. /**
  14087. * Dispose the texture and release its asoociated resources.
  14088. */
  14089. dispose(): void;
  14090. }
  14091. }
  14092. declare module "babylonjs/Particles/baseParticleSystem" {
  14093. import { Nullable } from "babylonjs/types";
  14094. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14096. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14097. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14098. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14099. import { Scene } from "babylonjs/scene";
  14100. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14101. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14102. import { Texture } from "babylonjs/Materials/Textures/texture";
  14103. import { Animation } from "babylonjs/Animations/animation";
  14104. /**
  14105. * This represents the base class for particle system in Babylon.
  14106. * 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.
  14107. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14108. * @example https://doc.babylonjs.com/babylon101/particles
  14109. */
  14110. export class BaseParticleSystem {
  14111. /**
  14112. * Source color is added to the destination color without alpha affecting the result
  14113. */
  14114. static BLENDMODE_ONEONE: number;
  14115. /**
  14116. * Blend current color and particle color using particle’s alpha
  14117. */
  14118. static BLENDMODE_STANDARD: number;
  14119. /**
  14120. * Add current color and particle color multiplied by particle’s alpha
  14121. */
  14122. static BLENDMODE_ADD: number;
  14123. /**
  14124. * Multiply current color with particle color
  14125. */
  14126. static BLENDMODE_MULTIPLY: number;
  14127. /**
  14128. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14129. */
  14130. static BLENDMODE_MULTIPLYADD: number;
  14131. /**
  14132. * List of animations used by the particle system.
  14133. */
  14134. animations: Animation[];
  14135. /**
  14136. * The id of the Particle system.
  14137. */
  14138. id: string;
  14139. /**
  14140. * The friendly name of the Particle system.
  14141. */
  14142. name: string;
  14143. /**
  14144. * The rendering group used by the Particle system to chose when to render.
  14145. */
  14146. renderingGroupId: number;
  14147. /**
  14148. * The emitter represents the Mesh or position we are attaching the particle system to.
  14149. */
  14150. emitter: Nullable<AbstractMesh | Vector3>;
  14151. /**
  14152. * The maximum number of particles to emit per frame
  14153. */
  14154. emitRate: number;
  14155. /**
  14156. * If you want to launch only a few particles at once, that can be done, as well.
  14157. */
  14158. manualEmitCount: number;
  14159. /**
  14160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14161. */
  14162. updateSpeed: number;
  14163. /**
  14164. * The amount of time the particle system is running (depends of the overall update speed).
  14165. */
  14166. targetStopDuration: number;
  14167. /**
  14168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14169. */
  14170. disposeOnStop: boolean;
  14171. /**
  14172. * Minimum power of emitting particles.
  14173. */
  14174. minEmitPower: number;
  14175. /**
  14176. * Maximum power of emitting particles.
  14177. */
  14178. maxEmitPower: number;
  14179. /**
  14180. * Minimum life time of emitting particles.
  14181. */
  14182. minLifeTime: number;
  14183. /**
  14184. * Maximum life time of emitting particles.
  14185. */
  14186. maxLifeTime: number;
  14187. /**
  14188. * Minimum Size of emitting particles.
  14189. */
  14190. minSize: number;
  14191. /**
  14192. * Maximum Size of emitting particles.
  14193. */
  14194. maxSize: number;
  14195. /**
  14196. * Minimum scale of emitting particles on X axis.
  14197. */
  14198. minScaleX: number;
  14199. /**
  14200. * Maximum scale of emitting particles on X axis.
  14201. */
  14202. maxScaleX: number;
  14203. /**
  14204. * Minimum scale of emitting particles on Y axis.
  14205. */
  14206. minScaleY: number;
  14207. /**
  14208. * Maximum scale of emitting particles on Y axis.
  14209. */
  14210. maxScaleY: number;
  14211. /**
  14212. * Gets or sets the minimal initial rotation in radians.
  14213. */
  14214. minInitialRotation: number;
  14215. /**
  14216. * Gets or sets the maximal initial rotation in radians.
  14217. */
  14218. maxInitialRotation: number;
  14219. /**
  14220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. minAngularSpeed: number;
  14223. /**
  14224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14225. */
  14226. maxAngularSpeed: number;
  14227. /**
  14228. * The texture used to render each particle. (this can be a spritesheet)
  14229. */
  14230. particleTexture: Nullable<Texture>;
  14231. /**
  14232. * The layer mask we are rendering the particles through.
  14233. */
  14234. layerMask: number;
  14235. /**
  14236. * This can help using your own shader to render the particle system.
  14237. * The according effect will be created
  14238. */
  14239. customShader: any;
  14240. /**
  14241. * By default particle system starts as soon as they are created. This prevents the
  14242. * automatic start to happen and let you decide when to start emitting particles.
  14243. */
  14244. preventAutoStart: boolean;
  14245. private _noiseTexture;
  14246. /**
  14247. * Gets or sets a texture used to add random noise to particle positions
  14248. */
  14249. noiseTexture: Nullable<ProceduralTexture>;
  14250. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14251. noiseStrength: Vector3;
  14252. /**
  14253. * Callback triggered when the particle animation is ending.
  14254. */
  14255. onAnimationEnd: Nullable<() => void>;
  14256. /**
  14257. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14258. */
  14259. blendMode: number;
  14260. /**
  14261. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14262. * to override the particles.
  14263. */
  14264. forceDepthWrite: boolean;
  14265. /** 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 */
  14266. preWarmCycles: number;
  14267. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14268. preWarmStepOffset: number;
  14269. /**
  14270. * 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)
  14271. */
  14272. spriteCellChangeSpeed: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14275. */
  14276. startSpriteCellID: number;
  14277. /**
  14278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14279. */
  14280. endSpriteCellID: number;
  14281. /**
  14282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14283. */
  14284. spriteCellWidth: number;
  14285. /**
  14286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14287. */
  14288. spriteCellHeight: number;
  14289. /**
  14290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14291. */
  14292. spriteRandomStartCell: boolean;
  14293. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14294. translationPivot: Vector2;
  14295. /** @hidden */
  14296. protected _isAnimationSheetEnabled: boolean;
  14297. /**
  14298. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14299. */
  14300. beginAnimationOnStart: boolean;
  14301. /**
  14302. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14303. */
  14304. beginAnimationFrom: number;
  14305. /**
  14306. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14307. */
  14308. beginAnimationTo: number;
  14309. /**
  14310. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14311. */
  14312. beginAnimationLoop: boolean;
  14313. /**
  14314. * Gets or sets a world offset applied to all particles
  14315. */
  14316. worldOffset: Vector3;
  14317. /**
  14318. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14319. */
  14320. isAnimationSheetEnabled: boolean;
  14321. /**
  14322. * Get hosting scene
  14323. * @returns the scene
  14324. */
  14325. getScene(): Scene;
  14326. /**
  14327. * You can use gravity if you want to give an orientation to your particles.
  14328. */
  14329. gravity: Vector3;
  14330. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14331. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14332. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14334. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14335. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14337. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14338. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14339. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14340. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14341. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14343. /**
  14344. * Defines the delay in milliseconds before starting the system (0 by default)
  14345. */
  14346. startDelay: number;
  14347. /**
  14348. * Gets the current list of drag gradients.
  14349. * You must use addDragGradient and removeDragGradient to udpate this list
  14350. * @returns the list of drag gradients
  14351. */
  14352. getDragGradients(): Nullable<Array<FactorGradient>>;
  14353. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14354. limitVelocityDamping: number;
  14355. /**
  14356. * Gets the current list of limit velocity gradients.
  14357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14358. * @returns the list of limit velocity gradients
  14359. */
  14360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14361. /**
  14362. * Gets the current list of color gradients.
  14363. * You must use addColorGradient and removeColorGradient to udpate this list
  14364. * @returns the list of color gradients
  14365. */
  14366. getColorGradients(): Nullable<Array<ColorGradient>>;
  14367. /**
  14368. * Gets the current list of size gradients.
  14369. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14370. * @returns the list of size gradients
  14371. */
  14372. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Gets the current list of color remap gradients.
  14375. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14376. * @returns the list of color remap gradients
  14377. */
  14378. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14379. /**
  14380. * Gets the current list of alpha remap gradients.
  14381. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14382. * @returns the list of alpha remap gradients
  14383. */
  14384. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of angular speed gradients.
  14393. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14394. * @returns the list of angular speed gradients
  14395. */
  14396. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14397. /**
  14398. * Gets the current list of velocity gradients.
  14399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14400. * @returns the list of velocity gradients
  14401. */
  14402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14403. /**
  14404. * Gets the current list of start size gradients.
  14405. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14406. * @returns the list of start size gradients
  14407. */
  14408. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14409. /**
  14410. * Gets the current list of emit rate gradients.
  14411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14412. * @returns the list of emit rate gradients
  14413. */
  14414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14415. /**
  14416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14417. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14418. */
  14419. direction1: Vector3;
  14420. /**
  14421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14422. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14423. */
  14424. direction2: Vector3;
  14425. /**
  14426. * 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.
  14427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14428. */
  14429. minEmitBox: Vector3;
  14430. /**
  14431. * 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.
  14432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14433. */
  14434. maxEmitBox: Vector3;
  14435. /**
  14436. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14437. */
  14438. color1: Color4;
  14439. /**
  14440. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14441. */
  14442. color2: Color4;
  14443. /**
  14444. * Color the particle will have at the end of its lifetime
  14445. */
  14446. colorDead: Color4;
  14447. /**
  14448. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14449. */
  14450. textureMask: Color4;
  14451. /**
  14452. * The particle emitter type defines the emitter used by the particle system.
  14453. * It can be for example box, sphere, or cone...
  14454. */
  14455. particleEmitterType: IParticleEmitterType;
  14456. /** @hidden */
  14457. _isSubEmitter: boolean;
  14458. /**
  14459. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14460. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14461. */
  14462. billboardMode: number;
  14463. protected _isBillboardBased: boolean;
  14464. /**
  14465. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14466. */
  14467. isBillboardBased: boolean;
  14468. /**
  14469. * The scene the particle system belongs to.
  14470. */
  14471. protected _scene: Scene;
  14472. /**
  14473. * Local cache of defines for image processing.
  14474. */
  14475. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14476. /**
  14477. * Default configuration related to image processing available in the standard Material.
  14478. */
  14479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14480. /**
  14481. * Gets the image processing configuration used either in this material.
  14482. */
  14483. /**
  14484. * Sets the Default image processing configuration used either in the this material.
  14485. *
  14486. * If sets to null, the scene one is in use.
  14487. */
  14488. imageProcessingConfiguration: ImageProcessingConfiguration;
  14489. /**
  14490. * Attaches a new image processing configuration to the Standard Material.
  14491. * @param configuration
  14492. */
  14493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14494. /** @hidden */
  14495. protected _reset(): void;
  14496. /** @hidden */
  14497. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14498. /**
  14499. * Instantiates a particle system.
  14500. * 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.
  14501. * @param name The name of the particle system
  14502. */
  14503. constructor(name: string);
  14504. /**
  14505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @returns the emitter
  14509. */
  14510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14511. /**
  14512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14513. * @param radius The radius of the hemisphere to emit from
  14514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14515. * @returns the emitter
  14516. */
  14517. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14518. /**
  14519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14520. * @param radius The radius of the sphere to emit from
  14521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14522. * @returns the emitter
  14523. */
  14524. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14525. /**
  14526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14527. * @param radius The radius of the sphere to emit from
  14528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @returns the emitter
  14531. */
  14532. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14533. /**
  14534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14535. * @param radius The radius of the emission cylinder
  14536. * @param height The height of the emission cylinder
  14537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14539. * @returns the emitter
  14540. */
  14541. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14542. /**
  14543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14544. * @param radius The radius of the cylinder to emit from
  14545. * @param height The height of the emission cylinder
  14546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @returns the emitter
  14550. */
  14551. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14552. /**
  14553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14554. * @param radius The radius of the cone to emit from
  14555. * @param angle The base angle of the cone
  14556. * @returns the emitter
  14557. */
  14558. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14559. /**
  14560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @returns the emitter
  14566. */
  14567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14568. }
  14569. }
  14570. declare module "babylonjs/Particles/subEmitter" {
  14571. import { Scene } from "babylonjs/scene";
  14572. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14573. /**
  14574. * Type of sub emitter
  14575. */
  14576. export enum SubEmitterType {
  14577. /**
  14578. * Attached to the particle over it's lifetime
  14579. */
  14580. ATTACHED = 0,
  14581. /**
  14582. * Created when the particle dies
  14583. */
  14584. END = 1
  14585. }
  14586. /**
  14587. * Sub emitter class used to emit particles from an existing particle
  14588. */
  14589. export class SubEmitter {
  14590. /**
  14591. * the particle system to be used by the sub emitter
  14592. */
  14593. particleSystem: ParticleSystem;
  14594. /**
  14595. * Type of the submitter (Default: END)
  14596. */
  14597. type: SubEmitterType;
  14598. /**
  14599. * 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)
  14600. * Note: This only is supported when using an emitter of type Mesh
  14601. */
  14602. inheritDirection: boolean;
  14603. /**
  14604. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14605. */
  14606. inheritedVelocityAmount: number;
  14607. /**
  14608. * Creates a sub emitter
  14609. * @param particleSystem the particle system to be used by the sub emitter
  14610. */
  14611. constructor(
  14612. /**
  14613. * the particle system to be used by the sub emitter
  14614. */
  14615. particleSystem: ParticleSystem);
  14616. /**
  14617. * Clones the sub emitter
  14618. * @returns the cloned sub emitter
  14619. */
  14620. clone(): SubEmitter;
  14621. /**
  14622. * Serialize current object to a JSON object
  14623. * @returns the serialized object
  14624. */
  14625. serialize(): any;
  14626. /** @hidden */
  14627. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14628. /**
  14629. * Creates a new SubEmitter from a serialized JSON version
  14630. * @param serializationObject defines the JSON object to read from
  14631. * @param scene defines the hosting scene
  14632. * @param rootUrl defines the rootUrl for data loading
  14633. * @returns a new SubEmitter
  14634. */
  14635. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14636. /** Release associated resources */
  14637. dispose(): void;
  14638. }
  14639. }
  14640. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14641. /** @hidden */
  14642. export var clipPlaneFragmentDeclaration: {
  14643. name: string;
  14644. shader: string;
  14645. };
  14646. }
  14647. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14648. /** @hidden */
  14649. export var imageProcessingDeclaration: {
  14650. name: string;
  14651. shader: string;
  14652. };
  14653. }
  14654. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14655. /** @hidden */
  14656. export var imageProcessingFunctions: {
  14657. name: string;
  14658. shader: string;
  14659. };
  14660. }
  14661. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14662. /** @hidden */
  14663. export var clipPlaneFragment: {
  14664. name: string;
  14665. shader: string;
  14666. };
  14667. }
  14668. declare module "babylonjs/Shaders/particles.fragment" {
  14669. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14670. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14672. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14673. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14674. /** @hidden */
  14675. export var particlesPixelShader: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14681. /** @hidden */
  14682. export var clipPlaneVertexDeclaration: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14688. /** @hidden */
  14689. export var clipPlaneVertex: {
  14690. name: string;
  14691. shader: string;
  14692. };
  14693. }
  14694. declare module "babylonjs/Shaders/particles.vertex" {
  14695. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14697. /** @hidden */
  14698. export var particlesVertexShader: {
  14699. name: string;
  14700. shader: string;
  14701. };
  14702. }
  14703. declare module "babylonjs/Particles/particleSystem" {
  14704. import { Nullable } from "babylonjs/types";
  14705. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14706. import { Observable } from "babylonjs/Misc/observable";
  14707. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14708. import { Effect } from "babylonjs/Materials/effect";
  14709. import { Scene, IDisposable } from "babylonjs/scene";
  14710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14711. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14712. import { Particle } from "babylonjs/Particles/particle";
  14713. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14714. import "babylonjs/Shaders/particles.fragment";
  14715. import "babylonjs/Shaders/particles.vertex";
  14716. /**
  14717. * This represents a particle system in Babylon.
  14718. * 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.
  14719. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14720. * @example https://doc.babylonjs.com/babylon101/particles
  14721. */
  14722. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14723. /**
  14724. * Billboard mode will only apply to Y axis
  14725. */
  14726. static readonly BILLBOARDMODE_Y: number;
  14727. /**
  14728. * Billboard mode will apply to all axes
  14729. */
  14730. static readonly BILLBOARDMODE_ALL: number;
  14731. /**
  14732. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14733. */
  14734. static readonly BILLBOARDMODE_STRETCHED: number;
  14735. /**
  14736. * This function can be defined to provide custom update for active particles.
  14737. * This function will be called instead of regular update (age, position, color, etc.).
  14738. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14739. */
  14740. updateFunction: (particles: Particle[]) => void;
  14741. private _emitterWorldMatrix;
  14742. /**
  14743. * This function can be defined to specify initial direction for every new particle.
  14744. * It by default use the emitterType defined function
  14745. */
  14746. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14747. /**
  14748. * This function can be defined to specify initial position for every new particle.
  14749. * It by default use the emitterType defined function
  14750. */
  14751. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14752. /**
  14753. * @hidden
  14754. */
  14755. _inheritedVelocityOffset: Vector3;
  14756. /**
  14757. * An event triggered when the system is disposed
  14758. */
  14759. onDisposeObservable: Observable<ParticleSystem>;
  14760. private _onDisposeObserver;
  14761. /**
  14762. * Sets a callback that will be triggered when the system is disposed
  14763. */
  14764. onDispose: () => void;
  14765. private _particles;
  14766. private _epsilon;
  14767. private _capacity;
  14768. private _stockParticles;
  14769. private _newPartsExcess;
  14770. private _vertexData;
  14771. private _vertexBuffer;
  14772. private _vertexBuffers;
  14773. private _spriteBuffer;
  14774. private _indexBuffer;
  14775. private _effect;
  14776. private _customEffect;
  14777. private _cachedDefines;
  14778. private _scaledColorStep;
  14779. private _colorDiff;
  14780. private _scaledDirection;
  14781. private _scaledGravity;
  14782. private _currentRenderId;
  14783. private _alive;
  14784. private _useInstancing;
  14785. private _started;
  14786. private _stopped;
  14787. private _actualFrame;
  14788. private _scaledUpdateSpeed;
  14789. private _vertexBufferSize;
  14790. /** @hidden */
  14791. _currentEmitRateGradient: Nullable<FactorGradient>;
  14792. /** @hidden */
  14793. _currentEmitRate1: number;
  14794. /** @hidden */
  14795. _currentEmitRate2: number;
  14796. /** @hidden */
  14797. _currentStartSizeGradient: Nullable<FactorGradient>;
  14798. /** @hidden */
  14799. _currentStartSize1: number;
  14800. /** @hidden */
  14801. _currentStartSize2: number;
  14802. private readonly _rawTextureWidth;
  14803. private _rampGradientsTexture;
  14804. private _useRampGradients;
  14805. /** Gets or sets a boolean indicating that ramp gradients must be used
  14806. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14807. */
  14808. useRampGradients: boolean;
  14809. /**
  14810. * 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.
  14811. * 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: [])
  14812. */
  14813. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14814. private _subEmitters;
  14815. /**
  14816. * @hidden
  14817. * If the particle systems emitter should be disposed when the particle system is disposed
  14818. */
  14819. _disposeEmitterOnDispose: boolean;
  14820. /**
  14821. * The current active Sub-systems, this property is used by the root particle system only.
  14822. */
  14823. activeSubSystems: Array<ParticleSystem>;
  14824. private _rootParticleSystem;
  14825. /**
  14826. * Gets the current list of active particles
  14827. */
  14828. readonly particles: Particle[];
  14829. /**
  14830. * Returns the string "ParticleSystem"
  14831. * @returns a string containing the class name
  14832. */
  14833. getClassName(): string;
  14834. /**
  14835. * Instantiates a particle system.
  14836. * 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.
  14837. * @param name The name of the particle system
  14838. * @param capacity The max number of particles alive at the same time
  14839. * @param scene The scene the particle system belongs to
  14840. * @param customEffect a custom effect used to change the way particles are rendered by default
  14841. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14842. * @param epsilon Offset used to render the particles
  14843. */
  14844. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14845. private _addFactorGradient;
  14846. private _removeFactorGradient;
  14847. /**
  14848. * Adds a new life time gradient
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the life time factor to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific life time gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Adds a new size gradient
  14863. * @param gradient defines the gradient to use (between 0 and 1)
  14864. * @param factor defines the size factor to affect to the specified gradient
  14865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14866. * @returns the current particle system
  14867. */
  14868. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14869. /**
  14870. * Remove a specific size gradient
  14871. * @param gradient defines the gradient to remove
  14872. * @returns the current particle system
  14873. */
  14874. removeSizeGradient(gradient: number): IParticleSystem;
  14875. /**
  14876. * Adds a new color remap gradient
  14877. * @param gradient defines the gradient to use (between 0 and 1)
  14878. * @param min defines the color remap minimal range
  14879. * @param max defines the color remap maximal range
  14880. * @returns the current particle system
  14881. */
  14882. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14883. /**
  14884. * Remove a specific color remap gradient
  14885. * @param gradient defines the gradient to remove
  14886. * @returns the current particle system
  14887. */
  14888. removeColorRemapGradient(gradient: number): IParticleSystem;
  14889. /**
  14890. * Adds a new alpha remap gradient
  14891. * @param gradient defines the gradient to use (between 0 and 1)
  14892. * @param min defines the alpha remap minimal range
  14893. * @param max defines the alpha remap maximal range
  14894. * @returns the current particle system
  14895. */
  14896. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14897. /**
  14898. * Remove a specific alpha remap gradient
  14899. * @param gradient defines the gradient to remove
  14900. * @returns the current particle system
  14901. */
  14902. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14903. /**
  14904. * Adds a new angular speed gradient
  14905. * @param gradient defines the gradient to use (between 0 and 1)
  14906. * @param factor defines the angular speed to affect to the specified gradient
  14907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14908. * @returns the current particle system
  14909. */
  14910. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14911. /**
  14912. * Remove a specific angular speed gradient
  14913. * @param gradient defines the gradient to remove
  14914. * @returns the current particle system
  14915. */
  14916. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14917. /**
  14918. * Adds a new velocity gradient
  14919. * @param gradient defines the gradient to use (between 0 and 1)
  14920. * @param factor defines the velocity to affect to the specified gradient
  14921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14922. * @returns the current particle system
  14923. */
  14924. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14925. /**
  14926. * Remove a specific velocity gradient
  14927. * @param gradient defines the gradient to remove
  14928. * @returns the current particle system
  14929. */
  14930. removeVelocityGradient(gradient: number): IParticleSystem;
  14931. /**
  14932. * Adds a new limit velocity gradient
  14933. * @param gradient defines the gradient to use (between 0 and 1)
  14934. * @param factor defines the limit velocity value to affect to the specified gradient
  14935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14936. * @returns the current particle system
  14937. */
  14938. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14939. /**
  14940. * Remove a specific limit velocity gradient
  14941. * @param gradient defines the gradient to remove
  14942. * @returns the current particle system
  14943. */
  14944. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14945. /**
  14946. * Adds a new drag gradient
  14947. * @param gradient defines the gradient to use (between 0 and 1)
  14948. * @param factor defines the drag value to affect to the specified gradient
  14949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14950. * @returns the current particle system
  14951. */
  14952. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14953. /**
  14954. * Remove a specific drag gradient
  14955. * @param gradient defines the gradient to remove
  14956. * @returns the current particle system
  14957. */
  14958. removeDragGradient(gradient: number): IParticleSystem;
  14959. /**
  14960. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14961. * @param gradient defines the gradient to use (between 0 and 1)
  14962. * @param factor defines the emit rate value to affect to the specified gradient
  14963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14964. * @returns the current particle system
  14965. */
  14966. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14967. /**
  14968. * Remove a specific emit rate gradient
  14969. * @param gradient defines the gradient to remove
  14970. * @returns the current particle system
  14971. */
  14972. removeEmitRateGradient(gradient: number): IParticleSystem;
  14973. /**
  14974. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14975. * @param gradient defines the gradient to use (between 0 and 1)
  14976. * @param factor defines the start size value to affect to the specified gradient
  14977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14978. * @returns the current particle system
  14979. */
  14980. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14981. /**
  14982. * Remove a specific start size gradient
  14983. * @param gradient defines the gradient to remove
  14984. * @returns the current particle system
  14985. */
  14986. removeStartSizeGradient(gradient: number): IParticleSystem;
  14987. private _createRampGradientTexture;
  14988. /**
  14989. * Gets the current list of ramp gradients.
  14990. * You must use addRampGradient and removeRampGradient to udpate this list
  14991. * @returns the list of ramp gradients
  14992. */
  14993. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14994. /**
  14995. * Adds a new ramp gradient used to remap particle colors
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param color defines the color to affect to the specified gradient
  14998. * @returns the current particle system
  14999. */
  15000. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15001. /**
  15002. * Remove a specific ramp gradient
  15003. * @param gradient defines the gradient to remove
  15004. * @returns the current particle system
  15005. */
  15006. removeRampGradient(gradient: number): ParticleSystem;
  15007. /**
  15008. * Adds a new color gradient
  15009. * @param gradient defines the gradient to use (between 0 and 1)
  15010. * @param color1 defines the color to affect to the specified gradient
  15011. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15012. * @returns this particle system
  15013. */
  15014. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15015. /**
  15016. * Remove a specific color gradient
  15017. * @param gradient defines the gradient to remove
  15018. * @returns this particle system
  15019. */
  15020. removeColorGradient(gradient: number): IParticleSystem;
  15021. private _fetchR;
  15022. protected _reset(): void;
  15023. private _resetEffect;
  15024. private _createVertexBuffers;
  15025. private _createIndexBuffer;
  15026. /**
  15027. * Gets the maximum number of particles active at the same time.
  15028. * @returns The max number of active particles.
  15029. */
  15030. getCapacity(): number;
  15031. /**
  15032. * Gets whether there are still active particles in the system.
  15033. * @returns True if it is alive, otherwise false.
  15034. */
  15035. isAlive(): boolean;
  15036. /**
  15037. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15038. * @returns True if it has been started, otherwise false.
  15039. */
  15040. isStarted(): boolean;
  15041. private _prepareSubEmitterInternalArray;
  15042. /**
  15043. * Starts the particle system and begins to emit
  15044. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15045. */
  15046. start(delay?: number): void;
  15047. /**
  15048. * Stops the particle system.
  15049. * @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.
  15050. */
  15051. stop(stopSubEmitters?: boolean): void;
  15052. /**
  15053. * Remove all active particles
  15054. */
  15055. reset(): void;
  15056. /**
  15057. * @hidden (for internal use only)
  15058. */
  15059. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15060. /**
  15061. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15062. * Its lifetime will start back at 0.
  15063. */
  15064. recycleParticle: (particle: Particle) => void;
  15065. private _stopSubEmitters;
  15066. private _createParticle;
  15067. private _removeFromRoot;
  15068. private _emitFromParticle;
  15069. private _update;
  15070. /** @hidden */
  15071. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15072. /** @hidden */
  15073. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15074. /** @hidden */
  15075. private _getEffect;
  15076. /**
  15077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15079. */
  15080. animate(preWarmOnly?: boolean): void;
  15081. private _appendParticleVertices;
  15082. /**
  15083. * Rebuilds the particle system.
  15084. */
  15085. rebuild(): void;
  15086. /**
  15087. * Is this system ready to be used/rendered
  15088. * @return true if the system is ready
  15089. */
  15090. isReady(): boolean;
  15091. private _render;
  15092. /**
  15093. * Renders the particle system in its current state.
  15094. * @returns the current number of particles
  15095. */
  15096. render(): number;
  15097. /**
  15098. * Disposes the particle system and free the associated resources
  15099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15100. */
  15101. dispose(disposeTexture?: boolean): void;
  15102. /**
  15103. * Clones the particle system.
  15104. * @param name The name of the cloned object
  15105. * @param newEmitter The new emitter to use
  15106. * @returns the cloned particle system
  15107. */
  15108. clone(name: string, newEmitter: any): ParticleSystem;
  15109. /**
  15110. * Serializes the particle system to a JSON object.
  15111. * @returns the JSON object
  15112. */
  15113. serialize(): any;
  15114. /** @hidden */
  15115. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15116. /** @hidden */
  15117. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15118. /**
  15119. * Parses a JSON object to create a particle system.
  15120. * @param parsedParticleSystem The JSON object to parse
  15121. * @param scene The scene to create the particle system in
  15122. * @param rootUrl The root url to use to load external dependencies like texture
  15123. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15124. * @returns the Parsed particle system
  15125. */
  15126. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15127. }
  15128. }
  15129. declare module "babylonjs/Particles/particle" {
  15130. import { Nullable } from "babylonjs/types";
  15131. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15132. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15133. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15134. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15135. /**
  15136. * A particle represents one of the element emitted by a particle system.
  15137. * This is mainly define by its coordinates, direction, velocity and age.
  15138. */
  15139. export class Particle {
  15140. /**
  15141. * The particle system the particle belongs to.
  15142. */
  15143. particleSystem: ParticleSystem;
  15144. private static _Count;
  15145. /**
  15146. * Unique ID of the particle
  15147. */
  15148. id: number;
  15149. /**
  15150. * The world position of the particle in the scene.
  15151. */
  15152. position: Vector3;
  15153. /**
  15154. * The world direction of the particle in the scene.
  15155. */
  15156. direction: Vector3;
  15157. /**
  15158. * The color of the particle.
  15159. */
  15160. color: Color4;
  15161. /**
  15162. * The color change of the particle per step.
  15163. */
  15164. colorStep: Color4;
  15165. /**
  15166. * Defines how long will the life of the particle be.
  15167. */
  15168. lifeTime: number;
  15169. /**
  15170. * The current age of the particle.
  15171. */
  15172. age: number;
  15173. /**
  15174. * The current size of the particle.
  15175. */
  15176. size: number;
  15177. /**
  15178. * The current scale of the particle.
  15179. */
  15180. scale: Vector2;
  15181. /**
  15182. * The current angle of the particle.
  15183. */
  15184. angle: number;
  15185. /**
  15186. * Defines how fast is the angle changing.
  15187. */
  15188. angularSpeed: number;
  15189. /**
  15190. * Defines the cell index used by the particle to be rendered from a sprite.
  15191. */
  15192. cellIndex: number;
  15193. /**
  15194. * The information required to support color remapping
  15195. */
  15196. remapData: Vector4;
  15197. /** @hidden */
  15198. _randomCellOffset?: number;
  15199. /** @hidden */
  15200. _initialDirection: Nullable<Vector3>;
  15201. /** @hidden */
  15202. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15203. /** @hidden */
  15204. _initialStartSpriteCellID: number;
  15205. /** @hidden */
  15206. _initialEndSpriteCellID: number;
  15207. /** @hidden */
  15208. _currentColorGradient: Nullable<ColorGradient>;
  15209. /** @hidden */
  15210. _currentColor1: Color4;
  15211. /** @hidden */
  15212. _currentColor2: Color4;
  15213. /** @hidden */
  15214. _currentSizeGradient: Nullable<FactorGradient>;
  15215. /** @hidden */
  15216. _currentSize1: number;
  15217. /** @hidden */
  15218. _currentSize2: number;
  15219. /** @hidden */
  15220. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15221. /** @hidden */
  15222. _currentAngularSpeed1: number;
  15223. /** @hidden */
  15224. _currentAngularSpeed2: number;
  15225. /** @hidden */
  15226. _currentVelocityGradient: Nullable<FactorGradient>;
  15227. /** @hidden */
  15228. _currentVelocity1: number;
  15229. /** @hidden */
  15230. _currentVelocity2: number;
  15231. /** @hidden */
  15232. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15233. /** @hidden */
  15234. _currentLimitVelocity1: number;
  15235. /** @hidden */
  15236. _currentLimitVelocity2: number;
  15237. /** @hidden */
  15238. _currentDragGradient: Nullable<FactorGradient>;
  15239. /** @hidden */
  15240. _currentDrag1: number;
  15241. /** @hidden */
  15242. _currentDrag2: number;
  15243. /** @hidden */
  15244. _randomNoiseCoordinates1: Vector3;
  15245. /** @hidden */
  15246. _randomNoiseCoordinates2: Vector3;
  15247. /**
  15248. * Creates a new instance Particle
  15249. * @param particleSystem the particle system the particle belongs to
  15250. */
  15251. constructor(
  15252. /**
  15253. * The particle system the particle belongs to.
  15254. */
  15255. particleSystem: ParticleSystem);
  15256. private updateCellInfoFromSystem;
  15257. /**
  15258. * Defines how the sprite cell index is updated for the particle
  15259. */
  15260. updateCellIndex(): void;
  15261. /** @hidden */
  15262. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15263. /** @hidden */
  15264. _inheritParticleInfoToSubEmitters(): void;
  15265. /** @hidden */
  15266. _reset(): void;
  15267. /**
  15268. * Copy the properties of particle to another one.
  15269. * @param other the particle to copy the information to.
  15270. */
  15271. copyTo(other: Particle): void;
  15272. }
  15273. }
  15274. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15275. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15276. import { Effect } from "babylonjs/Materials/effect";
  15277. import { Particle } from "babylonjs/Particles/particle";
  15278. /**
  15279. * Particle emitter represents a volume emitting particles.
  15280. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15281. */
  15282. export interface IParticleEmitterType {
  15283. /**
  15284. * Called by the particle System when the direction is computed for the created particle.
  15285. * @param worldMatrix is the world matrix of the particle system
  15286. * @param directionToUpdate is the direction vector to update with the result
  15287. * @param particle is the particle we are computed the direction for
  15288. */
  15289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15290. /**
  15291. * Called by the particle System when the position is computed for the created particle.
  15292. * @param worldMatrix is the world matrix of the particle system
  15293. * @param positionToUpdate is the position vector to update with the result
  15294. * @param particle is the particle we are computed the position for
  15295. */
  15296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15297. /**
  15298. * Clones the current emitter and returns a copy of it
  15299. * @returns the new emitter
  15300. */
  15301. clone(): IParticleEmitterType;
  15302. /**
  15303. * Called by the GPUParticleSystem to setup the update shader
  15304. * @param effect defines the update shader
  15305. */
  15306. applyToShader(effect: Effect): void;
  15307. /**
  15308. * Returns a string to use to update the GPU particles update shader
  15309. * @returns the effect defines string
  15310. */
  15311. getEffectDefines(): string;
  15312. /**
  15313. * Returns a string representing the class name
  15314. * @returns a string containing the class name
  15315. */
  15316. getClassName(): string;
  15317. /**
  15318. * Serializes the particle system to a JSON object.
  15319. * @returns the JSON object
  15320. */
  15321. serialize(): any;
  15322. /**
  15323. * Parse properties from a JSON object
  15324. * @param serializationObject defines the JSON object
  15325. */
  15326. parse(serializationObject: any): void;
  15327. }
  15328. }
  15329. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15330. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15331. import { Effect } from "babylonjs/Materials/effect";
  15332. import { Particle } from "babylonjs/Particles/particle";
  15333. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15334. /**
  15335. * Particle emitter emitting particles from the inside of a box.
  15336. * It emits the particles randomly between 2 given directions.
  15337. */
  15338. export class BoxParticleEmitter implements IParticleEmitterType {
  15339. /**
  15340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15341. */
  15342. direction1: Vector3;
  15343. /**
  15344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15345. */
  15346. direction2: Vector3;
  15347. /**
  15348. * 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.
  15349. */
  15350. minEmitBox: Vector3;
  15351. /**
  15352. * 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.
  15353. */
  15354. maxEmitBox: Vector3;
  15355. /**
  15356. * Creates a new instance BoxParticleEmitter
  15357. */
  15358. constructor();
  15359. /**
  15360. * Called by the particle System when the direction is computed for the created particle.
  15361. * @param worldMatrix is the world matrix of the particle system
  15362. * @param directionToUpdate is the direction vector to update with the result
  15363. * @param particle is the particle we are computed the direction for
  15364. */
  15365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15366. /**
  15367. * Called by the particle System when the position is computed for the created particle.
  15368. * @param worldMatrix is the world matrix of the particle system
  15369. * @param positionToUpdate is the position vector to update with the result
  15370. * @param particle is the particle we are computed the position for
  15371. */
  15372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15373. /**
  15374. * Clones the current emitter and returns a copy of it
  15375. * @returns the new emitter
  15376. */
  15377. clone(): BoxParticleEmitter;
  15378. /**
  15379. * Called by the GPUParticleSystem to setup the update shader
  15380. * @param effect defines the update shader
  15381. */
  15382. applyToShader(effect: Effect): void;
  15383. /**
  15384. * Returns a string to use to update the GPU particles update shader
  15385. * @returns a string containng the defines string
  15386. */
  15387. getEffectDefines(): string;
  15388. /**
  15389. * Returns the string "BoxParticleEmitter"
  15390. * @returns a string containing the class name
  15391. */
  15392. getClassName(): string;
  15393. /**
  15394. * Serializes the particle system to a JSON object.
  15395. * @returns the JSON object
  15396. */
  15397. serialize(): any;
  15398. /**
  15399. * Parse properties from a JSON object
  15400. * @param serializationObject defines the JSON object
  15401. */
  15402. parse(serializationObject: any): void;
  15403. }
  15404. }
  15405. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15406. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15407. import { Effect } from "babylonjs/Materials/effect";
  15408. import { Particle } from "babylonjs/Particles/particle";
  15409. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15410. /**
  15411. * Particle emitter emitting particles from the inside of a cone.
  15412. * It emits the particles alongside the cone volume from the base to the particle.
  15413. * The emission direction might be randomized.
  15414. */
  15415. export class ConeParticleEmitter implements IParticleEmitterType {
  15416. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15417. directionRandomizer: number;
  15418. private _radius;
  15419. private _angle;
  15420. private _height;
  15421. /**
  15422. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15423. */
  15424. radiusRange: number;
  15425. /**
  15426. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15427. */
  15428. heightRange: number;
  15429. /**
  15430. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15431. */
  15432. emitFromSpawnPointOnly: boolean;
  15433. /**
  15434. * Gets or sets the radius of the emission cone
  15435. */
  15436. radius: number;
  15437. /**
  15438. * Gets or sets the angle of the emission cone
  15439. */
  15440. angle: number;
  15441. private _buildHeight;
  15442. /**
  15443. * Creates a new instance ConeParticleEmitter
  15444. * @param radius the radius of the emission cone (1 by default)
  15445. * @param angle the cone base angle (PI by default)
  15446. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15447. */
  15448. constructor(radius?: number, angle?: number,
  15449. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15450. directionRandomizer?: number);
  15451. /**
  15452. * Called by the particle System when the direction is computed for the created particle.
  15453. * @param worldMatrix is the world matrix of the particle system
  15454. * @param directionToUpdate is the direction vector to update with the result
  15455. * @param particle is the particle we are computed the direction for
  15456. */
  15457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15458. /**
  15459. * Called by the particle System when the position is computed for the created particle.
  15460. * @param worldMatrix is the world matrix of the particle system
  15461. * @param positionToUpdate is the position vector to update with the result
  15462. * @param particle is the particle we are computed the position for
  15463. */
  15464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15465. /**
  15466. * Clones the current emitter and returns a copy of it
  15467. * @returns the new emitter
  15468. */
  15469. clone(): ConeParticleEmitter;
  15470. /**
  15471. * Called by the GPUParticleSystem to setup the update shader
  15472. * @param effect defines the update shader
  15473. */
  15474. applyToShader(effect: Effect): void;
  15475. /**
  15476. * Returns a string to use to update the GPU particles update shader
  15477. * @returns a string containng the defines string
  15478. */
  15479. getEffectDefines(): string;
  15480. /**
  15481. * Returns the string "ConeParticleEmitter"
  15482. * @returns a string containing the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Serializes the particle system to a JSON object.
  15487. * @returns the JSON object
  15488. */
  15489. serialize(): any;
  15490. /**
  15491. * Parse properties from a JSON object
  15492. * @param serializationObject defines the JSON object
  15493. */
  15494. parse(serializationObject: any): void;
  15495. }
  15496. }
  15497. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15498. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15499. import { Effect } from "babylonjs/Materials/effect";
  15500. import { Particle } from "babylonjs/Particles/particle";
  15501. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15502. /**
  15503. * Particle emitter emitting particles from the inside of a cylinder.
  15504. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15505. */
  15506. export class CylinderParticleEmitter implements IParticleEmitterType {
  15507. /**
  15508. * The radius of the emission cylinder.
  15509. */
  15510. radius: number;
  15511. /**
  15512. * The height of the emission cylinder.
  15513. */
  15514. height: number;
  15515. /**
  15516. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15517. */
  15518. radiusRange: number;
  15519. /**
  15520. * How much to randomize the particle direction [0-1].
  15521. */
  15522. directionRandomizer: number;
  15523. /**
  15524. * Creates a new instance CylinderParticleEmitter
  15525. * @param radius the radius of the emission cylinder (1 by default)
  15526. * @param height the height of the emission cylinder (1 by default)
  15527. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15529. */
  15530. constructor(
  15531. /**
  15532. * The radius of the emission cylinder.
  15533. */
  15534. radius?: number,
  15535. /**
  15536. * The height of the emission cylinder.
  15537. */
  15538. height?: number,
  15539. /**
  15540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15541. */
  15542. radiusRange?: number,
  15543. /**
  15544. * How much to randomize the particle direction [0-1].
  15545. */
  15546. directionRandomizer?: number);
  15547. /**
  15548. * Called by the particle System when the direction is computed for the created particle.
  15549. * @param worldMatrix is the world matrix of the particle system
  15550. * @param directionToUpdate is the direction vector to update with the result
  15551. * @param particle is the particle we are computed the direction for
  15552. */
  15553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15554. /**
  15555. * Called by the particle System when the position is computed for the created particle.
  15556. * @param worldMatrix is the world matrix of the particle system
  15557. * @param positionToUpdate is the position vector to update with the result
  15558. * @param particle is the particle we are computed the position for
  15559. */
  15560. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15561. /**
  15562. * Clones the current emitter and returns a copy of it
  15563. * @returns the new emitter
  15564. */
  15565. clone(): CylinderParticleEmitter;
  15566. /**
  15567. * Called by the GPUParticleSystem to setup the update shader
  15568. * @param effect defines the update shader
  15569. */
  15570. applyToShader(effect: Effect): void;
  15571. /**
  15572. * Returns a string to use to update the GPU particles update shader
  15573. * @returns a string containng the defines string
  15574. */
  15575. getEffectDefines(): string;
  15576. /**
  15577. * Returns the string "CylinderParticleEmitter"
  15578. * @returns a string containing the class name
  15579. */
  15580. getClassName(): string;
  15581. /**
  15582. * Serializes the particle system to a JSON object.
  15583. * @returns the JSON object
  15584. */
  15585. serialize(): any;
  15586. /**
  15587. * Parse properties from a JSON object
  15588. * @param serializationObject defines the JSON object
  15589. */
  15590. parse(serializationObject: any): void;
  15591. }
  15592. /**
  15593. * Particle emitter emitting particles from the inside of a cylinder.
  15594. * It emits the particles randomly between two vectors.
  15595. */
  15596. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15597. /**
  15598. * The min limit of the emission direction.
  15599. */
  15600. direction1: Vector3;
  15601. /**
  15602. * The max limit of the emission direction.
  15603. */
  15604. direction2: Vector3;
  15605. /**
  15606. * Creates a new instance CylinderDirectedParticleEmitter
  15607. * @param radius the radius of the emission cylinder (1 by default)
  15608. * @param height the height of the emission cylinder (1 by default)
  15609. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15610. * @param direction1 the min limit of the emission direction (up vector by default)
  15611. * @param direction2 the max limit of the emission direction (up vector by default)
  15612. */
  15613. constructor(radius?: number, height?: number, radiusRange?: number,
  15614. /**
  15615. * The min limit of the emission direction.
  15616. */
  15617. direction1?: Vector3,
  15618. /**
  15619. * The max limit of the emission direction.
  15620. */
  15621. direction2?: Vector3);
  15622. /**
  15623. * Called by the particle System when the direction is computed for the created particle.
  15624. * @param worldMatrix is the world matrix of the particle system
  15625. * @param directionToUpdate is the direction vector to update with the result
  15626. * @param particle is the particle we are computed the direction for
  15627. */
  15628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15629. /**
  15630. * Clones the current emitter and returns a copy of it
  15631. * @returns the new emitter
  15632. */
  15633. clone(): CylinderDirectedParticleEmitter;
  15634. /**
  15635. * Called by the GPUParticleSystem to setup the update shader
  15636. * @param effect defines the update shader
  15637. */
  15638. applyToShader(effect: Effect): void;
  15639. /**
  15640. * Returns a string to use to update the GPU particles update shader
  15641. * @returns a string containng the defines string
  15642. */
  15643. getEffectDefines(): string;
  15644. /**
  15645. * Returns the string "CylinderDirectedParticleEmitter"
  15646. * @returns a string containing the class name
  15647. */
  15648. getClassName(): string;
  15649. /**
  15650. * Serializes the particle system to a JSON object.
  15651. * @returns the JSON object
  15652. */
  15653. serialize(): any;
  15654. /**
  15655. * Parse properties from a JSON object
  15656. * @param serializationObject defines the JSON object
  15657. */
  15658. parse(serializationObject: any): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15662. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Particle } from "babylonjs/Particles/particle";
  15665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15666. /**
  15667. * Particle emitter emitting particles from the inside of a hemisphere.
  15668. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15669. */
  15670. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15671. /**
  15672. * The radius of the emission hemisphere.
  15673. */
  15674. radius: number;
  15675. /**
  15676. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15677. */
  15678. radiusRange: number;
  15679. /**
  15680. * How much to randomize the particle direction [0-1].
  15681. */
  15682. directionRandomizer: number;
  15683. /**
  15684. * Creates a new instance HemisphericParticleEmitter
  15685. * @param radius the radius of the emission hemisphere (1 by default)
  15686. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15687. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15688. */
  15689. constructor(
  15690. /**
  15691. * The radius of the emission hemisphere.
  15692. */
  15693. radius?: number,
  15694. /**
  15695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15696. */
  15697. radiusRange?: number,
  15698. /**
  15699. * How much to randomize the particle direction [0-1].
  15700. */
  15701. directionRandomizer?: number);
  15702. /**
  15703. * Called by the particle System when the direction is computed for the created particle.
  15704. * @param worldMatrix is the world matrix of the particle system
  15705. * @param directionToUpdate is the direction vector to update with the result
  15706. * @param particle is the particle we are computed the direction for
  15707. */
  15708. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15709. /**
  15710. * Called by the particle System when the position is computed for the created particle.
  15711. * @param worldMatrix is the world matrix of the particle system
  15712. * @param positionToUpdate is the position vector to update with the result
  15713. * @param particle is the particle we are computed the position for
  15714. */
  15715. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15716. /**
  15717. * Clones the current emitter and returns a copy of it
  15718. * @returns the new emitter
  15719. */
  15720. clone(): HemisphericParticleEmitter;
  15721. /**
  15722. * Called by the GPUParticleSystem to setup the update shader
  15723. * @param effect defines the update shader
  15724. */
  15725. applyToShader(effect: Effect): void;
  15726. /**
  15727. * Returns a string to use to update the GPU particles update shader
  15728. * @returns a string containng the defines string
  15729. */
  15730. getEffectDefines(): string;
  15731. /**
  15732. * Returns the string "HemisphericParticleEmitter"
  15733. * @returns a string containing the class name
  15734. */
  15735. getClassName(): string;
  15736. /**
  15737. * Serializes the particle system to a JSON object.
  15738. * @returns the JSON object
  15739. */
  15740. serialize(): any;
  15741. /**
  15742. * Parse properties from a JSON object
  15743. * @param serializationObject defines the JSON object
  15744. */
  15745. parse(serializationObject: any): void;
  15746. }
  15747. }
  15748. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15749. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15750. import { Effect } from "babylonjs/Materials/effect";
  15751. import { Particle } from "babylonjs/Particles/particle";
  15752. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15753. /**
  15754. * Particle emitter emitting particles from a point.
  15755. * It emits the particles randomly between 2 given directions.
  15756. */
  15757. export class PointParticleEmitter implements IParticleEmitterType {
  15758. /**
  15759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15760. */
  15761. direction1: Vector3;
  15762. /**
  15763. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15764. */
  15765. direction2: Vector3;
  15766. /**
  15767. * Creates a new instance PointParticleEmitter
  15768. */
  15769. constructor();
  15770. /**
  15771. * Called by the particle System when the direction is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param directionToUpdate is the direction vector to update with the result
  15774. * @param particle is the particle we are computed the direction for
  15775. */
  15776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Called by the particle System when the position is computed for the created particle.
  15779. * @param worldMatrix is the world matrix of the particle system
  15780. * @param positionToUpdate is the position vector to update with the result
  15781. * @param particle is the particle we are computed the position for
  15782. */
  15783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15784. /**
  15785. * Clones the current emitter and returns a copy of it
  15786. * @returns the new emitter
  15787. */
  15788. clone(): PointParticleEmitter;
  15789. /**
  15790. * Called by the GPUParticleSystem to setup the update shader
  15791. * @param effect defines the update shader
  15792. */
  15793. applyToShader(effect: Effect): void;
  15794. /**
  15795. * Returns a string to use to update the GPU particles update shader
  15796. * @returns a string containng the defines string
  15797. */
  15798. getEffectDefines(): string;
  15799. /**
  15800. * Returns the string "PointParticleEmitter"
  15801. * @returns a string containing the class name
  15802. */
  15803. getClassName(): string;
  15804. /**
  15805. * Serializes the particle system to a JSON object.
  15806. * @returns the JSON object
  15807. */
  15808. serialize(): any;
  15809. /**
  15810. * Parse properties from a JSON object
  15811. * @param serializationObject defines the JSON object
  15812. */
  15813. parse(serializationObject: any): void;
  15814. }
  15815. }
  15816. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15817. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15818. import { Effect } from "babylonjs/Materials/effect";
  15819. import { Particle } from "babylonjs/Particles/particle";
  15820. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15821. /**
  15822. * Particle emitter emitting particles from the inside of a sphere.
  15823. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15824. */
  15825. export class SphereParticleEmitter implements IParticleEmitterType {
  15826. /**
  15827. * The radius of the emission sphere.
  15828. */
  15829. radius: number;
  15830. /**
  15831. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15832. */
  15833. radiusRange: number;
  15834. /**
  15835. * How much to randomize the particle direction [0-1].
  15836. */
  15837. directionRandomizer: number;
  15838. /**
  15839. * Creates a new instance SphereParticleEmitter
  15840. * @param radius the radius of the emission sphere (1 by default)
  15841. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15843. */
  15844. constructor(
  15845. /**
  15846. * The radius of the emission sphere.
  15847. */
  15848. radius?: number,
  15849. /**
  15850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15851. */
  15852. radiusRange?: number,
  15853. /**
  15854. * How much to randomize the particle direction [0-1].
  15855. */
  15856. directionRandomizer?: number);
  15857. /**
  15858. * Called by the particle System when the direction is computed for the created particle.
  15859. * @param worldMatrix is the world matrix of the particle system
  15860. * @param directionToUpdate is the direction vector to update with the result
  15861. * @param particle is the particle we are computed the direction for
  15862. */
  15863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15864. /**
  15865. * Called by the particle System when the position is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param positionToUpdate is the position vector to update with the result
  15868. * @param particle is the particle we are computed the position for
  15869. */
  15870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): SphereParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "SphereParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. /**
  15903. * Particle emitter emitting particles from the inside of a sphere.
  15904. * It emits the particles randomly between two vectors.
  15905. */
  15906. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15907. /**
  15908. * The min limit of the emission direction.
  15909. */
  15910. direction1: Vector3;
  15911. /**
  15912. * The max limit of the emission direction.
  15913. */
  15914. direction2: Vector3;
  15915. /**
  15916. * Creates a new instance SphereDirectedParticleEmitter
  15917. * @param radius the radius of the emission sphere (1 by default)
  15918. * @param direction1 the min limit of the emission direction (up vector by default)
  15919. * @param direction2 the max limit of the emission direction (up vector by default)
  15920. */
  15921. constructor(radius?: number,
  15922. /**
  15923. * The min limit of the emission direction.
  15924. */
  15925. direction1?: Vector3,
  15926. /**
  15927. * The max limit of the emission direction.
  15928. */
  15929. direction2?: Vector3);
  15930. /**
  15931. * Called by the particle System when the direction is computed for the created particle.
  15932. * @param worldMatrix is the world matrix of the particle system
  15933. * @param directionToUpdate is the direction vector to update with the result
  15934. * @param particle is the particle we are computed the direction for
  15935. */
  15936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15937. /**
  15938. * Clones the current emitter and returns a copy of it
  15939. * @returns the new emitter
  15940. */
  15941. clone(): SphereDirectedParticleEmitter;
  15942. /**
  15943. * Called by the GPUParticleSystem to setup the update shader
  15944. * @param effect defines the update shader
  15945. */
  15946. applyToShader(effect: Effect): void;
  15947. /**
  15948. * Returns a string to use to update the GPU particles update shader
  15949. * @returns a string containng the defines string
  15950. */
  15951. getEffectDefines(): string;
  15952. /**
  15953. * Returns the string "SphereDirectedParticleEmitter"
  15954. * @returns a string containing the class name
  15955. */
  15956. getClassName(): string;
  15957. /**
  15958. * Serializes the particle system to a JSON object.
  15959. * @returns the JSON object
  15960. */
  15961. serialize(): any;
  15962. /**
  15963. * Parse properties from a JSON object
  15964. * @param serializationObject defines the JSON object
  15965. */
  15966. parse(serializationObject: any): void;
  15967. }
  15968. }
  15969. declare module "babylonjs/Particles/EmitterTypes/index" {
  15970. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15971. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15972. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15973. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15974. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15975. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15976. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15977. }
  15978. declare module "babylonjs/Particles/IParticleSystem" {
  15979. import { Nullable } from "babylonjs/types";
  15980. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15983. import { Texture } from "babylonjs/Materials/Textures/texture";
  15984. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15985. import { Scene } from "babylonjs/scene";
  15986. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15987. import { Animation } from "babylonjs/Animations/animation";
  15988. /**
  15989. * Interface representing a particle system in Babylon.js.
  15990. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15991. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15992. */
  15993. export interface IParticleSystem {
  15994. /**
  15995. * List of animations used by the particle system.
  15996. */
  15997. animations: Animation[];
  15998. /**
  15999. * The id of the Particle system.
  16000. */
  16001. id: string;
  16002. /**
  16003. * The name of the Particle system.
  16004. */
  16005. name: string;
  16006. /**
  16007. * The emitter represents the Mesh or position we are attaching the particle system to.
  16008. */
  16009. emitter: Nullable<AbstractMesh | Vector3>;
  16010. /**
  16011. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16012. */
  16013. isBillboardBased: boolean;
  16014. /**
  16015. * The rendering group used by the Particle system to chose when to render.
  16016. */
  16017. renderingGroupId: number;
  16018. /**
  16019. * The layer mask we are rendering the particles through.
  16020. */
  16021. layerMask: number;
  16022. /**
  16023. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16024. */
  16025. updateSpeed: number;
  16026. /**
  16027. * The amount of time the particle system is running (depends of the overall update speed).
  16028. */
  16029. targetStopDuration: number;
  16030. /**
  16031. * The texture used to render each particle. (this can be a spritesheet)
  16032. */
  16033. particleTexture: Nullable<Texture>;
  16034. /**
  16035. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16036. */
  16037. blendMode: number;
  16038. /**
  16039. * Minimum life time of emitting particles.
  16040. */
  16041. minLifeTime: number;
  16042. /**
  16043. * Maximum life time of emitting particles.
  16044. */
  16045. maxLifeTime: number;
  16046. /**
  16047. * Minimum Size of emitting particles.
  16048. */
  16049. minSize: number;
  16050. /**
  16051. * Maximum Size of emitting particles.
  16052. */
  16053. maxSize: number;
  16054. /**
  16055. * Minimum scale of emitting particles on X axis.
  16056. */
  16057. minScaleX: number;
  16058. /**
  16059. * Maximum scale of emitting particles on X axis.
  16060. */
  16061. maxScaleX: number;
  16062. /**
  16063. * Minimum scale of emitting particles on Y axis.
  16064. */
  16065. minScaleY: number;
  16066. /**
  16067. * Maximum scale of emitting particles on Y axis.
  16068. */
  16069. maxScaleY: number;
  16070. /**
  16071. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16072. */
  16073. color1: Color4;
  16074. /**
  16075. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16076. */
  16077. color2: Color4;
  16078. /**
  16079. * Color the particle will have at the end of its lifetime.
  16080. */
  16081. colorDead: Color4;
  16082. /**
  16083. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16084. */
  16085. emitRate: number;
  16086. /**
  16087. * You can use gravity if you want to give an orientation to your particles.
  16088. */
  16089. gravity: Vector3;
  16090. /**
  16091. * Minimum power of emitting particles.
  16092. */
  16093. minEmitPower: number;
  16094. /**
  16095. * Maximum power of emitting particles.
  16096. */
  16097. maxEmitPower: number;
  16098. /**
  16099. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16100. */
  16101. minAngularSpeed: number;
  16102. /**
  16103. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16104. */
  16105. maxAngularSpeed: number;
  16106. /**
  16107. * Gets or sets the minimal initial rotation in radians.
  16108. */
  16109. minInitialRotation: number;
  16110. /**
  16111. * Gets or sets the maximal initial rotation in radians.
  16112. */
  16113. maxInitialRotation: number;
  16114. /**
  16115. * The particle emitter type defines the emitter used by the particle system.
  16116. * It can be for example box, sphere, or cone...
  16117. */
  16118. particleEmitterType: Nullable<IParticleEmitterType>;
  16119. /**
  16120. * Defines the delay in milliseconds before starting the system (0 by default)
  16121. */
  16122. startDelay: number;
  16123. /**
  16124. * 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
  16125. */
  16126. preWarmCycles: number;
  16127. /**
  16128. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16129. */
  16130. preWarmStepOffset: number;
  16131. /**
  16132. * 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)
  16133. */
  16134. spriteCellChangeSpeed: number;
  16135. /**
  16136. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16137. */
  16138. startSpriteCellID: number;
  16139. /**
  16140. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16141. */
  16142. endSpriteCellID: number;
  16143. /**
  16144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16145. */
  16146. spriteCellWidth: number;
  16147. /**
  16148. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16149. */
  16150. spriteCellHeight: number;
  16151. /**
  16152. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16153. */
  16154. spriteRandomStartCell: boolean;
  16155. /**
  16156. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16157. */
  16158. isAnimationSheetEnabled: boolean;
  16159. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16160. translationPivot: Vector2;
  16161. /**
  16162. * Gets or sets a texture used to add random noise to particle positions
  16163. */
  16164. noiseTexture: Nullable<BaseTexture>;
  16165. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16166. noiseStrength: Vector3;
  16167. /**
  16168. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16169. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16170. */
  16171. billboardMode: number;
  16172. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16173. limitVelocityDamping: number;
  16174. /**
  16175. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16176. */
  16177. beginAnimationOnStart: boolean;
  16178. /**
  16179. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16180. */
  16181. beginAnimationFrom: number;
  16182. /**
  16183. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16184. */
  16185. beginAnimationTo: number;
  16186. /**
  16187. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16188. */
  16189. beginAnimationLoop: boolean;
  16190. /**
  16191. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16192. */
  16193. disposeOnStop: boolean;
  16194. /**
  16195. * Gets the maximum number of particles active at the same time.
  16196. * @returns The max number of active particles.
  16197. */
  16198. getCapacity(): number;
  16199. /**
  16200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16201. * @returns True if it has been started, otherwise false.
  16202. */
  16203. isStarted(): boolean;
  16204. /**
  16205. * Animates the particle system for this frame.
  16206. */
  16207. animate(): void;
  16208. /**
  16209. * Renders the particle system in its current state.
  16210. * @returns the current number of particles
  16211. */
  16212. render(): number;
  16213. /**
  16214. * Dispose the particle system and frees its associated resources.
  16215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16216. */
  16217. dispose(disposeTexture?: boolean): void;
  16218. /**
  16219. * Clones the particle system.
  16220. * @param name The name of the cloned object
  16221. * @param newEmitter The new emitter to use
  16222. * @returns the cloned particle system
  16223. */
  16224. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16225. /**
  16226. * Serializes the particle system to a JSON object.
  16227. * @returns the JSON object
  16228. */
  16229. serialize(): any;
  16230. /**
  16231. * Rebuild the particle system
  16232. */
  16233. rebuild(): void;
  16234. /**
  16235. * Starts the particle system and begins to emit
  16236. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16237. */
  16238. start(delay?: number): void;
  16239. /**
  16240. * Stops the particle system.
  16241. */
  16242. stop(): void;
  16243. /**
  16244. * Remove all active particles
  16245. */
  16246. reset(): void;
  16247. /**
  16248. * Is this system ready to be used/rendered
  16249. * @return true if the system is ready
  16250. */
  16251. isReady(): boolean;
  16252. /**
  16253. * Adds a new color gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param color1 defines the color to affect to the specified gradient
  16256. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16257. * @returns the current particle system
  16258. */
  16259. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16260. /**
  16261. * Remove a specific color gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeColorGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Adds a new size gradient
  16268. * @param gradient defines the gradient to use (between 0 and 1)
  16269. * @param factor defines the size factor to affect to the specified gradient
  16270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16271. * @returns the current particle system
  16272. */
  16273. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16274. /**
  16275. * Remove a specific size gradient
  16276. * @param gradient defines the gradient to remove
  16277. * @returns the current particle system
  16278. */
  16279. removeSizeGradient(gradient: number): IParticleSystem;
  16280. /**
  16281. * Gets the current list of color gradients.
  16282. * You must use addColorGradient and removeColorGradient to udpate this list
  16283. * @returns the list of color gradients
  16284. */
  16285. getColorGradients(): Nullable<Array<ColorGradient>>;
  16286. /**
  16287. * Gets the current list of size gradients.
  16288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16289. * @returns the list of size gradients
  16290. */
  16291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16292. /**
  16293. * Gets the current list of angular speed gradients.
  16294. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16295. * @returns the list of angular speed gradients
  16296. */
  16297. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16298. /**
  16299. * Adds a new angular speed gradient
  16300. * @param gradient defines the gradient to use (between 0 and 1)
  16301. * @param factor defines the angular speed to affect to the specified gradient
  16302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16303. * @returns the current particle system
  16304. */
  16305. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16306. /**
  16307. * Remove a specific angular speed gradient
  16308. * @param gradient defines the gradient to remove
  16309. * @returns the current particle system
  16310. */
  16311. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16312. /**
  16313. * Gets the current list of velocity gradients.
  16314. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16315. * @returns the list of velocity gradients
  16316. */
  16317. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16318. /**
  16319. * Adds a new velocity gradient
  16320. * @param gradient defines the gradient to use (between 0 and 1)
  16321. * @param factor defines the velocity to affect to the specified gradient
  16322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16323. * @returns the current particle system
  16324. */
  16325. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16326. /**
  16327. * Remove a specific velocity gradient
  16328. * @param gradient defines the gradient to remove
  16329. * @returns the current particle system
  16330. */
  16331. removeVelocityGradient(gradient: number): IParticleSystem;
  16332. /**
  16333. * Gets the current list of limit velocity gradients.
  16334. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16335. * @returns the list of limit velocity gradients
  16336. */
  16337. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16338. /**
  16339. * Adds a new limit velocity gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the limit velocity to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific limit velocity gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Adds a new drag gradient
  16354. * @param gradient defines the gradient to use (between 0 and 1)
  16355. * @param factor defines the drag to affect to the specified gradient
  16356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16357. * @returns the current particle system
  16358. */
  16359. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16360. /**
  16361. * Remove a specific drag gradient
  16362. * @param gradient defines the gradient to remove
  16363. * @returns the current particle system
  16364. */
  16365. removeDragGradient(gradient: number): IParticleSystem;
  16366. /**
  16367. * Gets the current list of drag gradients.
  16368. * You must use addDragGradient and removeDragGradient to udpate this list
  16369. * @returns the list of drag gradients
  16370. */
  16371. getDragGradients(): Nullable<Array<FactorGradient>>;
  16372. /**
  16373. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16374. * @param gradient defines the gradient to use (between 0 and 1)
  16375. * @param factor defines the emit rate to affect to the specified gradient
  16376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16377. * @returns the current particle system
  16378. */
  16379. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16380. /**
  16381. * Remove a specific emit rate gradient
  16382. * @param gradient defines the gradient to remove
  16383. * @returns the current particle system
  16384. */
  16385. removeEmitRateGradient(gradient: number): IParticleSystem;
  16386. /**
  16387. * Gets the current list of emit rate gradients.
  16388. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16389. * @returns the list of emit rate gradients
  16390. */
  16391. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16392. /**
  16393. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16394. * @param gradient defines the gradient to use (between 0 and 1)
  16395. * @param factor defines the start size to affect to the specified gradient
  16396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16397. * @returns the current particle system
  16398. */
  16399. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16400. /**
  16401. * Remove a specific start size gradient
  16402. * @param gradient defines the gradient to remove
  16403. * @returns the current particle system
  16404. */
  16405. removeStartSizeGradient(gradient: number): IParticleSystem;
  16406. /**
  16407. * Gets the current list of start size gradients.
  16408. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16409. * @returns the list of start size gradients
  16410. */
  16411. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16412. /**
  16413. * Adds a new life time gradient
  16414. * @param gradient defines the gradient to use (between 0 and 1)
  16415. * @param factor defines the life time factor to affect to the specified gradient
  16416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16417. * @returns the current particle system
  16418. */
  16419. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16420. /**
  16421. * Remove a specific life time gradient
  16422. * @param gradient defines the gradient to remove
  16423. * @returns the current particle system
  16424. */
  16425. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16426. /**
  16427. * Gets the current list of life time gradients.
  16428. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16429. * @returns the list of life time gradients
  16430. */
  16431. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16432. /**
  16433. * Gets the current list of color gradients.
  16434. * You must use addColorGradient and removeColorGradient to udpate this list
  16435. * @returns the list of color gradients
  16436. */
  16437. getColorGradients(): Nullable<Array<ColorGradient>>;
  16438. /**
  16439. * Adds a new ramp gradient used to remap particle colors
  16440. * @param gradient defines the gradient to use (between 0 and 1)
  16441. * @param color defines the color to affect to the specified gradient
  16442. * @returns the current particle system
  16443. */
  16444. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16445. /**
  16446. * Gets the current list of ramp gradients.
  16447. * You must use addRampGradient and removeRampGradient to udpate this list
  16448. * @returns the list of ramp gradients
  16449. */
  16450. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16451. /** Gets or sets a boolean indicating that ramp gradients must be used
  16452. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16453. */
  16454. useRampGradients: boolean;
  16455. /**
  16456. * Adds a new color remap gradient
  16457. * @param gradient defines the gradient to use (between 0 and 1)
  16458. * @param min defines the color remap minimal range
  16459. * @param max defines the color remap maximal range
  16460. * @returns the current particle system
  16461. */
  16462. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16463. /**
  16464. * Gets the current list of color remap gradients.
  16465. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16466. * @returns the list of color remap gradients
  16467. */
  16468. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16469. /**
  16470. * Adds a new alpha remap gradient
  16471. * @param gradient defines the gradient to use (between 0 and 1)
  16472. * @param min defines the alpha remap minimal range
  16473. * @param max defines the alpha remap maximal range
  16474. * @returns the current particle system
  16475. */
  16476. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16477. /**
  16478. * Gets the current list of alpha remap gradients.
  16479. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16480. * @returns the list of alpha remap gradients
  16481. */
  16482. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16483. /**
  16484. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16487. * @returns the emitter
  16488. */
  16489. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16490. /**
  16491. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16492. * @param radius The radius of the hemisphere to emit from
  16493. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16494. * @returns the emitter
  16495. */
  16496. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16497. /**
  16498. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16499. * @param radius The radius of the sphere to emit from
  16500. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16501. * @returns the emitter
  16502. */
  16503. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16504. /**
  16505. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16506. * @param radius The radius of the sphere to emit from
  16507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16509. * @returns the emitter
  16510. */
  16511. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16512. /**
  16513. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16514. * @param radius The radius of the emission cylinder
  16515. * @param height The height of the emission cylinder
  16516. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16517. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16518. * @returns the emitter
  16519. */
  16520. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16521. /**
  16522. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16523. * @param radius The radius of the cylinder to emit from
  16524. * @param height The height of the emission cylinder
  16525. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16528. * @returns the emitter
  16529. */
  16530. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16531. /**
  16532. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16533. * @param radius The radius of the cone to emit from
  16534. * @param angle The base angle of the cone
  16535. * @returns the emitter
  16536. */
  16537. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16538. /**
  16539. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16542. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16543. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16544. * @returns the emitter
  16545. */
  16546. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16547. /**
  16548. * Get hosting scene
  16549. * @returns the scene
  16550. */
  16551. getScene(): Scene;
  16552. }
  16553. }
  16554. declare module "babylonjs/Meshes/instancedMesh" {
  16555. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16556. import { Vector3 } from "babylonjs/Maths/math";
  16557. import { Camera } from "babylonjs/Cameras/camera";
  16558. import { Node } from "babylonjs/node";
  16559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16560. import { Mesh } from "babylonjs/Meshes/mesh";
  16561. import { Material } from "babylonjs/Materials/material";
  16562. import { Skeleton } from "babylonjs/Bones/skeleton";
  16563. /**
  16564. * Creates an instance based on a source mesh.
  16565. */
  16566. export class InstancedMesh extends AbstractMesh {
  16567. private _sourceMesh;
  16568. private _currentLOD;
  16569. /** @hidden */
  16570. _indexInSourceMeshInstanceArray: number;
  16571. constructor(name: string, source: Mesh);
  16572. /**
  16573. * Returns the string "InstancedMesh".
  16574. */
  16575. getClassName(): string;
  16576. /**
  16577. * If the source mesh receives shadows
  16578. */
  16579. readonly receiveShadows: boolean;
  16580. /**
  16581. * The material of the source mesh
  16582. */
  16583. readonly material: Nullable<Material>;
  16584. /**
  16585. * Visibility of the source mesh
  16586. */
  16587. readonly visibility: number;
  16588. /**
  16589. * Skeleton of the source mesh
  16590. */
  16591. readonly skeleton: Nullable<Skeleton>;
  16592. /**
  16593. * Rendering ground id of the source mesh
  16594. */
  16595. renderingGroupId: number;
  16596. /**
  16597. * Returns the total number of vertices (integer).
  16598. */
  16599. getTotalVertices(): number;
  16600. /**
  16601. * Returns a positive integer : the total number of indices in this mesh geometry.
  16602. * @returns the numner of indices or zero if the mesh has no geometry.
  16603. */
  16604. getTotalIndices(): number;
  16605. /**
  16606. * The source mesh of the instance
  16607. */
  16608. readonly sourceMesh: Mesh;
  16609. /**
  16610. * Is this node ready to be used/rendered
  16611. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16612. * @return {boolean} is it ready
  16613. */
  16614. isReady(completeCheck?: boolean): boolean;
  16615. /**
  16616. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16617. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16618. * @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.
  16619. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16620. */
  16621. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16622. /**
  16623. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16624. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16625. * The `data` are either a numeric array either a Float32Array.
  16626. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16627. * 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).
  16628. * Note that a new underlying VertexBuffer object is created each call.
  16629. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16630. *
  16631. * Possible `kind` values :
  16632. * - VertexBuffer.PositionKind
  16633. * - VertexBuffer.UVKind
  16634. * - VertexBuffer.UV2Kind
  16635. * - VertexBuffer.UV3Kind
  16636. * - VertexBuffer.UV4Kind
  16637. * - VertexBuffer.UV5Kind
  16638. * - VertexBuffer.UV6Kind
  16639. * - VertexBuffer.ColorKind
  16640. * - VertexBuffer.MatricesIndicesKind
  16641. * - VertexBuffer.MatricesIndicesExtraKind
  16642. * - VertexBuffer.MatricesWeightsKind
  16643. * - VertexBuffer.MatricesWeightsExtraKind
  16644. *
  16645. * Returns the Mesh.
  16646. */
  16647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16648. /**
  16649. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16650. * If the mesh has no geometry, it is simply returned as it is.
  16651. * The `data` are either a numeric array either a Float32Array.
  16652. * No new underlying VertexBuffer object is created.
  16653. * 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.
  16654. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16655. *
  16656. * Possible `kind` values :
  16657. * - VertexBuffer.PositionKind
  16658. * - VertexBuffer.UVKind
  16659. * - VertexBuffer.UV2Kind
  16660. * - VertexBuffer.UV3Kind
  16661. * - VertexBuffer.UV4Kind
  16662. * - VertexBuffer.UV5Kind
  16663. * - VertexBuffer.UV6Kind
  16664. * - VertexBuffer.ColorKind
  16665. * - VertexBuffer.MatricesIndicesKind
  16666. * - VertexBuffer.MatricesIndicesExtraKind
  16667. * - VertexBuffer.MatricesWeightsKind
  16668. * - VertexBuffer.MatricesWeightsExtraKind
  16669. *
  16670. * Returns the Mesh.
  16671. */
  16672. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16673. /**
  16674. * Sets the mesh indices.
  16675. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16677. * This method creates a new index buffer each call.
  16678. * Returns the Mesh.
  16679. */
  16680. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16681. /**
  16682. * Boolean : True if the mesh owns the requested kind of data.
  16683. */
  16684. isVerticesDataPresent(kind: string): boolean;
  16685. /**
  16686. * Returns an array of indices (IndicesArray).
  16687. */
  16688. getIndices(): Nullable<IndicesArray>;
  16689. readonly _positions: Nullable<Vector3[]>;
  16690. /**
  16691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16692. * This means the mesh underlying bounding box and sphere are recomputed.
  16693. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16694. * @returns the current mesh
  16695. */
  16696. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16697. /** @hidden */
  16698. _preActivate(): InstancedMesh;
  16699. /** @hidden */
  16700. _activate(renderId: number): InstancedMesh;
  16701. /**
  16702. * Returns the current associated LOD AbstractMesh.
  16703. */
  16704. getLOD(camera: Camera): AbstractMesh;
  16705. /** @hidden */
  16706. _syncSubMeshes(): InstancedMesh;
  16707. /** @hidden */
  16708. _generatePointsArray(): boolean;
  16709. /**
  16710. * Creates a new InstancedMesh from the current mesh.
  16711. * - name (string) : the cloned mesh name
  16712. * - newParent (optional Node) : the optional Node to parent the clone to.
  16713. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16714. *
  16715. * Returns the clone.
  16716. */
  16717. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16718. /**
  16719. * Disposes the InstancedMesh.
  16720. * Returns nothing.
  16721. */
  16722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Materials/shaderMaterial" {
  16726. import { Scene } from "babylonjs/scene";
  16727. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16729. import { Mesh } from "babylonjs/Meshes/mesh";
  16730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16731. import { Texture } from "babylonjs/Materials/Textures/texture";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. /**
  16734. * Defines the options associated with the creation of a shader material.
  16735. */
  16736. export interface IShaderMaterialOptions {
  16737. /**
  16738. * Does the material work in alpha blend mode
  16739. */
  16740. needAlphaBlending: boolean;
  16741. /**
  16742. * Does the material work in alpha test mode
  16743. */
  16744. needAlphaTesting: boolean;
  16745. /**
  16746. * The list of attribute names used in the shader
  16747. */
  16748. attributes: string[];
  16749. /**
  16750. * The list of unifrom names used in the shader
  16751. */
  16752. uniforms: string[];
  16753. /**
  16754. * The list of UBO names used in the shader
  16755. */
  16756. uniformBuffers: string[];
  16757. /**
  16758. * The list of sampler names used in the shader
  16759. */
  16760. samplers: string[];
  16761. /**
  16762. * The list of defines used in the shader
  16763. */
  16764. defines: string[];
  16765. }
  16766. /**
  16767. * 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.
  16768. *
  16769. * This returned material effects how the mesh will look based on the code in the shaders.
  16770. *
  16771. * @see http://doc.babylonjs.com/how_to/shader_material
  16772. */
  16773. export class ShaderMaterial extends Material {
  16774. private _shaderPath;
  16775. private _options;
  16776. private _textures;
  16777. private _textureArrays;
  16778. private _floats;
  16779. private _ints;
  16780. private _floatsArrays;
  16781. private _colors3;
  16782. private _colors3Arrays;
  16783. private _colors4;
  16784. private _vectors2;
  16785. private _vectors3;
  16786. private _vectors4;
  16787. private _matrices;
  16788. private _matrices3x3;
  16789. private _matrices2x2;
  16790. private _vectors2Arrays;
  16791. private _vectors3Arrays;
  16792. private _cachedWorldViewMatrix;
  16793. private _renderId;
  16794. /**
  16795. * Instantiate a new shader material.
  16796. * 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.
  16797. * This returned material effects how the mesh will look based on the code in the shaders.
  16798. * @see http://doc.babylonjs.com/how_to/shader_material
  16799. * @param name Define the name of the material in the scene
  16800. * @param scene Define the scene the material belongs to
  16801. * @param shaderPath Defines the route to the shader code in one of three ways:
  16802. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16803. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16804. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16805. * @param options Define the options used to create the shader
  16806. */
  16807. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16808. /**
  16809. * Gets the current class name of the material e.g. "ShaderMaterial"
  16810. * Mainly use in serialization.
  16811. * @returns the class name
  16812. */
  16813. getClassName(): string;
  16814. /**
  16815. * Specifies if the material will require alpha blending
  16816. * @returns a boolean specifying if alpha blending is needed
  16817. */
  16818. needAlphaBlending(): boolean;
  16819. /**
  16820. * Specifies if this material should be rendered in alpha test mode
  16821. * @returns a boolean specifying if an alpha test is needed.
  16822. */
  16823. needAlphaTesting(): boolean;
  16824. private _checkUniform;
  16825. /**
  16826. * Set a texture in the shader.
  16827. * @param name Define the name of the uniform samplers as defined in the shader
  16828. * @param texture Define the texture to bind to this sampler
  16829. * @return the material itself allowing "fluent" like uniform updates
  16830. */
  16831. setTexture(name: string, texture: Texture): ShaderMaterial;
  16832. /**
  16833. * Set a texture array in the shader.
  16834. * @param name Define the name of the uniform sampler array as defined in the shader
  16835. * @param textures Define the list of textures to bind to this sampler
  16836. * @return the material itself allowing "fluent" like uniform updates
  16837. */
  16838. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16839. /**
  16840. * Set a float in the shader.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the material itself allowing "fluent" like uniform updates
  16844. */
  16845. setFloat(name: string, value: number): ShaderMaterial;
  16846. /**
  16847. * Set a int in the shader.
  16848. * @param name Define the name of the uniform as defined in the shader
  16849. * @param value Define the value to give to the uniform
  16850. * @return the material itself allowing "fluent" like uniform updates
  16851. */
  16852. setInt(name: string, value: number): ShaderMaterial;
  16853. /**
  16854. * Set an array of floats in the shader.
  16855. * @param name Define the name of the uniform as defined in the shader
  16856. * @param value Define the value to give to the uniform
  16857. * @return the material itself allowing "fluent" like uniform updates
  16858. */
  16859. setFloats(name: string, value: number[]): ShaderMaterial;
  16860. /**
  16861. * Set a vec3 in the shader from a Color3.
  16862. * @param name Define the name of the uniform as defined in the shader
  16863. * @param value Define the value to give to the uniform
  16864. * @return the material itself allowing "fluent" like uniform updates
  16865. */
  16866. setColor3(name: string, value: Color3): ShaderMaterial;
  16867. /**
  16868. * Set a vec3 array in the shader from a Color3 array.
  16869. * @param name Define the name of the uniform as defined in the shader
  16870. * @param value Define the value to give to the uniform
  16871. * @return the material itself allowing "fluent" like uniform updates
  16872. */
  16873. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16874. /**
  16875. * Set a vec4 in the shader from a Color4.
  16876. * @param name Define the name of the uniform as defined in the shader
  16877. * @param value Define the value to give to the uniform
  16878. * @return the material itself allowing "fluent" like uniform updates
  16879. */
  16880. setColor4(name: string, value: Color4): ShaderMaterial;
  16881. /**
  16882. * Set a vec2 in the shader from a Vector2.
  16883. * @param name Define the name of the uniform as defined in the shader
  16884. * @param value Define the value to give to the uniform
  16885. * @return the material itself allowing "fluent" like uniform updates
  16886. */
  16887. setVector2(name: string, value: Vector2): ShaderMaterial;
  16888. /**
  16889. * Set a vec3 in the shader from a Vector3.
  16890. * @param name Define the name of the uniform as defined in the shader
  16891. * @param value Define the value to give to the uniform
  16892. * @return the material itself allowing "fluent" like uniform updates
  16893. */
  16894. setVector3(name: string, value: Vector3): ShaderMaterial;
  16895. /**
  16896. * Set a vec4 in the shader from a Vector4.
  16897. * @param name Define the name of the uniform as defined in the shader
  16898. * @param value Define the value to give to the uniform
  16899. * @return the material itself allowing "fluent" like uniform updates
  16900. */
  16901. setVector4(name: string, value: Vector4): ShaderMaterial;
  16902. /**
  16903. * Set a mat4 in the shader from a Matrix.
  16904. * @param name Define the name of the uniform as defined in the shader
  16905. * @param value Define the value to give to the uniform
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16909. /**
  16910. * Set a mat3 in the shader from a Float32Array.
  16911. * @param name Define the name of the uniform as defined in the shader
  16912. * @param value Define the value to give to the uniform
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16916. /**
  16917. * Set a mat2 in the shader from a Float32Array.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16923. /**
  16924. * Set a vec2 array in the shader from a number array.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setArray2(name: string, value: number[]): ShaderMaterial;
  16930. /**
  16931. * Set a vec3 array in the shader from a number array.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setArray3(name: string, value: number[]): ShaderMaterial;
  16937. private _checkCache;
  16938. /**
  16939. * Checks if the material is ready to render the requested mesh
  16940. * @param mesh Define the mesh to render
  16941. * @param useInstances Define whether or not the material is used with instances
  16942. * @returns true if ready, otherwise false
  16943. */
  16944. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16945. /**
  16946. * Binds the world matrix to the material
  16947. * @param world defines the world transformation matrix
  16948. */
  16949. bindOnlyWorldMatrix(world: Matrix): void;
  16950. /**
  16951. * Binds the material to the mesh
  16952. * @param world defines the world transformation matrix
  16953. * @param mesh defines the mesh to bind the material to
  16954. */
  16955. bind(world: Matrix, mesh?: Mesh): void;
  16956. /**
  16957. * Gets the active textures from the material
  16958. * @returns an array of textures
  16959. */
  16960. getActiveTextures(): BaseTexture[];
  16961. /**
  16962. * Specifies if the material uses a texture
  16963. * @param texture defines the texture to check against the material
  16964. * @returns a boolean specifying if the material uses the texture
  16965. */
  16966. hasTexture(texture: BaseTexture): boolean;
  16967. /**
  16968. * Makes a duplicate of the material, and gives it a new name
  16969. * @param name defines the new name for the duplicated material
  16970. * @returns the cloned material
  16971. */
  16972. clone(name: string): ShaderMaterial;
  16973. /**
  16974. * Disposes the material
  16975. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16976. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16977. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16978. */
  16979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16980. /**
  16981. * Serializes this material in a JSON representation
  16982. * @returns the serialized material object
  16983. */
  16984. serialize(): any;
  16985. /**
  16986. * Creates a shader material from parsed shader material data
  16987. * @param source defines the JSON represnetation of the material
  16988. * @param scene defines the hosting scene
  16989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16990. * @returns a new material
  16991. */
  16992. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16993. }
  16994. }
  16995. declare module "babylonjs/Shaders/color.fragment" {
  16996. /** @hidden */
  16997. export var colorPixelShader: {
  16998. name: string;
  16999. shader: string;
  17000. };
  17001. }
  17002. declare module "babylonjs/Shaders/color.vertex" {
  17003. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17007. /** @hidden */
  17008. export var colorVertexShader: {
  17009. name: string;
  17010. shader: string;
  17011. };
  17012. }
  17013. declare module "babylonjs/Meshes/linesMesh" {
  17014. import { Nullable } from "babylonjs/types";
  17015. import { Scene } from "babylonjs/scene";
  17016. import { Color3 } from "babylonjs/Maths/math";
  17017. import { Node } from "babylonjs/node";
  17018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17019. import { Mesh } from "babylonjs/Meshes/mesh";
  17020. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17021. import { Effect } from "babylonjs/Materials/effect";
  17022. import { Material } from "babylonjs/Materials/material";
  17023. import "babylonjs/Shaders/color.fragment";
  17024. import "babylonjs/Shaders/color.vertex";
  17025. /**
  17026. * Line mesh
  17027. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17028. */
  17029. export class LinesMesh extends Mesh {
  17030. /**
  17031. * If vertex color should be applied to the mesh
  17032. */
  17033. useVertexColor?: boolean | undefined;
  17034. /**
  17035. * If vertex alpha should be applied to the mesh
  17036. */
  17037. useVertexAlpha?: boolean | undefined;
  17038. /**
  17039. * Color of the line (Default: White)
  17040. */
  17041. color: Color3;
  17042. /**
  17043. * Alpha of the line (Default: 1)
  17044. */
  17045. alpha: number;
  17046. /**
  17047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17048. * This margin is expressed in world space coordinates, so its value may vary.
  17049. * Default value is 0.1
  17050. */
  17051. intersectionThreshold: number;
  17052. private _colorShader;
  17053. /**
  17054. * Creates a new LinesMesh
  17055. * @param name defines the name
  17056. * @param scene defines the hosting scene
  17057. * @param parent defines the parent mesh if any
  17058. * @param source defines the optional source LinesMesh used to clone data from
  17059. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17060. * When false, achieved by calling a clone(), also passing False.
  17061. * This will make creation of children, recursive.
  17062. * @param useVertexColor defines if this LinesMesh supports vertex color
  17063. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17064. */
  17065. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17066. /**
  17067. * If vertex color should be applied to the mesh
  17068. */
  17069. useVertexColor?: boolean | undefined,
  17070. /**
  17071. * If vertex alpha should be applied to the mesh
  17072. */
  17073. useVertexAlpha?: boolean | undefined);
  17074. /**
  17075. * Returns the string "LineMesh"
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * @hidden
  17080. */
  17081. /**
  17082. * @hidden
  17083. */
  17084. material: Material;
  17085. /**
  17086. * @hidden
  17087. */
  17088. readonly checkCollisions: boolean;
  17089. /** @hidden */
  17090. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17091. /** @hidden */
  17092. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17093. /**
  17094. * Disposes of the line mesh
  17095. * @param doNotRecurse If children should be disposed
  17096. */
  17097. dispose(doNotRecurse?: boolean): void;
  17098. /**
  17099. * Returns a new LineMesh object cloned from the current one.
  17100. */
  17101. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17102. /**
  17103. * Creates a new InstancedLinesMesh object from the mesh model.
  17104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17105. * @param name defines the name of the new instance
  17106. * @returns a new InstancedLinesMesh
  17107. */
  17108. createInstance(name: string): InstancedLinesMesh;
  17109. }
  17110. /**
  17111. * Creates an instance based on a source LinesMesh
  17112. */
  17113. export class InstancedLinesMesh extends InstancedMesh {
  17114. /**
  17115. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17116. * This margin is expressed in world space coordinates, so its value may vary.
  17117. * Initilized with the intersectionThreshold value of the source LinesMesh
  17118. */
  17119. intersectionThreshold: number;
  17120. constructor(name: string, source: LinesMesh);
  17121. /**
  17122. * Returns the string "InstancedLinesMesh".
  17123. */
  17124. getClassName(): string;
  17125. }
  17126. }
  17127. declare module "babylonjs/Shaders/line.fragment" {
  17128. /** @hidden */
  17129. export var linePixelShader: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/line.vertex" {
  17135. /** @hidden */
  17136. export var lineVertexShader: {
  17137. name: string;
  17138. shader: string;
  17139. };
  17140. }
  17141. declare module "babylonjs/Rendering/edgesRenderer" {
  17142. import { Nullable } from "babylonjs/types";
  17143. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17145. import { Vector3 } from "babylonjs/Maths/math";
  17146. import { IDisposable } from "babylonjs/scene";
  17147. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17148. import "babylonjs/Shaders/line.fragment";
  17149. import "babylonjs/Shaders/line.vertex";
  17150. module "babylonjs/Meshes/abstractMesh" {
  17151. interface AbstractMesh {
  17152. /**
  17153. * Disables the mesh edge rendering mode
  17154. * @returns the currentAbstractMesh
  17155. */
  17156. disableEdgesRendering(): AbstractMesh;
  17157. /**
  17158. * Enables the edge rendering mode on the mesh.
  17159. * This mode makes the mesh edges visible
  17160. * @param epsilon defines the maximal distance between two angles to detect a face
  17161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17162. * @returns the currentAbstractMesh
  17163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17164. */
  17165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17166. /**
  17167. * Gets the edgesRenderer associated with the mesh
  17168. */
  17169. edgesRenderer: Nullable<EdgesRenderer>;
  17170. }
  17171. }
  17172. module "babylonjs/Meshes/linesMesh" {
  17173. interface LinesMesh {
  17174. /**
  17175. * Enables the edge rendering mode on the mesh.
  17176. * This mode makes the mesh edges visible
  17177. * @param epsilon defines the maximal distance between two angles to detect a face
  17178. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17179. * @returns the currentAbstractMesh
  17180. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17181. */
  17182. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17183. }
  17184. }
  17185. module "babylonjs/Meshes/linesMesh" {
  17186. interface InstancedLinesMesh {
  17187. /**
  17188. * Enables the edge rendering mode on the mesh.
  17189. * This mode makes the mesh edges visible
  17190. * @param epsilon defines the maximal distance between two angles to detect a face
  17191. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17192. * @returns the current InstancedLinesMesh
  17193. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17194. */
  17195. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17196. }
  17197. }
  17198. /**
  17199. * Defines the minimum contract an Edges renderer should follow.
  17200. */
  17201. export interface IEdgesRenderer extends IDisposable {
  17202. /**
  17203. * Gets or sets a boolean indicating if the edgesRenderer is active
  17204. */
  17205. isEnabled: boolean;
  17206. /**
  17207. * Renders the edges of the attached mesh,
  17208. */
  17209. render(): void;
  17210. /**
  17211. * Checks wether or not the edges renderer is ready to render.
  17212. * @return true if ready, otherwise false.
  17213. */
  17214. isReady(): boolean;
  17215. }
  17216. /**
  17217. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17218. */
  17219. export class EdgesRenderer implements IEdgesRenderer {
  17220. /**
  17221. * Define the size of the edges with an orthographic camera
  17222. */
  17223. edgesWidthScalerForOrthographic: number;
  17224. /**
  17225. * Define the size of the edges with a perspective camera
  17226. */
  17227. edgesWidthScalerForPerspective: number;
  17228. protected _source: AbstractMesh;
  17229. protected _linesPositions: number[];
  17230. protected _linesNormals: number[];
  17231. protected _linesIndices: number[];
  17232. protected _epsilon: number;
  17233. protected _indicesCount: number;
  17234. protected _lineShader: ShaderMaterial;
  17235. protected _ib: WebGLBuffer;
  17236. protected _buffers: {
  17237. [key: string]: Nullable<VertexBuffer>;
  17238. };
  17239. protected _checkVerticesInsteadOfIndices: boolean;
  17240. private _meshRebuildObserver;
  17241. private _meshDisposeObserver;
  17242. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17243. isEnabled: boolean;
  17244. /**
  17245. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17246. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17247. * @param source Mesh used to create edges
  17248. * @param epsilon sum of angles in adjacency to check for edge
  17249. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17250. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17251. */
  17252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17253. protected _prepareRessources(): void;
  17254. /** @hidden */
  17255. _rebuild(): void;
  17256. /**
  17257. * Releases the required resources for the edges renderer
  17258. */
  17259. dispose(): void;
  17260. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17261. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17262. /**
  17263. * Checks if the pair of p0 and p1 is en edge
  17264. * @param faceIndex
  17265. * @param edge
  17266. * @param faceNormals
  17267. * @param p0
  17268. * @param p1
  17269. * @private
  17270. */
  17271. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17272. /**
  17273. * push line into the position, normal and index buffer
  17274. * @protected
  17275. */
  17276. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17277. /**
  17278. * Generates lines edges from adjacencjes
  17279. * @private
  17280. */
  17281. _generateEdgesLines(): void;
  17282. /**
  17283. * Checks wether or not the edges renderer is ready to render.
  17284. * @return true if ready, otherwise false.
  17285. */
  17286. isReady(): boolean;
  17287. /**
  17288. * Renders the edges of the attached mesh,
  17289. */
  17290. render(): void;
  17291. }
  17292. /**
  17293. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17294. */
  17295. export class LineEdgesRenderer extends EdgesRenderer {
  17296. /**
  17297. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17298. * @param source LineMesh used to generate edges
  17299. * @param epsilon not important (specified angle for edge detection)
  17300. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17301. */
  17302. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17303. /**
  17304. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17305. */
  17306. _generateEdgesLines(): void;
  17307. }
  17308. }
  17309. declare module "babylonjs/Rendering/renderingGroup" {
  17310. import { SmartArray } from "babylonjs/Misc/smartArray";
  17311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17313. import { Nullable } from "babylonjs/types";
  17314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17315. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17316. import { Material } from "babylonjs/Materials/material";
  17317. import { Scene } from "babylonjs/scene";
  17318. /**
  17319. * This represents the object necessary to create a rendering group.
  17320. * This is exclusively used and created by the rendering manager.
  17321. * To modify the behavior, you use the available helpers in your scene or meshes.
  17322. * @hidden
  17323. */
  17324. export class RenderingGroup {
  17325. index: number;
  17326. private _scene;
  17327. private _opaqueSubMeshes;
  17328. private _transparentSubMeshes;
  17329. private _alphaTestSubMeshes;
  17330. private _depthOnlySubMeshes;
  17331. private _particleSystems;
  17332. private _spriteManagers;
  17333. private _opaqueSortCompareFn;
  17334. private _alphaTestSortCompareFn;
  17335. private _transparentSortCompareFn;
  17336. private _renderOpaque;
  17337. private _renderAlphaTest;
  17338. private _renderTransparent;
  17339. private _edgesRenderers;
  17340. onBeforeTransparentRendering: () => void;
  17341. /**
  17342. * Set the opaque sort comparison function.
  17343. * If null the sub meshes will be render in the order they were created
  17344. */
  17345. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17346. /**
  17347. * Set the alpha test sort comparison function.
  17348. * If null the sub meshes will be render in the order they were created
  17349. */
  17350. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17351. /**
  17352. * Set the transparent sort comparison function.
  17353. * If null the sub meshes will be render in the order they were created
  17354. */
  17355. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17356. /**
  17357. * Creates a new rendering group.
  17358. * @param index The rendering group index
  17359. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17360. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17361. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17362. */
  17363. 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>);
  17364. /**
  17365. * Render all the sub meshes contained in the group.
  17366. * @param customRenderFunction Used to override the default render behaviour of the group.
  17367. * @returns true if rendered some submeshes.
  17368. */
  17369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17370. /**
  17371. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17372. * @param subMeshes The submeshes to render
  17373. */
  17374. private renderOpaqueSorted;
  17375. /**
  17376. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17377. * @param subMeshes The submeshes to render
  17378. */
  17379. private renderAlphaTestSorted;
  17380. /**
  17381. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17382. * @param subMeshes The submeshes to render
  17383. */
  17384. private renderTransparentSorted;
  17385. /**
  17386. * Renders the submeshes in a specified order.
  17387. * @param subMeshes The submeshes to sort before render
  17388. * @param sortCompareFn The comparison function use to sort
  17389. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17390. * @param transparent Specifies to activate blending if true
  17391. */
  17392. private static renderSorted;
  17393. /**
  17394. * Renders the submeshes in the order they were dispatched (no sort applied).
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private static renderUnsorted;
  17398. /**
  17399. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17400. * are rendered back to front if in the same alpha index.
  17401. *
  17402. * @param a The first submesh
  17403. * @param b The second submesh
  17404. * @returns The result of the comparison
  17405. */
  17406. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17407. /**
  17408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17409. * are rendered back to front.
  17410. *
  17411. * @param a The first submesh
  17412. * @param b The second submesh
  17413. * @returns The result of the comparison
  17414. */
  17415. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17416. /**
  17417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17418. * are rendered front to back (prevent overdraw).
  17419. *
  17420. * @param a The first submesh
  17421. * @param b The second submesh
  17422. * @returns The result of the comparison
  17423. */
  17424. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17425. /**
  17426. * Resets the different lists of submeshes to prepare a new frame.
  17427. */
  17428. prepare(): void;
  17429. dispose(): void;
  17430. /**
  17431. * Inserts the submesh in its correct queue depending on its material.
  17432. * @param subMesh The submesh to dispatch
  17433. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17434. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17435. */
  17436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17437. dispatchSprites(spriteManager: ISpriteManager): void;
  17438. dispatchParticles(particleSystem: IParticleSystem): void;
  17439. private _renderParticles;
  17440. private _renderSprites;
  17441. }
  17442. }
  17443. declare module "babylonjs/Rendering/renderingManager" {
  17444. import { Nullable } from "babylonjs/types";
  17445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17446. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17447. import { SmartArray } from "babylonjs/Misc/smartArray";
  17448. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17449. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17450. import { Material } from "babylonjs/Materials/material";
  17451. import { Scene } from "babylonjs/scene";
  17452. import { Camera } from "babylonjs/Cameras/camera";
  17453. /**
  17454. * Interface describing the different options available in the rendering manager
  17455. * regarding Auto Clear between groups.
  17456. */
  17457. export interface IRenderingManagerAutoClearSetup {
  17458. /**
  17459. * Defines whether or not autoclear is enable.
  17460. */
  17461. autoClear: boolean;
  17462. /**
  17463. * Defines whether or not to autoclear the depth buffer.
  17464. */
  17465. depth: boolean;
  17466. /**
  17467. * Defines whether or not to autoclear the stencil buffer.
  17468. */
  17469. stencil: boolean;
  17470. }
  17471. /**
  17472. * This class is used by the onRenderingGroupObservable
  17473. */
  17474. export class RenderingGroupInfo {
  17475. /**
  17476. * The Scene that being rendered
  17477. */
  17478. scene: Scene;
  17479. /**
  17480. * The camera currently used for the rendering pass
  17481. */
  17482. camera: Nullable<Camera>;
  17483. /**
  17484. * The ID of the renderingGroup being processed
  17485. */
  17486. renderingGroupId: number;
  17487. }
  17488. /**
  17489. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17490. * It is enable to manage the different groups as well as the different necessary sort functions.
  17491. * This should not be used directly aside of the few static configurations
  17492. */
  17493. export class RenderingManager {
  17494. /**
  17495. * The max id used for rendering groups (not included)
  17496. */
  17497. static MAX_RENDERINGGROUPS: number;
  17498. /**
  17499. * The min id used for rendering groups (included)
  17500. */
  17501. static MIN_RENDERINGGROUPS: number;
  17502. /**
  17503. * Used to globally prevent autoclearing scenes.
  17504. */
  17505. static AUTOCLEAR: boolean;
  17506. /**
  17507. * @hidden
  17508. */
  17509. _useSceneAutoClearSetup: boolean;
  17510. private _scene;
  17511. private _renderingGroups;
  17512. private _depthStencilBufferAlreadyCleaned;
  17513. private _autoClearDepthStencil;
  17514. private _customOpaqueSortCompareFn;
  17515. private _customAlphaTestSortCompareFn;
  17516. private _customTransparentSortCompareFn;
  17517. private _renderingGroupInfo;
  17518. /**
  17519. * Instantiates a new rendering group for a particular scene
  17520. * @param scene Defines the scene the groups belongs to
  17521. */
  17522. constructor(scene: Scene);
  17523. private _clearDepthStencilBuffer;
  17524. /**
  17525. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17526. * @hidden
  17527. */
  17528. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17529. /**
  17530. * Resets the different information of the group to prepare a new frame
  17531. * @hidden
  17532. */
  17533. reset(): void;
  17534. /**
  17535. * Dispose and release the group and its associated resources.
  17536. * @hidden
  17537. */
  17538. dispose(): void;
  17539. /**
  17540. * Clear the info related to rendering groups preventing retention points during dispose.
  17541. */
  17542. freeRenderingGroups(): void;
  17543. private _prepareRenderingGroup;
  17544. /**
  17545. * Add a sprite manager to the rendering manager in order to render it this frame.
  17546. * @param spriteManager Define the sprite manager to render
  17547. */
  17548. dispatchSprites(spriteManager: ISpriteManager): void;
  17549. /**
  17550. * Add a particle system to the rendering manager in order to render it this frame.
  17551. * @param particleSystem Define the particle system to render
  17552. */
  17553. dispatchParticles(particleSystem: IParticleSystem): void;
  17554. /**
  17555. * Add a submesh to the manager in order to render it this frame
  17556. * @param subMesh The submesh to dispatch
  17557. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17558. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17559. */
  17560. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17561. /**
  17562. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17563. * This allowed control for front to back rendering or reversly depending of the special needs.
  17564. *
  17565. * @param renderingGroupId The rendering group id corresponding to its index
  17566. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17567. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17568. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17569. */
  17570. 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;
  17571. /**
  17572. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17573. *
  17574. * @param renderingGroupId The rendering group id corresponding to its index
  17575. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17576. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17577. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17578. */
  17579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17580. /**
  17581. * Gets the current auto clear configuration for one rendering group of the rendering
  17582. * manager.
  17583. * @param index the rendering group index to get the information for
  17584. * @returns The auto clear setup for the requested rendering group
  17585. */
  17586. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17587. }
  17588. }
  17589. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17590. import { Observable } from "babylonjs/Misc/observable";
  17591. import { SmartArray } from "babylonjs/Misc/smartArray";
  17592. import { Nullable } from "babylonjs/types";
  17593. import { Camera } from "babylonjs/Cameras/camera";
  17594. import { Scene } from "babylonjs/scene";
  17595. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17596. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17600. import { Texture } from "babylonjs/Materials/Textures/texture";
  17601. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17602. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17603. import { Engine } from "babylonjs/Engines/engine";
  17604. /**
  17605. * This Helps creating a texture that will be created from a camera in your scene.
  17606. * It is basically a dynamic texture that could be used to create special effects for instance.
  17607. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17608. */
  17609. export class RenderTargetTexture extends Texture {
  17610. isCube: boolean;
  17611. /**
  17612. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17613. */
  17614. static readonly REFRESHRATE_RENDER_ONCE: number;
  17615. /**
  17616. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17617. */
  17618. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17619. /**
  17620. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17621. * the central point of your effect and can save a lot of performances.
  17622. */
  17623. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17624. /**
  17625. * Use this predicate to dynamically define the list of mesh you want to render.
  17626. * If set, the renderList property will be overwritten.
  17627. */
  17628. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17629. private _renderList;
  17630. /**
  17631. * Use this list to define the list of mesh you want to render.
  17632. */
  17633. renderList: Nullable<Array<AbstractMesh>>;
  17634. private _hookArray;
  17635. /**
  17636. * Define if particles should be rendered in your texture.
  17637. */
  17638. renderParticles: boolean;
  17639. /**
  17640. * Define if sprites should be rendered in your texture.
  17641. */
  17642. renderSprites: boolean;
  17643. /**
  17644. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17645. */
  17646. coordinatesMode: number;
  17647. /**
  17648. * Define the camera used to render the texture.
  17649. */
  17650. activeCamera: Nullable<Camera>;
  17651. /**
  17652. * Override the render function of the texture with your own one.
  17653. */
  17654. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17655. /**
  17656. * Define if camera post processes should be use while rendering the texture.
  17657. */
  17658. useCameraPostProcesses: boolean;
  17659. /**
  17660. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17661. */
  17662. ignoreCameraViewport: boolean;
  17663. private _postProcessManager;
  17664. private _postProcesses;
  17665. private _resizeObserver;
  17666. /**
  17667. * An event triggered when the texture is unbind.
  17668. */
  17669. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17670. /**
  17671. * An event triggered when the texture is unbind.
  17672. */
  17673. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17674. private _onAfterUnbindObserver;
  17675. /**
  17676. * Set a after unbind callback in the texture.
  17677. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17678. */
  17679. onAfterUnbind: () => void;
  17680. /**
  17681. * An event triggered before rendering the texture
  17682. */
  17683. onBeforeRenderObservable: Observable<number>;
  17684. private _onBeforeRenderObserver;
  17685. /**
  17686. * Set a before render callback in the texture.
  17687. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17688. */
  17689. onBeforeRender: (faceIndex: number) => void;
  17690. /**
  17691. * An event triggered after rendering the texture
  17692. */
  17693. onAfterRenderObservable: Observable<number>;
  17694. private _onAfterRenderObserver;
  17695. /**
  17696. * Set a after render callback in the texture.
  17697. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17698. */
  17699. onAfterRender: (faceIndex: number) => void;
  17700. /**
  17701. * An event triggered after the texture clear
  17702. */
  17703. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17704. private _onClearObserver;
  17705. /**
  17706. * Set a clear callback in the texture.
  17707. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17708. */
  17709. onClear: (Engine: Engine) => void;
  17710. /**
  17711. * Define the clear color of the Render Target if it should be different from the scene.
  17712. */
  17713. clearColor: Color4;
  17714. protected _size: number | {
  17715. width: number;
  17716. height: number;
  17717. };
  17718. protected _initialSizeParameter: number | {
  17719. width: number;
  17720. height: number;
  17721. } | {
  17722. ratio: number;
  17723. };
  17724. protected _sizeRatio: Nullable<number>;
  17725. /** @hidden */
  17726. _generateMipMaps: boolean;
  17727. protected _renderingManager: RenderingManager;
  17728. /** @hidden */
  17729. _waitingRenderList: string[];
  17730. protected _doNotChangeAspectRatio: boolean;
  17731. protected _currentRefreshId: number;
  17732. protected _refreshRate: number;
  17733. protected _textureMatrix: Matrix;
  17734. protected _samples: number;
  17735. protected _renderTargetOptions: RenderTargetCreationOptions;
  17736. /**
  17737. * Gets render target creation options that were used.
  17738. */
  17739. readonly renderTargetOptions: RenderTargetCreationOptions;
  17740. protected _engine: Engine;
  17741. protected _onRatioRescale(): void;
  17742. /**
  17743. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17744. * It must define where the camera used to render the texture is set
  17745. */
  17746. boundingBoxPosition: Vector3;
  17747. private _boundingBoxSize;
  17748. /**
  17749. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17750. * When defined, the cubemap will switch to local mode
  17751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17752. * @example https://www.babylonjs-playground.com/#RNASML
  17753. */
  17754. boundingBoxSize: Vector3;
  17755. /**
  17756. * In case the RTT has been created with a depth texture, get the associated
  17757. * depth texture.
  17758. * Otherwise, return null.
  17759. */
  17760. depthStencilTexture: Nullable<InternalTexture>;
  17761. /**
  17762. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17763. * or used a shadow, depth texture...
  17764. * @param name The friendly name of the texture
  17765. * @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)
  17766. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17767. * @param generateMipMaps True if mip maps need to be generated after render.
  17768. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17769. * @param type The type of the buffer in the RTT (int, half float, float...)
  17770. * @param isCube True if a cube texture needs to be created
  17771. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17772. * @param generateDepthBuffer True to generate a depth buffer
  17773. * @param generateStencilBuffer True to generate a stencil buffer
  17774. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17775. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17777. */
  17778. constructor(name: string, size: number | {
  17779. width: number;
  17780. height: number;
  17781. } | {
  17782. ratio: number;
  17783. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17784. /**
  17785. * Creates a depth stencil texture.
  17786. * This is only available in WebGL 2 or with the depth texture extension available.
  17787. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17788. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17789. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17790. */
  17791. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17792. private _processSizeParameter;
  17793. /**
  17794. * Define the number of samples to use in case of MSAA.
  17795. * It defaults to one meaning no MSAA has been enabled.
  17796. */
  17797. samples: number;
  17798. /**
  17799. * Resets the refresh counter of the texture and start bak from scratch.
  17800. * Could be useful to regenerate the texture if it is setup to render only once.
  17801. */
  17802. resetRefreshCounter(): void;
  17803. /**
  17804. * Define the refresh rate of the texture or the rendering frequency.
  17805. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17806. */
  17807. refreshRate: number;
  17808. /**
  17809. * Adds a post process to the render target rendering passes.
  17810. * @param postProcess define the post process to add
  17811. */
  17812. addPostProcess(postProcess: PostProcess): void;
  17813. /**
  17814. * Clear all the post processes attached to the render target
  17815. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17816. */
  17817. clearPostProcesses(dispose?: boolean): void;
  17818. /**
  17819. * Remove one of the post process from the list of attached post processes to the texture
  17820. * @param postProcess define the post process to remove from the list
  17821. */
  17822. removePostProcess(postProcess: PostProcess): void;
  17823. /** @hidden */
  17824. _shouldRender(): boolean;
  17825. /**
  17826. * Gets the actual render size of the texture.
  17827. * @returns the width of the render size
  17828. */
  17829. getRenderSize(): number;
  17830. /**
  17831. * Gets the actual render width of the texture.
  17832. * @returns the width of the render size
  17833. */
  17834. getRenderWidth(): number;
  17835. /**
  17836. * Gets the actual render height of the texture.
  17837. * @returns the height of the render size
  17838. */
  17839. getRenderHeight(): number;
  17840. /**
  17841. * Get if the texture can be rescaled or not.
  17842. */
  17843. readonly canRescale: boolean;
  17844. /**
  17845. * Resize the texture using a ratio.
  17846. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17847. */
  17848. scale(ratio: number): void;
  17849. /**
  17850. * Get the texture reflection matrix used to rotate/transform the reflection.
  17851. * @returns the reflection matrix
  17852. */
  17853. getReflectionTextureMatrix(): Matrix;
  17854. /**
  17855. * Resize the texture to a new desired size.
  17856. * Be carrefull as it will recreate all the data in the new texture.
  17857. * @param size Define the new size. It can be:
  17858. * - a number for squared texture,
  17859. * - an object containing { width: number, height: number }
  17860. * - or an object containing a ratio { ratio: number }
  17861. */
  17862. resize(size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }): void;
  17868. /**
  17869. * Renders all the objects from the render list into the texture.
  17870. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17871. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17872. */
  17873. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17874. private _bestReflectionRenderTargetDimension;
  17875. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17876. private renderToTarget;
  17877. /**
  17878. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17879. * This allowed control for front to back rendering or reversly depending of the special needs.
  17880. *
  17881. * @param renderingGroupId The rendering group id corresponding to its index
  17882. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17883. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17884. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17885. */
  17886. 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;
  17887. /**
  17888. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17889. *
  17890. * @param renderingGroupId The rendering group id corresponding to its index
  17891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17892. */
  17893. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17894. /**
  17895. * Clones the texture.
  17896. * @returns the cloned texture
  17897. */
  17898. clone(): RenderTargetTexture;
  17899. /**
  17900. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17901. * @returns The JSON representation of the texture
  17902. */
  17903. serialize(): any;
  17904. /**
  17905. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17906. */
  17907. disposeFramebufferObjects(): void;
  17908. /**
  17909. * Dispose the texture and release its associated resources.
  17910. */
  17911. dispose(): void;
  17912. /** @hidden */
  17913. _rebuild(): void;
  17914. /**
  17915. * Clear the info related to rendering groups preventing retention point in material dispose.
  17916. */
  17917. freeRenderingGroups(): void;
  17918. }
  17919. }
  17920. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17921. import { Scene } from "babylonjs/scene";
  17922. import { Plane } from "babylonjs/Maths/math";
  17923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17924. /**
  17925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17927. * You can then easily use it as a reflectionTexture on a flat surface.
  17928. * In case the surface is not a plane, please consider relying on reflection probes.
  17929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17930. */
  17931. export class MirrorTexture extends RenderTargetTexture {
  17932. private scene;
  17933. /**
  17934. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17935. * 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.
  17936. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17937. */
  17938. mirrorPlane: Plane;
  17939. /**
  17940. * Define the blur ratio used to blur the reflection if needed.
  17941. */
  17942. blurRatio: number;
  17943. /**
  17944. * Define the adaptive blur kernel used to blur the reflection if needed.
  17945. * This will autocompute the closest best match for the `blurKernel`
  17946. */
  17947. adaptiveBlurKernel: number;
  17948. /**
  17949. * Define the blur kernel used to blur the reflection if needed.
  17950. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17951. */
  17952. blurKernel: number;
  17953. /**
  17954. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17955. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17956. */
  17957. blurKernelX: number;
  17958. /**
  17959. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17960. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17961. */
  17962. blurKernelY: number;
  17963. private _autoComputeBlurKernel;
  17964. protected _onRatioRescale(): void;
  17965. private _updateGammaSpace;
  17966. private _imageProcessingConfigChangeObserver;
  17967. private _transformMatrix;
  17968. private _mirrorMatrix;
  17969. private _savedViewMatrix;
  17970. private _blurX;
  17971. private _blurY;
  17972. private _adaptiveBlurKernel;
  17973. private _blurKernelX;
  17974. private _blurKernelY;
  17975. private _blurRatio;
  17976. /**
  17977. * Instantiates a Mirror Texture.
  17978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17980. * You can then easily use it as a reflectionTexture on a flat surface.
  17981. * In case the surface is not a plane, please consider relying on reflection probes.
  17982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17983. * @param name
  17984. * @param size
  17985. * @param scene
  17986. * @param generateMipMaps
  17987. * @param type
  17988. * @param samplingMode
  17989. * @param generateDepthBuffer
  17990. */
  17991. constructor(name: string, size: number | {
  17992. width: number;
  17993. height: number;
  17994. } | {
  17995. ratio: number;
  17996. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17997. private _preparePostProcesses;
  17998. /**
  17999. * Clone the mirror texture.
  18000. * @returns the cloned texture
  18001. */
  18002. clone(): MirrorTexture;
  18003. /**
  18004. * Serialize the texture to a JSON representation you could use in Parse later on
  18005. * @returns the serialized JSON representation
  18006. */
  18007. serialize(): any;
  18008. /**
  18009. * Dispose the texture and release its associated resources.
  18010. */
  18011. dispose(): void;
  18012. }
  18013. }
  18014. declare module "babylonjs/Materials/Textures/texture" {
  18015. import { Observable } from "babylonjs/Misc/observable";
  18016. import { Nullable } from "babylonjs/types";
  18017. import { Scene } from "babylonjs/scene";
  18018. import { Matrix } from "babylonjs/Maths/math";
  18019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18020. /**
  18021. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18022. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18023. */
  18024. export class Texture extends BaseTexture {
  18025. /** @hidden */
  18026. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18027. /** @hidden */
  18028. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18029. /** @hidden */
  18030. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18031. /** nearest is mag = nearest and min = nearest and mip = linear */
  18032. static readonly NEAREST_SAMPLINGMODE: number;
  18033. /** nearest is mag = nearest and min = nearest and mip = linear */
  18034. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18035. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18036. static readonly BILINEAR_SAMPLINGMODE: number;
  18037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18038. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18039. /** Trilinear is mag = linear and min = linear and mip = linear */
  18040. static readonly TRILINEAR_SAMPLINGMODE: number;
  18041. /** Trilinear is mag = linear and min = linear and mip = linear */
  18042. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18043. /** mag = nearest and min = nearest and mip = nearest */
  18044. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18045. /** mag = nearest and min = linear and mip = nearest */
  18046. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18047. /** mag = nearest and min = linear and mip = linear */
  18048. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18049. /** mag = nearest and min = linear and mip = none */
  18050. static readonly NEAREST_LINEAR: number;
  18051. /** mag = nearest and min = nearest and mip = none */
  18052. static readonly NEAREST_NEAREST: number;
  18053. /** mag = linear and min = nearest and mip = nearest */
  18054. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18055. /** mag = linear and min = nearest and mip = linear */
  18056. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18057. /** mag = linear and min = linear and mip = none */
  18058. static readonly LINEAR_LINEAR: number;
  18059. /** mag = linear and min = nearest and mip = none */
  18060. static readonly LINEAR_NEAREST: number;
  18061. /** Explicit coordinates mode */
  18062. static readonly EXPLICIT_MODE: number;
  18063. /** Spherical coordinates mode */
  18064. static readonly SPHERICAL_MODE: number;
  18065. /** Planar coordinates mode */
  18066. static readonly PLANAR_MODE: number;
  18067. /** Cubic coordinates mode */
  18068. static readonly CUBIC_MODE: number;
  18069. /** Projection coordinates mode */
  18070. static readonly PROJECTION_MODE: number;
  18071. /** Inverse Cubic coordinates mode */
  18072. static readonly SKYBOX_MODE: number;
  18073. /** Inverse Cubic coordinates mode */
  18074. static readonly INVCUBIC_MODE: number;
  18075. /** Equirectangular coordinates mode */
  18076. static readonly EQUIRECTANGULAR_MODE: number;
  18077. /** Equirectangular Fixed coordinates mode */
  18078. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18079. /** Equirectangular Fixed Mirrored coordinates mode */
  18080. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18081. /** Texture is not repeating outside of 0..1 UVs */
  18082. static readonly CLAMP_ADDRESSMODE: number;
  18083. /** Texture is repeating outside of 0..1 UVs */
  18084. static readonly WRAP_ADDRESSMODE: number;
  18085. /** Texture is repeating and mirrored */
  18086. static readonly MIRROR_ADDRESSMODE: number;
  18087. /**
  18088. * 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
  18089. */
  18090. static UseSerializedUrlIfAny: boolean;
  18091. /**
  18092. * Define the url of the texture.
  18093. */
  18094. url: Nullable<string>;
  18095. /**
  18096. * Define an offset on the texture to offset the u coordinates of the UVs
  18097. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18098. */
  18099. uOffset: number;
  18100. /**
  18101. * Define an offset on the texture to offset the v coordinates of the UVs
  18102. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18103. */
  18104. vOffset: number;
  18105. /**
  18106. * Define an offset on the texture to scale the u coordinates of the UVs
  18107. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18108. */
  18109. uScale: number;
  18110. /**
  18111. * Define an offset on the texture to scale the v coordinates of the UVs
  18112. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18113. */
  18114. vScale: number;
  18115. /**
  18116. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18117. * @see http://doc.babylonjs.com/how_to/more_materials
  18118. */
  18119. uAng: number;
  18120. /**
  18121. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18122. * @see http://doc.babylonjs.com/how_to/more_materials
  18123. */
  18124. vAng: number;
  18125. /**
  18126. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18127. * @see http://doc.babylonjs.com/how_to/more_materials
  18128. */
  18129. wAng: number;
  18130. /**
  18131. * Defines the center of rotation (U)
  18132. */
  18133. uRotationCenter: number;
  18134. /**
  18135. * Defines the center of rotation (V)
  18136. */
  18137. vRotationCenter: number;
  18138. /**
  18139. * Defines the center of rotation (W)
  18140. */
  18141. wRotationCenter: number;
  18142. /**
  18143. * Are mip maps generated for this texture or not.
  18144. */
  18145. readonly noMipmap: boolean;
  18146. private _noMipmap;
  18147. /** @hidden */
  18148. _invertY: boolean;
  18149. private _rowGenerationMatrix;
  18150. private _cachedTextureMatrix;
  18151. private _projectionModeMatrix;
  18152. private _t0;
  18153. private _t1;
  18154. private _t2;
  18155. private _cachedUOffset;
  18156. private _cachedVOffset;
  18157. private _cachedUScale;
  18158. private _cachedVScale;
  18159. private _cachedUAng;
  18160. private _cachedVAng;
  18161. private _cachedWAng;
  18162. private _cachedProjectionMatrixId;
  18163. private _cachedCoordinatesMode;
  18164. /** @hidden */
  18165. protected _initialSamplingMode: number;
  18166. /** @hidden */
  18167. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18168. private _deleteBuffer;
  18169. protected _format: Nullable<number>;
  18170. private _delayedOnLoad;
  18171. private _delayedOnError;
  18172. /**
  18173. * Observable triggered once the texture has been loaded.
  18174. */
  18175. onLoadObservable: Observable<Texture>;
  18176. protected _isBlocking: boolean;
  18177. /**
  18178. * Is the texture preventing material to render while loading.
  18179. * If false, a default texture will be used instead of the loading one during the preparation step.
  18180. */
  18181. isBlocking: boolean;
  18182. /**
  18183. * Get the current sampling mode associated with the texture.
  18184. */
  18185. readonly samplingMode: number;
  18186. /**
  18187. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18188. */
  18189. readonly invertY: boolean;
  18190. /**
  18191. * Instantiates a new texture.
  18192. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18193. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18194. * @param url define the url of the picture to load as a texture
  18195. * @param scene define the scene the texture will belong to
  18196. * @param noMipmap define if the texture will require mip maps or not
  18197. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18198. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18199. * @param onLoad define a callback triggered when the texture has been loaded
  18200. * @param onError define a callback triggered when an error occurred during the loading session
  18201. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18202. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18204. */
  18205. 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);
  18206. /**
  18207. * Update the url (and optional buffer) of this texture if url was null during construction.
  18208. * @param url the url of the texture
  18209. * @param buffer the buffer of the texture (defaults to null)
  18210. * @param onLoad callback called when the texture is loaded (defaults to null)
  18211. */
  18212. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18213. /**
  18214. * Finish the loading sequence of a texture flagged as delayed load.
  18215. * @hidden
  18216. */
  18217. delayLoad(): void;
  18218. private _prepareRowForTextureGeneration;
  18219. /**
  18220. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18221. * @returns the transform matrix of the texture.
  18222. */
  18223. getTextureMatrix(): Matrix;
  18224. /**
  18225. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18226. * @returns The reflection texture transform
  18227. */
  18228. getReflectionTextureMatrix(): Matrix;
  18229. /**
  18230. * Clones the texture.
  18231. * @returns the cloned texture
  18232. */
  18233. clone(): Texture;
  18234. /**
  18235. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18236. * @returns The JSON representation of the texture
  18237. */
  18238. serialize(): any;
  18239. /**
  18240. * Get the current class name of the texture useful for serialization or dynamic coding.
  18241. * @returns "Texture"
  18242. */
  18243. getClassName(): string;
  18244. /**
  18245. * Dispose the texture and release its associated resources.
  18246. */
  18247. dispose(): void;
  18248. /**
  18249. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18250. * @param parsedTexture Define the JSON representation of the texture
  18251. * @param scene Define the scene the parsed texture should be instantiated in
  18252. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18253. * @returns The parsed texture if successful
  18254. */
  18255. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18256. /**
  18257. * Creates a texture from its base 64 representation.
  18258. * @param data Define the base64 payload without the data: prefix
  18259. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18260. * @param scene Define the scene the texture should belong to
  18261. * @param noMipmap Forces the texture to not create mip map information if true
  18262. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18263. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18264. * @param onLoad define a callback triggered when the texture has been loaded
  18265. * @param onError define a callback triggered when an error occurred during the loading session
  18266. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18267. * @returns the created texture
  18268. */
  18269. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18270. /**
  18271. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18272. * @param data Define the base64 payload without the data: prefix
  18273. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18274. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18275. * @param scene Define the scene the texture should belong to
  18276. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18277. * @param noMipmap Forces the texture to not create mip map information if true
  18278. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18279. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18280. * @param onLoad define a callback triggered when the texture has been loaded
  18281. * @param onError define a callback triggered when an error occurred during the loading session
  18282. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18283. * @returns the created texture
  18284. */
  18285. 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;
  18286. }
  18287. }
  18288. declare module "babylonjs/Materials/Textures/rawTexture" {
  18289. import { Scene } from "babylonjs/scene";
  18290. import { Texture } from "babylonjs/Materials/Textures/texture";
  18291. /**
  18292. * Raw texture can help creating a texture directly from an array of data.
  18293. * This can be super useful if you either get the data from an uncompressed source or
  18294. * if you wish to create your texture pixel by pixel.
  18295. */
  18296. export class RawTexture extends Texture {
  18297. /**
  18298. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18299. */
  18300. format: number;
  18301. private _engine;
  18302. /**
  18303. * Instantiates a new RawTexture.
  18304. * Raw texture can help creating a texture directly from an array of data.
  18305. * This can be super useful if you either get the data from an uncompressed source or
  18306. * if you wish to create your texture pixel by pixel.
  18307. * @param data define the array of data to use to create the texture
  18308. * @param width define the width of the texture
  18309. * @param height define the height of the texture
  18310. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18311. * @param scene define the scene the texture belongs to
  18312. * @param generateMipMaps define whether mip maps should be generated or not
  18313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18315. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18316. */
  18317. constructor(data: ArrayBufferView, width: number, height: number,
  18318. /**
  18319. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18320. */
  18321. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18322. /**
  18323. * Updates the texture underlying data.
  18324. * @param data Define the new data of the texture
  18325. */
  18326. update(data: ArrayBufferView): void;
  18327. /**
  18328. * Creates a luminance texture from some data.
  18329. * @param data Define the texture data
  18330. * @param width Define the width of the texture
  18331. * @param height Define the height of the texture
  18332. * @param scene Define the scene the texture belongs to
  18333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18336. * @returns the luminance texture
  18337. */
  18338. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18339. /**
  18340. * Creates a luminance alpha texture from some data.
  18341. * @param data Define the texture data
  18342. * @param width Define the width of the texture
  18343. * @param height Define the height of the texture
  18344. * @param scene Define the scene the texture belongs to
  18345. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18348. * @returns the luminance alpha texture
  18349. */
  18350. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18351. /**
  18352. * Creates an alpha texture from some data.
  18353. * @param data Define the texture data
  18354. * @param width Define the width of the texture
  18355. * @param height Define the height of the texture
  18356. * @param scene Define the scene the texture belongs to
  18357. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18360. * @returns the alpha texture
  18361. */
  18362. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18363. /**
  18364. * Creates a RGB texture from some data.
  18365. * @param data Define the texture data
  18366. * @param width Define the width of the texture
  18367. * @param height Define the height of the texture
  18368. * @param scene Define the scene the texture belongs to
  18369. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18370. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18371. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18372. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18373. * @returns the RGB alpha texture
  18374. */
  18375. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18376. /**
  18377. * Creates a RGBA texture from some data.
  18378. * @param data Define the texture data
  18379. * @param width Define the width of the texture
  18380. * @param height Define the height of the texture
  18381. * @param scene Define the scene the texture belongs to
  18382. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18383. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18384. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18385. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18386. * @returns the RGBA texture
  18387. */
  18388. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18389. /**
  18390. * Creates a R texture from some data.
  18391. * @param data Define the texture data
  18392. * @param width Define the width of the texture
  18393. * @param height Define the height of the texture
  18394. * @param scene Define the scene the texture belongs to
  18395. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18396. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18397. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18398. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18399. * @returns the R texture
  18400. */
  18401. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18402. }
  18403. }
  18404. declare module "babylonjs/Animations/runtimeAnimation" {
  18405. import { Animation } from "babylonjs/Animations/animation";
  18406. import { Animatable } from "babylonjs/Animations/animatable";
  18407. import { Scene } from "babylonjs/scene";
  18408. /**
  18409. * Defines a runtime animation
  18410. */
  18411. export class RuntimeAnimation {
  18412. private _events;
  18413. /**
  18414. * The current frame of the runtime animation
  18415. */
  18416. private _currentFrame;
  18417. /**
  18418. * The animation used by the runtime animation
  18419. */
  18420. private _animation;
  18421. /**
  18422. * The target of the runtime animation
  18423. */
  18424. private _target;
  18425. /**
  18426. * The initiating animatable
  18427. */
  18428. private _host;
  18429. /**
  18430. * The original value of the runtime animation
  18431. */
  18432. private _originalValue;
  18433. /**
  18434. * The original blend value of the runtime animation
  18435. */
  18436. private _originalBlendValue;
  18437. /**
  18438. * The offsets cache of the runtime animation
  18439. */
  18440. private _offsetsCache;
  18441. /**
  18442. * The high limits cache of the runtime animation
  18443. */
  18444. private _highLimitsCache;
  18445. /**
  18446. * Specifies if the runtime animation has been stopped
  18447. */
  18448. private _stopped;
  18449. /**
  18450. * The blending factor of the runtime animation
  18451. */
  18452. private _blendingFactor;
  18453. /**
  18454. * The BabylonJS scene
  18455. */
  18456. private _scene;
  18457. /**
  18458. * The current value of the runtime animation
  18459. */
  18460. private _currentValue;
  18461. /** @hidden */
  18462. _workValue: any;
  18463. /**
  18464. * The active target of the runtime animation
  18465. */
  18466. private _activeTarget;
  18467. /**
  18468. * The target path of the runtime animation
  18469. */
  18470. private _targetPath;
  18471. /**
  18472. * The weight of the runtime animation
  18473. */
  18474. private _weight;
  18475. /**
  18476. * The ratio offset of the runtime animation
  18477. */
  18478. private _ratioOffset;
  18479. /**
  18480. * The previous delay of the runtime animation
  18481. */
  18482. private _previousDelay;
  18483. /**
  18484. * The previous ratio of the runtime animation
  18485. */
  18486. private _previousRatio;
  18487. /**
  18488. * Gets the current frame of the runtime animation
  18489. */
  18490. readonly currentFrame: number;
  18491. /**
  18492. * Gets the weight of the runtime animation
  18493. */
  18494. readonly weight: number;
  18495. /**
  18496. * Gets the current value of the runtime animation
  18497. */
  18498. readonly currentValue: any;
  18499. /**
  18500. * Gets the target path of the runtime animation
  18501. */
  18502. readonly targetPath: string;
  18503. /**
  18504. * Gets the actual target of the runtime animation
  18505. */
  18506. readonly target: any;
  18507. /**
  18508. * Create a new RuntimeAnimation object
  18509. * @param target defines the target of the animation
  18510. * @param animation defines the source animation object
  18511. * @param scene defines the hosting scene
  18512. * @param host defines the initiating Animatable
  18513. */
  18514. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18515. /**
  18516. * Gets the animation from the runtime animation
  18517. */
  18518. readonly animation: Animation;
  18519. /**
  18520. * Resets the runtime animation to the beginning
  18521. * @param restoreOriginal defines whether to restore the target property to the original value
  18522. */
  18523. reset(restoreOriginal?: boolean): void;
  18524. /**
  18525. * Specifies if the runtime animation is stopped
  18526. * @returns Boolean specifying if the runtime animation is stopped
  18527. */
  18528. isStopped(): boolean;
  18529. /**
  18530. * Disposes of the runtime animation
  18531. */
  18532. dispose(): void;
  18533. /**
  18534. * Interpolates the animation from the current frame
  18535. * @param currentFrame The frame to interpolate the animation to
  18536. * @param repeatCount The number of times that the animation should loop
  18537. * @param loopMode The type of looping mode to use
  18538. * @param offsetValue Animation offset value
  18539. * @param highLimitValue The high limit value
  18540. * @returns The interpolated value
  18541. */
  18542. private _interpolate;
  18543. /**
  18544. * Apply the interpolated value to the target
  18545. * @param currentValue defines the value computed by the animation
  18546. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18547. */
  18548. setValue(currentValue: any, weight?: number): void;
  18549. private _setValue;
  18550. /**
  18551. * Gets the loop pmode of the runtime animation
  18552. * @returns Loop Mode
  18553. */
  18554. private _getCorrectLoopMode;
  18555. /**
  18556. * Move the current animation to a given frame
  18557. * @param frame defines the frame to move to
  18558. */
  18559. goToFrame(frame: number): void;
  18560. /**
  18561. * @hidden Internal use only
  18562. */
  18563. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18564. /**
  18565. * Execute the current animation
  18566. * @param delay defines the delay to add to the current frame
  18567. * @param from defines the lower bound of the animation range
  18568. * @param to defines the upper bound of the animation range
  18569. * @param loop defines if the current animation must loop
  18570. * @param speedRatio defines the current speed ratio
  18571. * @param weight defines the weight of the animation (default is -1 so no weight)
  18572. * @param onLoop optional callback called when animation loops
  18573. * @returns a boolean indicating if the animation is running
  18574. */
  18575. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18576. }
  18577. }
  18578. declare module "babylonjs/Animations/animatable" {
  18579. import { Animation } from "babylonjs/Animations/animation";
  18580. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18581. import { Nullable } from "babylonjs/types";
  18582. import { Observable } from "babylonjs/Misc/observable";
  18583. import { Scene } from "babylonjs/scene";
  18584. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18585. import { Node } from "babylonjs/node";
  18586. /**
  18587. * Class used to store an actual running animation
  18588. */
  18589. export class Animatable {
  18590. /** defines the target object */
  18591. target: any;
  18592. /** defines the starting frame number (default is 0) */
  18593. fromFrame: number;
  18594. /** defines the ending frame number (default is 100) */
  18595. toFrame: number;
  18596. /** defines if the animation must loop (default is false) */
  18597. loopAnimation: boolean;
  18598. /** defines a callback to call when animation ends if it is not looping */
  18599. onAnimationEnd?: (() => void) | null | undefined;
  18600. /** defines a callback to call when animation loops */
  18601. onAnimationLoop?: (() => void) | null | undefined;
  18602. private _localDelayOffset;
  18603. private _pausedDelay;
  18604. private _runtimeAnimations;
  18605. private _paused;
  18606. private _scene;
  18607. private _speedRatio;
  18608. private _weight;
  18609. private _syncRoot;
  18610. /**
  18611. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18612. * This will only apply for non looping animation (default is true)
  18613. */
  18614. disposeOnEnd: boolean;
  18615. /**
  18616. * Gets a boolean indicating if the animation has started
  18617. */
  18618. animationStarted: boolean;
  18619. /**
  18620. * Observer raised when the animation ends
  18621. */
  18622. onAnimationEndObservable: Observable<Animatable>;
  18623. /**
  18624. * Observer raised when the animation loops
  18625. */
  18626. onAnimationLoopObservable: Observable<Animatable>;
  18627. /**
  18628. * Gets the root Animatable used to synchronize and normalize animations
  18629. */
  18630. readonly syncRoot: Animatable;
  18631. /**
  18632. * Gets the current frame of the first RuntimeAnimation
  18633. * Used to synchronize Animatables
  18634. */
  18635. readonly masterFrame: number;
  18636. /**
  18637. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18638. */
  18639. weight: number;
  18640. /**
  18641. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18642. */
  18643. speedRatio: number;
  18644. /**
  18645. * Creates a new Animatable
  18646. * @param scene defines the hosting scene
  18647. * @param target defines the target object
  18648. * @param fromFrame defines the starting frame number (default is 0)
  18649. * @param toFrame defines the ending frame number (default is 100)
  18650. * @param loopAnimation defines if the animation must loop (default is false)
  18651. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18652. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18653. * @param animations defines a group of animation to add to the new Animatable
  18654. * @param onAnimationLoop defines a callback to call when animation loops
  18655. */
  18656. constructor(scene: Scene,
  18657. /** defines the target object */
  18658. target: any,
  18659. /** defines the starting frame number (default is 0) */
  18660. fromFrame?: number,
  18661. /** defines the ending frame number (default is 100) */
  18662. toFrame?: number,
  18663. /** defines if the animation must loop (default is false) */
  18664. loopAnimation?: boolean, speedRatio?: number,
  18665. /** defines a callback to call when animation ends if it is not looping */
  18666. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18667. /** defines a callback to call when animation loops */
  18668. onAnimationLoop?: (() => void) | null | undefined);
  18669. /**
  18670. * Synchronize and normalize current Animatable with a source Animatable
  18671. * This is useful when using animation weights and when animations are not of the same length
  18672. * @param root defines the root Animatable to synchronize with
  18673. * @returns the current Animatable
  18674. */
  18675. syncWith(root: Animatable): Animatable;
  18676. /**
  18677. * Gets the list of runtime animations
  18678. * @returns an array of RuntimeAnimation
  18679. */
  18680. getAnimations(): RuntimeAnimation[];
  18681. /**
  18682. * Adds more animations to the current animatable
  18683. * @param target defines the target of the animations
  18684. * @param animations defines the new animations to add
  18685. */
  18686. appendAnimations(target: any, animations: Animation[]): void;
  18687. /**
  18688. * Gets the source animation for a specific property
  18689. * @param property defines the propertyu to look for
  18690. * @returns null or the source animation for the given property
  18691. */
  18692. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18693. /**
  18694. * Gets the runtime animation for a specific property
  18695. * @param property defines the propertyu to look for
  18696. * @returns null or the runtime animation for the given property
  18697. */
  18698. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18699. /**
  18700. * Resets the animatable to its original state
  18701. */
  18702. reset(): void;
  18703. /**
  18704. * Allows the animatable to blend with current running animations
  18705. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18706. * @param blendingSpeed defines the blending speed to use
  18707. */
  18708. enableBlending(blendingSpeed: number): void;
  18709. /**
  18710. * Disable animation blending
  18711. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18712. */
  18713. disableBlending(): void;
  18714. /**
  18715. * Jump directly to a given frame
  18716. * @param frame defines the frame to jump to
  18717. */
  18718. goToFrame(frame: number): void;
  18719. /**
  18720. * Pause the animation
  18721. */
  18722. pause(): void;
  18723. /**
  18724. * Restart the animation
  18725. */
  18726. restart(): void;
  18727. private _raiseOnAnimationEnd;
  18728. /**
  18729. * Stop and delete the current animation
  18730. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18731. * @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)
  18732. */
  18733. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18734. /**
  18735. * Wait asynchronously for the animation to end
  18736. * @returns a promise which will be fullfilled when the animation ends
  18737. */
  18738. waitAsync(): Promise<Animatable>;
  18739. /** @hidden */
  18740. _animate(delay: number): boolean;
  18741. }
  18742. module "babylonjs/scene" {
  18743. interface Scene {
  18744. /** @hidden */
  18745. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18746. /** @hidden */
  18747. _processLateAnimationBindingsForMatrices(holder: {
  18748. totalWeight: number;
  18749. animations: RuntimeAnimation[];
  18750. originalValue: Matrix;
  18751. }): any;
  18752. /** @hidden */
  18753. _processLateAnimationBindingsForQuaternions(holder: {
  18754. totalWeight: number;
  18755. animations: RuntimeAnimation[];
  18756. originalValue: Quaternion;
  18757. }, refQuaternion: Quaternion): Quaternion;
  18758. /** @hidden */
  18759. _processLateAnimationBindings(): void;
  18760. /**
  18761. * Will start the animation sequence of a given target
  18762. * @param target defines the target
  18763. * @param from defines from which frame should animation start
  18764. * @param to defines until which frame should animation run.
  18765. * @param weight defines the weight to apply to the animation (1.0 by default)
  18766. * @param loop defines if the animation loops
  18767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18768. * @param onAnimationEnd defines the function to be executed when the animation ends
  18769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18770. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18771. * @param onAnimationLoop defines the callback to call when an animation loops
  18772. * @returns the animatable object created for this animation
  18773. */
  18774. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18775. /**
  18776. * Will start the animation sequence of a given target
  18777. * @param target defines the target
  18778. * @param from defines from which frame should animation start
  18779. * @param to defines until which frame should animation run.
  18780. * @param loop defines if the animation loops
  18781. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18782. * @param onAnimationEnd defines the function to be executed when the animation ends
  18783. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18784. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18785. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18786. * @param onAnimationLoop defines the callback to call when an animation loops
  18787. * @returns the animatable object created for this animation
  18788. */
  18789. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18790. /**
  18791. * Will start the animation sequence of a given target and its hierarchy
  18792. * @param target defines the target
  18793. * @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.
  18794. * @param from defines from which frame should animation start
  18795. * @param to defines until which frame should animation run.
  18796. * @param loop defines if the animation loops
  18797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18798. * @param onAnimationEnd defines the function to be executed when the animation ends
  18799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18802. * @param onAnimationLoop defines the callback to call when an animation loops
  18803. * @returns the list of created animatables
  18804. */
  18805. 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[];
  18806. /**
  18807. * Begin a new animation on a given node
  18808. * @param target defines the target where the animation will take place
  18809. * @param animations defines the list of animations to start
  18810. * @param from defines the initial value
  18811. * @param to defines the final value
  18812. * @param loop defines if you want animation to loop (off by default)
  18813. * @param speedRatio defines the speed ratio to apply to all animations
  18814. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18815. * @param onAnimationLoop defines the callback to call when an animation loops
  18816. * @returns the list of created animatables
  18817. */
  18818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18819. /**
  18820. * Begin a new animation on a given node and its hierarchy
  18821. * @param target defines the root node where the animation will take place
  18822. * @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.
  18823. * @param animations defines the list of animations to start
  18824. * @param from defines the initial value
  18825. * @param to defines the final value
  18826. * @param loop defines if you want animation to loop (off by default)
  18827. * @param speedRatio defines the speed ratio to apply to all animations
  18828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18829. * @param onAnimationLoop defines the callback to call when an animation loops
  18830. * @returns the list of animatables created for all nodes
  18831. */
  18832. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18833. /**
  18834. * Gets the animatable associated with a specific target
  18835. * @param target defines the target of the animatable
  18836. * @returns the required animatable if found
  18837. */
  18838. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18839. /**
  18840. * Gets all animatables associated with a given target
  18841. * @param target defines the target to look animatables for
  18842. * @returns an array of Animatables
  18843. */
  18844. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18845. /**
  18846. * Will stop the animation of the given target
  18847. * @param target - the target
  18848. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18849. * @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)
  18850. */
  18851. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18852. /**
  18853. * Stops and removes all animations that have been applied to the scene
  18854. */
  18855. stopAllAnimations(): void;
  18856. }
  18857. }
  18858. module "babylonjs/Bones/bone" {
  18859. interface Bone {
  18860. /**
  18861. * Copy an animation range from another bone
  18862. * @param source defines the source bone
  18863. * @param rangeName defines the range name to copy
  18864. * @param frameOffset defines the frame offset
  18865. * @param rescaleAsRequired defines if rescaling must be applied if required
  18866. * @param skelDimensionsRatio defines the scaling ratio
  18867. * @returns true if operation was successful
  18868. */
  18869. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18870. }
  18871. }
  18872. }
  18873. declare module "babylonjs/Bones/skeleton" {
  18874. import { Bone } from "babylonjs/Bones/bone";
  18875. import { IAnimatable } from "babylonjs/Misc/tools";
  18876. import { Observable } from "babylonjs/Misc/observable";
  18877. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18878. import { Scene } from "babylonjs/scene";
  18879. import { Nullable } from "babylonjs/types";
  18880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18881. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18882. import { Animatable } from "babylonjs/Animations/animatable";
  18883. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18884. import { Animation } from "babylonjs/Animations/animation";
  18885. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18886. /**
  18887. * Class used to handle skinning animations
  18888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18889. */
  18890. export class Skeleton implements IAnimatable {
  18891. /** defines the skeleton name */
  18892. name: string;
  18893. /** defines the skeleton Id */
  18894. id: string;
  18895. /**
  18896. * Defines the list of child bones
  18897. */
  18898. bones: Bone[];
  18899. /**
  18900. * Defines an estimate of the dimension of the skeleton at rest
  18901. */
  18902. dimensionsAtRest: Vector3;
  18903. /**
  18904. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18905. */
  18906. needInitialSkinMatrix: boolean;
  18907. /**
  18908. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18909. */
  18910. overrideMesh: Nullable<AbstractMesh>;
  18911. /**
  18912. * Gets the list of animations attached to this skeleton
  18913. */
  18914. animations: Array<Animation>;
  18915. private _scene;
  18916. private _isDirty;
  18917. private _transformMatrices;
  18918. private _transformMatrixTexture;
  18919. private _meshesWithPoseMatrix;
  18920. private _animatables;
  18921. private _identity;
  18922. private _synchronizedWithMesh;
  18923. private _ranges;
  18924. private _lastAbsoluteTransformsUpdateId;
  18925. private _canUseTextureForBones;
  18926. /** @hidden */
  18927. _numBonesWithLinkedTransformNode: number;
  18928. /**
  18929. * Specifies if the skeleton should be serialized
  18930. */
  18931. doNotSerialize: boolean;
  18932. /**
  18933. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18934. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18935. */
  18936. useTextureToStoreBoneMatrices: boolean;
  18937. private _animationPropertiesOverride;
  18938. /**
  18939. * Gets or sets the animation properties override
  18940. */
  18941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18942. /**
  18943. * An observable triggered before computing the skeleton's matrices
  18944. */
  18945. onBeforeComputeObservable: Observable<Skeleton>;
  18946. /**
  18947. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18948. */
  18949. readonly isUsingTextureForMatrices: boolean;
  18950. /**
  18951. * Creates a new skeleton
  18952. * @param name defines the skeleton name
  18953. * @param id defines the skeleton Id
  18954. * @param scene defines the hosting scene
  18955. */
  18956. constructor(
  18957. /** defines the skeleton name */
  18958. name: string,
  18959. /** defines the skeleton Id */
  18960. id: string, scene: Scene);
  18961. /**
  18962. * Gets the current object class name.
  18963. * @return the class name
  18964. */
  18965. getClassName(): string;
  18966. /**
  18967. * Returns an array containing the root bones
  18968. * @returns an array containing the root bones
  18969. */
  18970. getChildren(): Array<Bone>;
  18971. /**
  18972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18974. * @returns a Float32Array containing matrices data
  18975. */
  18976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18977. /**
  18978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18979. * @returns a raw texture containing the data
  18980. */
  18981. getTransformMatrixTexture(): Nullable<RawTexture>;
  18982. /**
  18983. * Gets the current hosting scene
  18984. * @returns a scene object
  18985. */
  18986. getScene(): Scene;
  18987. /**
  18988. * Gets a string representing the current skeleton data
  18989. * @param fullDetails defines a boolean indicating if we want a verbose version
  18990. * @returns a string representing the current skeleton data
  18991. */
  18992. toString(fullDetails?: boolean): string;
  18993. /**
  18994. * Get bone's index searching by name
  18995. * @param name defines bone's name to search for
  18996. * @return the indice of the bone. Returns -1 if not found
  18997. */
  18998. getBoneIndexByName(name: string): number;
  18999. /**
  19000. * Creater a new animation range
  19001. * @param name defines the name of the range
  19002. * @param from defines the start key
  19003. * @param to defines the end key
  19004. */
  19005. createAnimationRange(name: string, from: number, to: number): void;
  19006. /**
  19007. * Delete a specific animation range
  19008. * @param name defines the name of the range
  19009. * @param deleteFrames defines if frames must be removed as well
  19010. */
  19011. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19012. /**
  19013. * Gets a specific animation range
  19014. * @param name defines the name of the range to look for
  19015. * @returns the requested animation range or null if not found
  19016. */
  19017. getAnimationRange(name: string): Nullable<AnimationRange>;
  19018. /**
  19019. * Gets the list of all animation ranges defined on this skeleton
  19020. * @returns an array
  19021. */
  19022. getAnimationRanges(): Nullable<AnimationRange>[];
  19023. /**
  19024. * Copy animation range from a source skeleton.
  19025. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19026. * @param source defines the source skeleton
  19027. * @param name defines the name of the range to copy
  19028. * @param rescaleAsRequired defines if rescaling must be applied if required
  19029. * @returns true if operation was successful
  19030. */
  19031. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19032. /**
  19033. * Forces the skeleton to go to rest pose
  19034. */
  19035. returnToRest(): void;
  19036. private _getHighestAnimationFrame;
  19037. /**
  19038. * Begin a specific animation range
  19039. * @param name defines the name of the range to start
  19040. * @param loop defines if looping must be turned on (false by default)
  19041. * @param speedRatio defines the speed ratio to apply (1 by default)
  19042. * @param onAnimationEnd defines a callback which will be called when animation will end
  19043. * @returns a new animatable
  19044. */
  19045. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19046. /** @hidden */
  19047. _markAsDirty(): void;
  19048. /** @hidden */
  19049. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19050. /** @hidden */
  19051. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19052. private _computeTransformMatrices;
  19053. /**
  19054. * Build all resources required to render a skeleton
  19055. */
  19056. prepare(): void;
  19057. /**
  19058. * Gets the list of animatables currently running for this skeleton
  19059. * @returns an array of animatables
  19060. */
  19061. getAnimatables(): IAnimatable[];
  19062. /**
  19063. * Clone the current skeleton
  19064. * @param name defines the name of the new skeleton
  19065. * @param id defines the id of the enw skeleton
  19066. * @returns the new skeleton
  19067. */
  19068. clone(name: string, id: string): Skeleton;
  19069. /**
  19070. * Enable animation blending for this skeleton
  19071. * @param blendingSpeed defines the blending speed to apply
  19072. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19073. */
  19074. enableBlending(blendingSpeed?: number): void;
  19075. /**
  19076. * Releases all resources associated with the current skeleton
  19077. */
  19078. dispose(): void;
  19079. /**
  19080. * Serialize the skeleton in a JSON object
  19081. * @returns a JSON object
  19082. */
  19083. serialize(): any;
  19084. /**
  19085. * Creates a new skeleton from serialized data
  19086. * @param parsedSkeleton defines the serialized data
  19087. * @param scene defines the hosting scene
  19088. * @returns a new skeleton
  19089. */
  19090. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19091. /**
  19092. * Compute all node absolute transforms
  19093. * @param forceUpdate defines if computation must be done even if cache is up to date
  19094. */
  19095. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19096. /**
  19097. * Gets the root pose matrix
  19098. * @returns a matrix
  19099. */
  19100. getPoseMatrix(): Nullable<Matrix>;
  19101. /**
  19102. * Sorts bones per internal index
  19103. */
  19104. sortBones(): void;
  19105. private _sortBones;
  19106. }
  19107. }
  19108. declare module "babylonjs/Morph/morphTarget" {
  19109. import { IAnimatable } from "babylonjs/Misc/tools";
  19110. import { Observable } from "babylonjs/Misc/observable";
  19111. import { Nullable, FloatArray } from "babylonjs/types";
  19112. import { Scene } from "babylonjs/scene";
  19113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19114. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19115. /**
  19116. * Defines a target to use with MorphTargetManager
  19117. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19118. */
  19119. export class MorphTarget implements IAnimatable {
  19120. /** defines the name of the target */
  19121. name: string;
  19122. /**
  19123. * Gets or sets the list of animations
  19124. */
  19125. animations: import("babylonjs/Animations/animation").Animation[];
  19126. private _scene;
  19127. private _positions;
  19128. private _normals;
  19129. private _tangents;
  19130. private _influence;
  19131. /**
  19132. * Observable raised when the influence changes
  19133. */
  19134. onInfluenceChanged: Observable<boolean>;
  19135. /** @hidden */
  19136. _onDataLayoutChanged: Observable<void>;
  19137. /**
  19138. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19139. */
  19140. influence: number;
  19141. /**
  19142. * Gets or sets the id of the morph Target
  19143. */
  19144. id: string;
  19145. private _animationPropertiesOverride;
  19146. /**
  19147. * Gets or sets the animation properties override
  19148. */
  19149. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19150. /**
  19151. * Creates a new MorphTarget
  19152. * @param name defines the name of the target
  19153. * @param influence defines the influence to use
  19154. * @param scene defines the scene the morphtarget belongs to
  19155. */
  19156. constructor(
  19157. /** defines the name of the target */
  19158. name: string, influence?: number, scene?: Nullable<Scene>);
  19159. /**
  19160. * Gets a boolean defining if the target contains position data
  19161. */
  19162. readonly hasPositions: boolean;
  19163. /**
  19164. * Gets a boolean defining if the target contains normal data
  19165. */
  19166. readonly hasNormals: boolean;
  19167. /**
  19168. * Gets a boolean defining if the target contains tangent data
  19169. */
  19170. readonly hasTangents: boolean;
  19171. /**
  19172. * Affects position data to this target
  19173. * @param data defines the position data to use
  19174. */
  19175. setPositions(data: Nullable<FloatArray>): void;
  19176. /**
  19177. * Gets the position data stored in this target
  19178. * @returns a FloatArray containing the position data (or null if not present)
  19179. */
  19180. getPositions(): Nullable<FloatArray>;
  19181. /**
  19182. * Affects normal data to this target
  19183. * @param data defines the normal data to use
  19184. */
  19185. setNormals(data: Nullable<FloatArray>): void;
  19186. /**
  19187. * Gets the normal data stored in this target
  19188. * @returns a FloatArray containing the normal data (or null if not present)
  19189. */
  19190. getNormals(): Nullable<FloatArray>;
  19191. /**
  19192. * Affects tangent data to this target
  19193. * @param data defines the tangent data to use
  19194. */
  19195. setTangents(data: Nullable<FloatArray>): void;
  19196. /**
  19197. * Gets the tangent data stored in this target
  19198. * @returns a FloatArray containing the tangent data (or null if not present)
  19199. */
  19200. getTangents(): Nullable<FloatArray>;
  19201. /**
  19202. * Serializes the current target into a Serialization object
  19203. * @returns the serialized object
  19204. */
  19205. serialize(): any;
  19206. /**
  19207. * Returns the string "MorphTarget"
  19208. * @returns "MorphTarget"
  19209. */
  19210. getClassName(): string;
  19211. /**
  19212. * Creates a new target from serialized data
  19213. * @param serializationObject defines the serialized data to use
  19214. * @returns a new MorphTarget
  19215. */
  19216. static Parse(serializationObject: any): MorphTarget;
  19217. /**
  19218. * Creates a MorphTarget from mesh data
  19219. * @param mesh defines the source mesh
  19220. * @param name defines the name to use for the new target
  19221. * @param influence defines the influence to attach to the target
  19222. * @returns a new MorphTarget
  19223. */
  19224. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19225. }
  19226. }
  19227. declare module "babylonjs/Morph/morphTargetManager" {
  19228. import { Nullable } from "babylonjs/types";
  19229. import { Scene } from "babylonjs/scene";
  19230. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19231. /**
  19232. * This class is used to deform meshes using morphing between different targets
  19233. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19234. */
  19235. export class MorphTargetManager {
  19236. private _targets;
  19237. private _targetInfluenceChangedObservers;
  19238. private _targetDataLayoutChangedObservers;
  19239. private _activeTargets;
  19240. private _scene;
  19241. private _influences;
  19242. private _supportsNormals;
  19243. private _supportsTangents;
  19244. private _vertexCount;
  19245. private _uniqueId;
  19246. private _tempInfluences;
  19247. /**
  19248. * Creates a new MorphTargetManager
  19249. * @param scene defines the current scene
  19250. */
  19251. constructor(scene?: Nullable<Scene>);
  19252. /**
  19253. * Gets the unique ID of this manager
  19254. */
  19255. readonly uniqueId: number;
  19256. /**
  19257. * Gets the number of vertices handled by this manager
  19258. */
  19259. readonly vertexCount: number;
  19260. /**
  19261. * Gets a boolean indicating if this manager supports morphing of normals
  19262. */
  19263. readonly supportsNormals: boolean;
  19264. /**
  19265. * Gets a boolean indicating if this manager supports morphing of tangents
  19266. */
  19267. readonly supportsTangents: boolean;
  19268. /**
  19269. * Gets the number of targets stored in this manager
  19270. */
  19271. readonly numTargets: number;
  19272. /**
  19273. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19274. */
  19275. readonly numInfluencers: number;
  19276. /**
  19277. * Gets the list of influences (one per target)
  19278. */
  19279. readonly influences: Float32Array;
  19280. /**
  19281. * Gets the active target at specified index. An active target is a target with an influence > 0
  19282. * @param index defines the index to check
  19283. * @returns the requested target
  19284. */
  19285. getActiveTarget(index: number): MorphTarget;
  19286. /**
  19287. * Gets the target at specified index
  19288. * @param index defines the index to check
  19289. * @returns the requested target
  19290. */
  19291. getTarget(index: number): MorphTarget;
  19292. /**
  19293. * Add a new target to this manager
  19294. * @param target defines the target to add
  19295. */
  19296. addTarget(target: MorphTarget): void;
  19297. /**
  19298. * Removes a target from the manager
  19299. * @param target defines the target to remove
  19300. */
  19301. removeTarget(target: MorphTarget): void;
  19302. /**
  19303. * Serializes the current manager into a Serialization object
  19304. * @returns the serialized object
  19305. */
  19306. serialize(): any;
  19307. private _syncActiveTargets;
  19308. /**
  19309. * Syncrhonize the targets with all the meshes using this morph target manager
  19310. */
  19311. synchronize(): void;
  19312. /**
  19313. * Creates a new MorphTargetManager from serialized data
  19314. * @param serializationObject defines the serialized data
  19315. * @param scene defines the hosting scene
  19316. * @returns the new MorphTargetManager
  19317. */
  19318. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19319. }
  19320. }
  19321. declare module "babylonjs/Meshes/groundMesh" {
  19322. import { Scene } from "babylonjs/scene";
  19323. import { Vector3 } from "babylonjs/Maths/math";
  19324. import { Mesh } from "babylonjs/Meshes/mesh";
  19325. /**
  19326. * Mesh representing the gorund
  19327. */
  19328. export class GroundMesh extends Mesh {
  19329. /** If octree should be generated */
  19330. generateOctree: boolean;
  19331. private _heightQuads;
  19332. /** @hidden */
  19333. _subdivisionsX: number;
  19334. /** @hidden */
  19335. _subdivisionsY: number;
  19336. /** @hidden */
  19337. _width: number;
  19338. /** @hidden */
  19339. _height: number;
  19340. /** @hidden */
  19341. _minX: number;
  19342. /** @hidden */
  19343. _maxX: number;
  19344. /** @hidden */
  19345. _minZ: number;
  19346. /** @hidden */
  19347. _maxZ: number;
  19348. constructor(name: string, scene: Scene);
  19349. /**
  19350. * "GroundMesh"
  19351. * @returns "GroundMesh"
  19352. */
  19353. getClassName(): string;
  19354. /**
  19355. * The minimum of x and y subdivisions
  19356. */
  19357. readonly subdivisions: number;
  19358. /**
  19359. * X subdivisions
  19360. */
  19361. readonly subdivisionsX: number;
  19362. /**
  19363. * Y subdivisions
  19364. */
  19365. readonly subdivisionsY: number;
  19366. /**
  19367. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19368. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19369. * @param chunksCount the number of subdivisions for x and y
  19370. * @param octreeBlocksSize (Default: 32)
  19371. */
  19372. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19373. /**
  19374. * Returns a height (y) value in the Worl system :
  19375. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19376. * @param x x coordinate
  19377. * @param z z coordinate
  19378. * @returns the ground y position if (x, z) are outside the ground surface.
  19379. */
  19380. getHeightAtCoordinates(x: number, z: number): number;
  19381. /**
  19382. * Returns a normalized vector (Vector3) orthogonal to the ground
  19383. * at the ground coordinates (x, z) expressed in the World system.
  19384. * @param x x coordinate
  19385. * @param z z coordinate
  19386. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19387. */
  19388. getNormalAtCoordinates(x: number, z: number): Vector3;
  19389. /**
  19390. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19391. * at the ground coordinates (x, z) expressed in the World system.
  19392. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19393. * @param x x coordinate
  19394. * @param z z coordinate
  19395. * @param ref vector to store the result
  19396. * @returns the GroundMesh.
  19397. */
  19398. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19399. /**
  19400. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19401. * if the ground has been updated.
  19402. * This can be used in the render loop.
  19403. * @returns the GroundMesh.
  19404. */
  19405. updateCoordinateHeights(): GroundMesh;
  19406. private _getFacetAt;
  19407. private _initHeightQuads;
  19408. private _computeHeightQuads;
  19409. /**
  19410. * Serializes this ground mesh
  19411. * @param serializationObject object to write serialization to
  19412. */
  19413. serialize(serializationObject: any): void;
  19414. /**
  19415. * Parses a serialized ground mesh
  19416. * @param parsedMesh the serialized mesh
  19417. * @param scene the scene to create the ground mesh in
  19418. * @returns the created ground mesh
  19419. */
  19420. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19421. }
  19422. }
  19423. declare module "babylonjs/Physics/physicsJoint" {
  19424. import { Vector3 } from "babylonjs/Maths/math";
  19425. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19426. /**
  19427. * Interface for Physics-Joint data
  19428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19429. */
  19430. export interface PhysicsJointData {
  19431. /**
  19432. * The main pivot of the joint
  19433. */
  19434. mainPivot?: Vector3;
  19435. /**
  19436. * The connected pivot of the joint
  19437. */
  19438. connectedPivot?: Vector3;
  19439. /**
  19440. * The main axis of the joint
  19441. */
  19442. mainAxis?: Vector3;
  19443. /**
  19444. * The connected axis of the joint
  19445. */
  19446. connectedAxis?: Vector3;
  19447. /**
  19448. * The collision of the joint
  19449. */
  19450. collision?: boolean;
  19451. /**
  19452. * Native Oimo/Cannon/Energy data
  19453. */
  19454. nativeParams?: any;
  19455. }
  19456. /**
  19457. * This is a holder class for the physics joint created by the physics plugin
  19458. * It holds a set of functions to control the underlying joint
  19459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19460. */
  19461. export class PhysicsJoint {
  19462. /**
  19463. * The type of the physics joint
  19464. */
  19465. type: number;
  19466. /**
  19467. * The data for the physics joint
  19468. */
  19469. jointData: PhysicsJointData;
  19470. private _physicsJoint;
  19471. protected _physicsPlugin: IPhysicsEnginePlugin;
  19472. /**
  19473. * Initializes the physics joint
  19474. * @param type The type of the physics joint
  19475. * @param jointData The data for the physics joint
  19476. */
  19477. constructor(
  19478. /**
  19479. * The type of the physics joint
  19480. */
  19481. type: number,
  19482. /**
  19483. * The data for the physics joint
  19484. */
  19485. jointData: PhysicsJointData);
  19486. /**
  19487. * Gets the physics joint
  19488. */
  19489. /**
  19490. * Sets the physics joint
  19491. */
  19492. physicsJoint: any;
  19493. /**
  19494. * Sets the physics plugin
  19495. */
  19496. physicsPlugin: IPhysicsEnginePlugin;
  19497. /**
  19498. * Execute a function that is physics-plugin specific.
  19499. * @param {Function} func the function that will be executed.
  19500. * It accepts two parameters: the physics world and the physics joint
  19501. */
  19502. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19503. /**
  19504. * Distance-Joint type
  19505. */
  19506. static DistanceJoint: number;
  19507. /**
  19508. * Hinge-Joint type
  19509. */
  19510. static HingeJoint: number;
  19511. /**
  19512. * Ball-and-Socket joint type
  19513. */
  19514. static BallAndSocketJoint: number;
  19515. /**
  19516. * Wheel-Joint type
  19517. */
  19518. static WheelJoint: number;
  19519. /**
  19520. * Slider-Joint type
  19521. */
  19522. static SliderJoint: number;
  19523. /**
  19524. * Prismatic-Joint type
  19525. */
  19526. static PrismaticJoint: number;
  19527. /**
  19528. * Universal-Joint type
  19529. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19530. */
  19531. static UniversalJoint: number;
  19532. /**
  19533. * Hinge-Joint 2 type
  19534. */
  19535. static Hinge2Joint: number;
  19536. /**
  19537. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19538. */
  19539. static PointToPointJoint: number;
  19540. /**
  19541. * Spring-Joint type
  19542. */
  19543. static SpringJoint: number;
  19544. /**
  19545. * Lock-Joint type
  19546. */
  19547. static LockJoint: number;
  19548. }
  19549. /**
  19550. * A class representing a physics distance joint
  19551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19552. */
  19553. export class DistanceJoint extends PhysicsJoint {
  19554. /**
  19555. *
  19556. * @param jointData The data for the Distance-Joint
  19557. */
  19558. constructor(jointData: DistanceJointData);
  19559. /**
  19560. * Update the predefined distance.
  19561. * @param maxDistance The maximum preferred distance
  19562. * @param minDistance The minimum preferred distance
  19563. */
  19564. updateDistance(maxDistance: number, minDistance?: number): void;
  19565. }
  19566. /**
  19567. * Represents a Motor-Enabled Joint
  19568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19569. */
  19570. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19571. /**
  19572. * Initializes the Motor-Enabled Joint
  19573. * @param type The type of the joint
  19574. * @param jointData The physica joint data for the joint
  19575. */
  19576. constructor(type: number, jointData: PhysicsJointData);
  19577. /**
  19578. * Set the motor values.
  19579. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19580. * @param force the force to apply
  19581. * @param maxForce max force for this motor.
  19582. */
  19583. setMotor(force?: number, maxForce?: number): void;
  19584. /**
  19585. * Set the motor's limits.
  19586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19587. * @param upperLimit The upper limit of the motor
  19588. * @param lowerLimit The lower limit of the motor
  19589. */
  19590. setLimit(upperLimit: number, lowerLimit?: number): void;
  19591. }
  19592. /**
  19593. * This class represents a single physics Hinge-Joint
  19594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19595. */
  19596. export class HingeJoint extends MotorEnabledJoint {
  19597. /**
  19598. * Initializes the Hinge-Joint
  19599. * @param jointData The joint data for the Hinge-Joint
  19600. */
  19601. constructor(jointData: PhysicsJointData);
  19602. /**
  19603. * Set the motor values.
  19604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19605. * @param {number} force the force to apply
  19606. * @param {number} maxForce max force for this motor.
  19607. */
  19608. setMotor(force?: number, maxForce?: number): void;
  19609. /**
  19610. * Set the motor's limits.
  19611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19612. * @param upperLimit The upper limit of the motor
  19613. * @param lowerLimit The lower limit of the motor
  19614. */
  19615. setLimit(upperLimit: number, lowerLimit?: number): void;
  19616. }
  19617. /**
  19618. * This class represents a dual hinge physics joint (same as wheel joint)
  19619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19620. */
  19621. export class Hinge2Joint extends MotorEnabledJoint {
  19622. /**
  19623. * Initializes the Hinge2-Joint
  19624. * @param jointData The joint data for the Hinge2-Joint
  19625. */
  19626. constructor(jointData: PhysicsJointData);
  19627. /**
  19628. * Set the motor values.
  19629. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19630. * @param {number} targetSpeed the speed the motor is to reach
  19631. * @param {number} maxForce max force for this motor.
  19632. * @param {motorIndex} the motor's index, 0 or 1.
  19633. */
  19634. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19635. /**
  19636. * Set the motor limits.
  19637. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19638. * @param {number} upperLimit the upper limit
  19639. * @param {number} lowerLimit lower limit
  19640. * @param {motorIndex} the motor's index, 0 or 1.
  19641. */
  19642. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19643. }
  19644. /**
  19645. * Interface for a motor enabled joint
  19646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19647. */
  19648. export interface IMotorEnabledJoint {
  19649. /**
  19650. * Physics joint
  19651. */
  19652. physicsJoint: any;
  19653. /**
  19654. * Sets the motor of the motor-enabled joint
  19655. * @param force The force of the motor
  19656. * @param maxForce The maximum force of the motor
  19657. * @param motorIndex The index of the motor
  19658. */
  19659. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19660. /**
  19661. * Sets the limit of the motor
  19662. * @param upperLimit The upper limit of the motor
  19663. * @param lowerLimit The lower limit of the motor
  19664. * @param motorIndex The index of the motor
  19665. */
  19666. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19667. }
  19668. /**
  19669. * Joint data for a Distance-Joint
  19670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19671. */
  19672. export interface DistanceJointData extends PhysicsJointData {
  19673. /**
  19674. * Max distance the 2 joint objects can be apart
  19675. */
  19676. maxDistance: number;
  19677. }
  19678. /**
  19679. * Joint data from a spring joint
  19680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19681. */
  19682. export interface SpringJointData extends PhysicsJointData {
  19683. /**
  19684. * Length of the spring
  19685. */
  19686. length: number;
  19687. /**
  19688. * Stiffness of the spring
  19689. */
  19690. stiffness: number;
  19691. /**
  19692. * Damping of the spring
  19693. */
  19694. damping: number;
  19695. /** this callback will be called when applying the force to the impostors. */
  19696. forceApplicationCallback: () => void;
  19697. }
  19698. }
  19699. declare module "babylonjs/Physics/IPhysicsEngine" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19703. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19704. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19705. /**
  19706. * Interface used to describe a physics joint
  19707. */
  19708. export interface PhysicsImpostorJoint {
  19709. /** Defines the main impostor to which the joint is linked */
  19710. mainImpostor: PhysicsImpostor;
  19711. /** Defines the impostor that is connected to the main impostor using this joint */
  19712. connectedImpostor: PhysicsImpostor;
  19713. /** Defines the joint itself */
  19714. joint: PhysicsJoint;
  19715. }
  19716. /** @hidden */
  19717. export interface IPhysicsEnginePlugin {
  19718. world: any;
  19719. name: string;
  19720. setGravity(gravity: Vector3): void;
  19721. setTimeStep(timeStep: number): void;
  19722. getTimeStep(): number;
  19723. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19726. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19727. removePhysicsBody(impostor: PhysicsImpostor): void;
  19728. generateJoint(joint: PhysicsImpostorJoint): void;
  19729. removeJoint(joint: PhysicsImpostorJoint): void;
  19730. isSupported(): boolean;
  19731. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19733. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19735. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19737. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19738. getBodyMass(impostor: PhysicsImpostor): number;
  19739. getBodyFriction(impostor: PhysicsImpostor): number;
  19740. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19741. getBodyRestitution(impostor: PhysicsImpostor): number;
  19742. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19743. sleepBody(impostor: PhysicsImpostor): void;
  19744. wakeUpBody(impostor: PhysicsImpostor): void;
  19745. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19746. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19747. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19748. getRadius(impostor: PhysicsImpostor): number;
  19749. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19750. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19751. dispose(): void;
  19752. }
  19753. /**
  19754. * Interface used to define a physics engine
  19755. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface IPhysicsEngine {
  19758. /**
  19759. * Gets the gravity vector used by the simulation
  19760. */
  19761. gravity: Vector3;
  19762. /**
  19763. * Sets the gravity vector used by the simulation
  19764. * @param gravity defines the gravity vector to use
  19765. */
  19766. setGravity(gravity: Vector3): void;
  19767. /**
  19768. * Set the time step of the physics engine.
  19769. * Default is 1/60.
  19770. * To slow it down, enter 1/600 for example.
  19771. * To speed it up, 1/30
  19772. * @param newTimeStep the new timestep to apply to this world.
  19773. */
  19774. setTimeStep(newTimeStep: number): void;
  19775. /**
  19776. * Get the time step of the physics engine.
  19777. * @returns the current time step
  19778. */
  19779. getTimeStep(): number;
  19780. /**
  19781. * Release all resources
  19782. */
  19783. dispose(): void;
  19784. /**
  19785. * Gets the name of the current physics plugin
  19786. * @returns the name of the plugin
  19787. */
  19788. getPhysicsPluginName(): string;
  19789. /**
  19790. * Adding a new impostor for the impostor tracking.
  19791. * This will be done by the impostor itself.
  19792. * @param impostor the impostor to add
  19793. */
  19794. addImpostor(impostor: PhysicsImpostor): void;
  19795. /**
  19796. * Remove an impostor from the engine.
  19797. * This impostor and its mesh will not longer be updated by the physics engine.
  19798. * @param impostor the impostor to remove
  19799. */
  19800. removeImpostor(impostor: PhysicsImpostor): void;
  19801. /**
  19802. * Add a joint to the physics engine
  19803. * @param mainImpostor defines the main impostor to which the joint is added.
  19804. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19805. * @param joint defines the joint that will connect both impostors.
  19806. */
  19807. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19808. /**
  19809. * Removes a joint from the simulation
  19810. * @param mainImpostor defines the impostor used with the joint
  19811. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19812. * @param joint defines the joint to remove
  19813. */
  19814. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19815. /**
  19816. * Gets the current plugin used to run the simulation
  19817. * @returns current plugin
  19818. */
  19819. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19820. /**
  19821. * Gets the list of physic impostors
  19822. * @returns an array of PhysicsImpostor
  19823. */
  19824. getImpostors(): Array<PhysicsImpostor>;
  19825. /**
  19826. * Gets the impostor for a physics enabled object
  19827. * @param object defines the object impersonated by the impostor
  19828. * @returns the PhysicsImpostor or null if not found
  19829. */
  19830. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19831. /**
  19832. * Gets the impostor for a physics body object
  19833. * @param body defines physics body used by the impostor
  19834. * @returns the PhysicsImpostor or null if not found
  19835. */
  19836. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19837. /**
  19838. * Called by the scene. No need to call it.
  19839. * @param delta defines the timespam between frames
  19840. */
  19841. _step(delta: number): void;
  19842. }
  19843. }
  19844. declare module "babylonjs/Physics/physicsImpostor" {
  19845. import { Nullable, IndicesArray } from "babylonjs/types";
  19846. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19849. import { Scene } from "babylonjs/scene";
  19850. import { Bone } from "babylonjs/Bones/bone";
  19851. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19852. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19853. /**
  19854. * The interface for the physics imposter parameters
  19855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19856. */
  19857. export interface PhysicsImpostorParameters {
  19858. /**
  19859. * The mass of the physics imposter
  19860. */
  19861. mass: number;
  19862. /**
  19863. * The friction of the physics imposter
  19864. */
  19865. friction?: number;
  19866. /**
  19867. * The coefficient of restitution of the physics imposter
  19868. */
  19869. restitution?: number;
  19870. /**
  19871. * The native options of the physics imposter
  19872. */
  19873. nativeOptions?: any;
  19874. /**
  19875. * Specifies if the parent should be ignored
  19876. */
  19877. ignoreParent?: boolean;
  19878. /**
  19879. * Specifies if bi-directional transformations should be disabled
  19880. */
  19881. disableBidirectionalTransformation?: boolean;
  19882. }
  19883. /**
  19884. * Interface for a physics-enabled object
  19885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19886. */
  19887. export interface IPhysicsEnabledObject {
  19888. /**
  19889. * The position of the physics-enabled object
  19890. */
  19891. position: Vector3;
  19892. /**
  19893. * The rotation of the physics-enabled object
  19894. */
  19895. rotationQuaternion: Nullable<Quaternion>;
  19896. /**
  19897. * The scale of the physics-enabled object
  19898. */
  19899. scaling: Vector3;
  19900. /**
  19901. * The rotation of the physics-enabled object
  19902. */
  19903. rotation?: Vector3;
  19904. /**
  19905. * The parent of the physics-enabled object
  19906. */
  19907. parent?: any;
  19908. /**
  19909. * The bounding info of the physics-enabled object
  19910. * @returns The bounding info of the physics-enabled object
  19911. */
  19912. getBoundingInfo(): BoundingInfo;
  19913. /**
  19914. * Computes the world matrix
  19915. * @param force Specifies if the world matrix should be computed by force
  19916. * @returns A world matrix
  19917. */
  19918. computeWorldMatrix(force: boolean): Matrix;
  19919. /**
  19920. * Gets the world matrix
  19921. * @returns A world matrix
  19922. */
  19923. getWorldMatrix?(): Matrix;
  19924. /**
  19925. * Gets the child meshes
  19926. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19927. * @returns An array of abstract meshes
  19928. */
  19929. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19930. /**
  19931. * Gets the vertex data
  19932. * @param kind The type of vertex data
  19933. * @returns A nullable array of numbers, or a float32 array
  19934. */
  19935. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19936. /**
  19937. * Gets the indices from the mesh
  19938. * @returns A nullable array of index arrays
  19939. */
  19940. getIndices?(): Nullable<IndicesArray>;
  19941. /**
  19942. * Gets the scene from the mesh
  19943. * @returns the indices array or null
  19944. */
  19945. getScene?(): Scene;
  19946. /**
  19947. * Gets the absolute position from the mesh
  19948. * @returns the absolute position
  19949. */
  19950. getAbsolutePosition(): Vector3;
  19951. /**
  19952. * Gets the absolute pivot point from the mesh
  19953. * @returns the absolute pivot point
  19954. */
  19955. getAbsolutePivotPoint(): Vector3;
  19956. /**
  19957. * Rotates the mesh
  19958. * @param axis The axis of rotation
  19959. * @param amount The amount of rotation
  19960. * @param space The space of the rotation
  19961. * @returns The rotation transform node
  19962. */
  19963. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19964. /**
  19965. * Translates the mesh
  19966. * @param axis The axis of translation
  19967. * @param distance The distance of translation
  19968. * @param space The space of the translation
  19969. * @returns The transform node
  19970. */
  19971. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19972. /**
  19973. * Sets the absolute position of the mesh
  19974. * @param absolutePosition The absolute position of the mesh
  19975. * @returns The transform node
  19976. */
  19977. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19978. /**
  19979. * Gets the class name of the mesh
  19980. * @returns The class name
  19981. */
  19982. getClassName(): string;
  19983. }
  19984. /**
  19985. * Represents a physics imposter
  19986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19987. */
  19988. export class PhysicsImpostor {
  19989. /**
  19990. * The physics-enabled object used as the physics imposter
  19991. */
  19992. object: IPhysicsEnabledObject;
  19993. /**
  19994. * The type of the physics imposter
  19995. */
  19996. type: number;
  19997. private _options;
  19998. private _scene?;
  19999. /**
  20000. * The default object size of the imposter
  20001. */
  20002. static DEFAULT_OBJECT_SIZE: Vector3;
  20003. /**
  20004. * The identity quaternion of the imposter
  20005. */
  20006. static IDENTITY_QUATERNION: Quaternion;
  20007. /** @hidden */
  20008. _pluginData: any;
  20009. private _physicsEngine;
  20010. private _physicsBody;
  20011. private _bodyUpdateRequired;
  20012. private _onBeforePhysicsStepCallbacks;
  20013. private _onAfterPhysicsStepCallbacks;
  20014. /** @hidden */
  20015. _onPhysicsCollideCallbacks: Array<{
  20016. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20017. otherImpostors: Array<PhysicsImpostor>;
  20018. }>;
  20019. private _deltaPosition;
  20020. private _deltaRotation;
  20021. private _deltaRotationConjugated;
  20022. private _parent;
  20023. private _isDisposed;
  20024. private static _tmpVecs;
  20025. private static _tmpQuat;
  20026. /**
  20027. * Specifies if the physics imposter is disposed
  20028. */
  20029. readonly isDisposed: boolean;
  20030. /**
  20031. * Gets the mass of the physics imposter
  20032. */
  20033. mass: number;
  20034. /**
  20035. * Gets the coefficient of friction
  20036. */
  20037. /**
  20038. * Sets the coefficient of friction
  20039. */
  20040. friction: number;
  20041. /**
  20042. * Gets the coefficient of restitution
  20043. */
  20044. /**
  20045. * Sets the coefficient of restitution
  20046. */
  20047. restitution: number;
  20048. /**
  20049. * The unique id of the physics imposter
  20050. * set by the physics engine when adding this impostor to the array
  20051. */
  20052. uniqueId: number;
  20053. private _joints;
  20054. /**
  20055. * Initializes the physics imposter
  20056. * @param object The physics-enabled object used as the physics imposter
  20057. * @param type The type of the physics imposter
  20058. * @param _options The options for the physics imposter
  20059. * @param _scene The Babylon scene
  20060. */
  20061. constructor(
  20062. /**
  20063. * The physics-enabled object used as the physics imposter
  20064. */
  20065. object: IPhysicsEnabledObject,
  20066. /**
  20067. * The type of the physics imposter
  20068. */
  20069. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20070. /**
  20071. * This function will completly initialize this impostor.
  20072. * It will create a new body - but only if this mesh has no parent.
  20073. * If it has, this impostor will not be used other than to define the impostor
  20074. * of the child mesh.
  20075. * @hidden
  20076. */
  20077. _init(): void;
  20078. private _getPhysicsParent;
  20079. /**
  20080. * Should a new body be generated.
  20081. * @returns boolean specifying if body initialization is required
  20082. */
  20083. isBodyInitRequired(): boolean;
  20084. /**
  20085. * Sets the updated scaling
  20086. * @param updated Specifies if the scaling is updated
  20087. */
  20088. setScalingUpdated(): void;
  20089. /**
  20090. * Force a regeneration of this or the parent's impostor's body.
  20091. * Use under cautious - This will remove all joints already implemented.
  20092. */
  20093. forceUpdate(): void;
  20094. /**
  20095. * Gets the body that holds this impostor. Either its own, or its parent.
  20096. */
  20097. /**
  20098. * Set the physics body. Used mainly by the physics engine/plugin
  20099. */
  20100. physicsBody: any;
  20101. /**
  20102. * Get the parent of the physics imposter
  20103. * @returns Physics imposter or null
  20104. */
  20105. /**
  20106. * Sets the parent of the physics imposter
  20107. */
  20108. parent: Nullable<PhysicsImpostor>;
  20109. /**
  20110. * Resets the update flags
  20111. */
  20112. resetUpdateFlags(): void;
  20113. /**
  20114. * Gets the object extend size
  20115. * @returns the object extend size
  20116. */
  20117. getObjectExtendSize(): Vector3;
  20118. /**
  20119. * Gets the object center
  20120. * @returns The object center
  20121. */
  20122. getObjectCenter(): Vector3;
  20123. /**
  20124. * Get a specific parametes from the options parameter
  20125. * @param paramName The object parameter name
  20126. * @returns The object parameter
  20127. */
  20128. getParam(paramName: string): any;
  20129. /**
  20130. * Sets a specific parameter in the options given to the physics plugin
  20131. * @param paramName The parameter name
  20132. * @param value The value of the parameter
  20133. */
  20134. setParam(paramName: string, value: number): void;
  20135. /**
  20136. * Specifically change the body's mass option. Won't recreate the physics body object
  20137. * @param mass The mass of the physics imposter
  20138. */
  20139. setMass(mass: number): void;
  20140. /**
  20141. * Gets the linear velocity
  20142. * @returns linear velocity or null
  20143. */
  20144. getLinearVelocity(): Nullable<Vector3>;
  20145. /**
  20146. * Sets the linear velocity
  20147. * @param velocity linear velocity or null
  20148. */
  20149. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20150. /**
  20151. * Gets the angular velocity
  20152. * @returns angular velocity or null
  20153. */
  20154. getAngularVelocity(): Nullable<Vector3>;
  20155. /**
  20156. * Sets the angular velocity
  20157. * @param velocity The velocity or null
  20158. */
  20159. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20160. /**
  20161. * Execute a function with the physics plugin native code
  20162. * Provide a function the will have two variables - the world object and the physics body object
  20163. * @param func The function to execute with the physics plugin native code
  20164. */
  20165. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20166. /**
  20167. * Register a function that will be executed before the physics world is stepping forward
  20168. * @param func The function to execute before the physics world is stepped forward
  20169. */
  20170. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20171. /**
  20172. * Unregister a function that will be executed before the physics world is stepping forward
  20173. * @param func The function to execute before the physics world is stepped forward
  20174. */
  20175. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20176. /**
  20177. * Register a function that will be executed after the physics step
  20178. * @param func The function to execute after physics step
  20179. */
  20180. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20181. /**
  20182. * Unregisters a function that will be executed after the physics step
  20183. * @param func The function to execute after physics step
  20184. */
  20185. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20186. /**
  20187. * register a function that will be executed when this impostor collides against a different body
  20188. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20189. * @param func Callback that is executed on collision
  20190. */
  20191. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20192. /**
  20193. * Unregisters the physics imposter on contact
  20194. * @param collideAgainst The physics object to collide against
  20195. * @param func Callback to execute on collision
  20196. */
  20197. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20198. private _tmpQuat;
  20199. private _tmpQuat2;
  20200. /**
  20201. * Get the parent rotation
  20202. * @returns The parent rotation
  20203. */
  20204. getParentsRotation(): Quaternion;
  20205. /**
  20206. * this function is executed by the physics engine.
  20207. */
  20208. beforeStep: () => void;
  20209. /**
  20210. * this function is executed by the physics engine
  20211. */
  20212. afterStep: () => void;
  20213. /**
  20214. * Legacy collision detection event support
  20215. */
  20216. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20217. /**
  20218. * event and body object due to cannon's event-based architecture.
  20219. */
  20220. onCollide: (e: {
  20221. body: any;
  20222. }) => void;
  20223. /**
  20224. * Apply a force
  20225. * @param force The force to apply
  20226. * @param contactPoint The contact point for the force
  20227. * @returns The physics imposter
  20228. */
  20229. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20230. /**
  20231. * Apply an impulse
  20232. * @param force The impulse force
  20233. * @param contactPoint The contact point for the impulse force
  20234. * @returns The physics imposter
  20235. */
  20236. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20237. /**
  20238. * A help function to create a joint
  20239. * @param otherImpostor A physics imposter used to create a joint
  20240. * @param jointType The type of joint
  20241. * @param jointData The data for the joint
  20242. * @returns The physics imposter
  20243. */
  20244. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20245. /**
  20246. * Add a joint to this impostor with a different impostor
  20247. * @param otherImpostor A physics imposter used to add a joint
  20248. * @param joint The joint to add
  20249. * @returns The physics imposter
  20250. */
  20251. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20252. /**
  20253. * Will keep this body still, in a sleep mode.
  20254. * @returns the physics imposter
  20255. */
  20256. sleep(): PhysicsImpostor;
  20257. /**
  20258. * Wake the body up.
  20259. * @returns The physics imposter
  20260. */
  20261. wakeUp(): PhysicsImpostor;
  20262. /**
  20263. * Clones the physics imposter
  20264. * @param newObject The physics imposter clones to this physics-enabled object
  20265. * @returns A nullable physics imposter
  20266. */
  20267. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20268. /**
  20269. * Disposes the physics imposter
  20270. */
  20271. dispose(): void;
  20272. /**
  20273. * Sets the delta position
  20274. * @param position The delta position amount
  20275. */
  20276. setDeltaPosition(position: Vector3): void;
  20277. /**
  20278. * Sets the delta rotation
  20279. * @param rotation The delta rotation amount
  20280. */
  20281. setDeltaRotation(rotation: Quaternion): void;
  20282. /**
  20283. * Gets the box size of the physics imposter and stores the result in the input parameter
  20284. * @param result Stores the box size
  20285. * @returns The physics imposter
  20286. */
  20287. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20288. /**
  20289. * Gets the radius of the physics imposter
  20290. * @returns Radius of the physics imposter
  20291. */
  20292. getRadius(): number;
  20293. /**
  20294. * Sync a bone with this impostor
  20295. * @param bone The bone to sync to the impostor.
  20296. * @param boneMesh The mesh that the bone is influencing.
  20297. * @param jointPivot The pivot of the joint / bone in local space.
  20298. * @param distToJoint Optional distance from the impostor to the joint.
  20299. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20300. */
  20301. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20302. /**
  20303. * Sync impostor to a bone
  20304. * @param bone The bone that the impostor will be synced to.
  20305. * @param boneMesh The mesh that the bone is influencing.
  20306. * @param jointPivot The pivot of the joint / bone in local space.
  20307. * @param distToJoint Optional distance from the impostor to the joint.
  20308. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20309. * @param boneAxis Optional vector3 axis the bone is aligned with
  20310. */
  20311. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20312. /**
  20313. * No-Imposter type
  20314. */
  20315. static NoImpostor: number;
  20316. /**
  20317. * Sphere-Imposter type
  20318. */
  20319. static SphereImpostor: number;
  20320. /**
  20321. * Box-Imposter type
  20322. */
  20323. static BoxImpostor: number;
  20324. /**
  20325. * Plane-Imposter type
  20326. */
  20327. static PlaneImpostor: number;
  20328. /**
  20329. * Mesh-imposter type
  20330. */
  20331. static MeshImpostor: number;
  20332. /**
  20333. * Cylinder-Imposter type
  20334. */
  20335. static CylinderImpostor: number;
  20336. /**
  20337. * Particle-Imposter type
  20338. */
  20339. static ParticleImpostor: number;
  20340. /**
  20341. * Heightmap-Imposter type
  20342. */
  20343. static HeightmapImpostor: number;
  20344. }
  20345. }
  20346. declare module "babylonjs/Meshes/mesh" {
  20347. import { Observable } from "babylonjs/Misc/observable";
  20348. import { IAnimatable } from "babylonjs/Misc/tools";
  20349. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20350. import { Camera } from "babylonjs/Cameras/camera";
  20351. import { Scene } from "babylonjs/scene";
  20352. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20353. import { Engine } from "babylonjs/Engines/engine";
  20354. import { Node } from "babylonjs/node";
  20355. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20356. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20357. import { Buffer } from "babylonjs/Meshes/buffer";
  20358. import { Geometry } from "babylonjs/Meshes/geometry";
  20359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20361. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20362. import { Effect } from "babylonjs/Materials/effect";
  20363. import { Material } from "babylonjs/Materials/material";
  20364. import { Skeleton } from "babylonjs/Bones/skeleton";
  20365. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20366. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20367. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20368. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20369. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20370. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20371. /**
  20372. * Class used to represent a specific level of detail of a mesh
  20373. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20374. */
  20375. export class MeshLODLevel {
  20376. /** Defines the distance where this level should star being displayed */
  20377. distance: number;
  20378. /** Defines the mesh to use to render this level */
  20379. mesh: Nullable<Mesh>;
  20380. /**
  20381. * Creates a new LOD level
  20382. * @param distance defines the distance where this level should star being displayed
  20383. * @param mesh defines the mesh to use to render this level
  20384. */
  20385. constructor(
  20386. /** Defines the distance where this level should star being displayed */
  20387. distance: number,
  20388. /** Defines the mesh to use to render this level */
  20389. mesh: Nullable<Mesh>);
  20390. }
  20391. /**
  20392. * @hidden
  20393. **/
  20394. export class _CreationDataStorage {
  20395. closePath?: boolean;
  20396. closeArray?: boolean;
  20397. idx: number[];
  20398. dashSize: number;
  20399. gapSize: number;
  20400. path3D: Path3D;
  20401. pathArray: Vector3[][];
  20402. arc: number;
  20403. radius: number;
  20404. cap: number;
  20405. tessellation: number;
  20406. }
  20407. /**
  20408. * @hidden
  20409. **/
  20410. class _InstanceDataStorage {
  20411. visibleInstances: any;
  20412. renderIdForInstances: number[];
  20413. batchCache: _InstancesBatch;
  20414. instancesBufferSize: number;
  20415. instancesBuffer: Nullable<Buffer>;
  20416. instancesData: Float32Array;
  20417. overridenInstanceCount: number;
  20418. }
  20419. /**
  20420. * @hidden
  20421. **/
  20422. export class _InstancesBatch {
  20423. mustReturn: boolean;
  20424. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20425. renderSelf: boolean[];
  20426. }
  20427. /**
  20428. * Class used to represent renderable models
  20429. */
  20430. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20431. /**
  20432. * Mesh side orientation : usually the external or front surface
  20433. */
  20434. static readonly FRONTSIDE: number;
  20435. /**
  20436. * Mesh side orientation : usually the internal or back surface
  20437. */
  20438. static readonly BACKSIDE: number;
  20439. /**
  20440. * Mesh side orientation : both internal and external or front and back surfaces
  20441. */
  20442. static readonly DOUBLESIDE: number;
  20443. /**
  20444. * Mesh side orientation : by default, `FRONTSIDE`
  20445. */
  20446. static readonly DEFAULTSIDE: number;
  20447. /**
  20448. * Mesh cap setting : no cap
  20449. */
  20450. static readonly NO_CAP: number;
  20451. /**
  20452. * Mesh cap setting : one cap at the beginning of the mesh
  20453. */
  20454. static readonly CAP_START: number;
  20455. /**
  20456. * Mesh cap setting : one cap at the end of the mesh
  20457. */
  20458. static readonly CAP_END: number;
  20459. /**
  20460. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20461. */
  20462. static readonly CAP_ALL: number;
  20463. /**
  20464. * Gets the default side orientation.
  20465. * @param orientation the orientation to value to attempt to get
  20466. * @returns the default orientation
  20467. * @hidden
  20468. */
  20469. static _GetDefaultSideOrientation(orientation?: number): number;
  20470. private _onBeforeRenderObservable;
  20471. private _onBeforeBindObservable;
  20472. private _onAfterRenderObservable;
  20473. private _onBeforeDrawObservable;
  20474. /**
  20475. * An event triggered before rendering the mesh
  20476. */
  20477. readonly onBeforeRenderObservable: Observable<Mesh>;
  20478. /**
  20479. * An event triggered before binding the mesh
  20480. */
  20481. readonly onBeforeBindObservable: Observable<Mesh>;
  20482. /**
  20483. * An event triggered after rendering the mesh
  20484. */
  20485. readonly onAfterRenderObservable: Observable<Mesh>;
  20486. /**
  20487. * An event triggered before drawing the mesh
  20488. */
  20489. readonly onBeforeDrawObservable: Observable<Mesh>;
  20490. private _onBeforeDrawObserver;
  20491. /**
  20492. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20493. */
  20494. onBeforeDraw: () => void;
  20495. /**
  20496. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20497. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20498. */
  20499. delayLoadState: number;
  20500. /**
  20501. * Gets the list of instances created from this mesh
  20502. * it is not supposed to be modified manually.
  20503. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20504. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20505. */
  20506. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20507. /**
  20508. * Gets the file containing delay loading data for this mesh
  20509. */
  20510. delayLoadingFile: string;
  20511. /** @hidden */
  20512. _binaryInfo: any;
  20513. private _LODLevels;
  20514. /**
  20515. * User defined function used to change how LOD level selection is done
  20516. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20517. */
  20518. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20519. private _morphTargetManager;
  20520. /**
  20521. * Gets or sets the morph target manager
  20522. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20523. */
  20524. morphTargetManager: Nullable<MorphTargetManager>;
  20525. /** @hidden */
  20526. _creationDataStorage: Nullable<_CreationDataStorage>;
  20527. /** @hidden */
  20528. _geometry: Nullable<Geometry>;
  20529. /** @hidden */
  20530. _delayInfo: Array<string>;
  20531. /** @hidden */
  20532. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20533. /** @hidden */
  20534. _instanceDataStorage: _InstanceDataStorage;
  20535. private _effectiveMaterial;
  20536. /** @hidden */
  20537. _shouldGenerateFlatShading: boolean;
  20538. private _preActivateId;
  20539. /** @hidden */
  20540. _originalBuilderSideOrientation: number;
  20541. /**
  20542. * Use this property to change the original side orientation defined at construction time
  20543. */
  20544. overrideMaterialSideOrientation: Nullable<number>;
  20545. private _areNormalsFrozen;
  20546. private _sourcePositions;
  20547. private _sourceNormals;
  20548. private _source;
  20549. private meshMap;
  20550. /**
  20551. * Gets the source mesh (the one used to clone this one from)
  20552. */
  20553. readonly source: Nullable<Mesh>;
  20554. /**
  20555. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20556. */
  20557. isUnIndexed: boolean;
  20558. /**
  20559. * @constructor
  20560. * @param name The value used by scene.getMeshByName() to do a lookup.
  20561. * @param scene The scene to add this mesh to.
  20562. * @param parent The parent of this mesh, if it has one
  20563. * @param source An optional Mesh from which geometry is shared, cloned.
  20564. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20565. * When false, achieved by calling a clone(), also passing False.
  20566. * This will make creation of children, recursive.
  20567. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20568. */
  20569. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20570. /**
  20571. * Gets the class name
  20572. * @returns the string "Mesh".
  20573. */
  20574. getClassName(): string;
  20575. /** @hidden */
  20576. readonly _isMesh: boolean;
  20577. /**
  20578. * Returns a description of this mesh
  20579. * @param fullDetails define if full details about this mesh must be used
  20580. * @returns a descriptive string representing this mesh
  20581. */
  20582. toString(fullDetails?: boolean): string;
  20583. /** @hidden */
  20584. _unBindEffect(): void;
  20585. /**
  20586. * Gets a boolean indicating if this mesh has LOD
  20587. */
  20588. readonly hasLODLevels: boolean;
  20589. /**
  20590. * Gets the list of MeshLODLevel associated with the current mesh
  20591. * @returns an array of MeshLODLevel
  20592. */
  20593. getLODLevels(): MeshLODLevel[];
  20594. private _sortLODLevels;
  20595. /**
  20596. * Add a mesh as LOD level triggered at the given distance.
  20597. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20598. * @param distance The distance from the center of the object to show this level
  20599. * @param mesh The mesh to be added as LOD level (can be null)
  20600. * @return This mesh (for chaining)
  20601. */
  20602. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20603. /**
  20604. * Returns the LOD level mesh at the passed distance or null if not found.
  20605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20606. * @param distance The distance from the center of the object to show this level
  20607. * @returns a Mesh or `null`
  20608. */
  20609. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20610. /**
  20611. * Remove a mesh from the LOD array
  20612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20613. * @param mesh defines the mesh to be removed
  20614. * @return This mesh (for chaining)
  20615. */
  20616. removeLODLevel(mesh: Mesh): Mesh;
  20617. /**
  20618. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20620. * @param camera defines the camera to use to compute distance
  20621. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20622. * @return This mesh (for chaining)
  20623. */
  20624. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20625. /**
  20626. * Gets the mesh internal Geometry object
  20627. */
  20628. readonly geometry: Nullable<Geometry>;
  20629. /**
  20630. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20631. * @returns the total number of vertices
  20632. */
  20633. getTotalVertices(): number;
  20634. /**
  20635. * Returns the content of an associated vertex buffer
  20636. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20637. * - VertexBuffer.PositionKind
  20638. * - VertexBuffer.UVKind
  20639. * - VertexBuffer.UV2Kind
  20640. * - VertexBuffer.UV3Kind
  20641. * - VertexBuffer.UV4Kind
  20642. * - VertexBuffer.UV5Kind
  20643. * - VertexBuffer.UV6Kind
  20644. * - VertexBuffer.ColorKind
  20645. * - VertexBuffer.MatricesIndicesKind
  20646. * - VertexBuffer.MatricesIndicesExtraKind
  20647. * - VertexBuffer.MatricesWeightsKind
  20648. * - VertexBuffer.MatricesWeightsExtraKind
  20649. * @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
  20650. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20651. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20652. */
  20653. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20654. /**
  20655. * Returns the mesh VertexBuffer object from the requested `kind`
  20656. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20657. * - VertexBuffer.PositionKind
  20658. * - VertexBuffer.UVKind
  20659. * - VertexBuffer.UV2Kind
  20660. * - VertexBuffer.UV3Kind
  20661. * - VertexBuffer.UV4Kind
  20662. * - VertexBuffer.UV5Kind
  20663. * - VertexBuffer.UV6Kind
  20664. * - VertexBuffer.ColorKind
  20665. * - VertexBuffer.MatricesIndicesKind
  20666. * - VertexBuffer.MatricesIndicesExtraKind
  20667. * - VertexBuffer.MatricesWeightsKind
  20668. * - VertexBuffer.MatricesWeightsExtraKind
  20669. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20670. */
  20671. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20672. /**
  20673. * Tests if a specific vertex buffer is associated with this mesh
  20674. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20675. * - VertexBuffer.PositionKind
  20676. * - VertexBuffer.UVKind
  20677. * - VertexBuffer.UV2Kind
  20678. * - VertexBuffer.UV3Kind
  20679. * - VertexBuffer.UV4Kind
  20680. * - VertexBuffer.UV5Kind
  20681. * - VertexBuffer.UV6Kind
  20682. * - VertexBuffer.ColorKind
  20683. * - VertexBuffer.MatricesIndicesKind
  20684. * - VertexBuffer.MatricesIndicesExtraKind
  20685. * - VertexBuffer.MatricesWeightsKind
  20686. * - VertexBuffer.MatricesWeightsExtraKind
  20687. * @returns a boolean
  20688. */
  20689. isVerticesDataPresent(kind: string): boolean;
  20690. /**
  20691. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20692. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20693. * - VertexBuffer.PositionKind
  20694. * - VertexBuffer.UVKind
  20695. * - VertexBuffer.UV2Kind
  20696. * - VertexBuffer.UV3Kind
  20697. * - VertexBuffer.UV4Kind
  20698. * - VertexBuffer.UV5Kind
  20699. * - VertexBuffer.UV6Kind
  20700. * - VertexBuffer.ColorKind
  20701. * - VertexBuffer.MatricesIndicesKind
  20702. * - VertexBuffer.MatricesIndicesExtraKind
  20703. * - VertexBuffer.MatricesWeightsKind
  20704. * - VertexBuffer.MatricesWeightsExtraKind
  20705. * @returns a boolean
  20706. */
  20707. isVertexBufferUpdatable(kind: string): boolean;
  20708. /**
  20709. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @returns an array of strings
  20724. */
  20725. getVerticesDataKinds(): string[];
  20726. /**
  20727. * Returns a positive integer : the total number of indices in this mesh geometry.
  20728. * @returns the numner of indices or zero if the mesh has no geometry.
  20729. */
  20730. getTotalIndices(): number;
  20731. /**
  20732. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20733. * @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.
  20734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20735. * @returns the indices array or an empty array if the mesh has no geometry
  20736. */
  20737. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20738. readonly isBlocked: boolean;
  20739. /**
  20740. * Determine if the current mesh is ready to be rendered
  20741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20742. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20743. * @returns true if all associated assets are ready (material, textures, shaders)
  20744. */
  20745. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20746. /**
  20747. * 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.
  20748. */
  20749. readonly areNormalsFrozen: boolean;
  20750. /**
  20751. * 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.
  20752. * @returns the current mesh
  20753. */
  20754. freezeNormals(): Mesh;
  20755. /**
  20756. * 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
  20757. * @returns the current mesh
  20758. */
  20759. unfreezeNormals(): Mesh;
  20760. /**
  20761. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20762. */
  20763. overridenInstanceCount: number;
  20764. /** @hidden */
  20765. _preActivate(): Mesh;
  20766. /** @hidden */
  20767. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20768. /** @hidden */
  20769. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20770. /**
  20771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20772. * This means the mesh underlying bounding box and sphere are recomputed.
  20773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20774. * @returns the current mesh
  20775. */
  20776. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20777. /** @hidden */
  20778. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20779. /**
  20780. * This function will subdivide the mesh into multiple submeshes
  20781. * @param count defines the expected number of submeshes
  20782. */
  20783. subdivide(count: number): void;
  20784. /**
  20785. * Copy a FloatArray into a specific associated vertex buffer
  20786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20787. * - VertexBuffer.PositionKind
  20788. * - VertexBuffer.UVKind
  20789. * - VertexBuffer.UV2Kind
  20790. * - VertexBuffer.UV3Kind
  20791. * - VertexBuffer.UV4Kind
  20792. * - VertexBuffer.UV5Kind
  20793. * - VertexBuffer.UV6Kind
  20794. * - VertexBuffer.ColorKind
  20795. * - VertexBuffer.MatricesIndicesKind
  20796. * - VertexBuffer.MatricesIndicesExtraKind
  20797. * - VertexBuffer.MatricesWeightsKind
  20798. * - VertexBuffer.MatricesWeightsExtraKind
  20799. * @param data defines the data source
  20800. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20801. * @param stride defines the data stride size (can be null)
  20802. * @returns the current mesh
  20803. */
  20804. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20805. /**
  20806. * Flags an associated vertex buffer as updatable
  20807. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20808. * - VertexBuffer.PositionKind
  20809. * - VertexBuffer.UVKind
  20810. * - VertexBuffer.UV2Kind
  20811. * - VertexBuffer.UV3Kind
  20812. * - VertexBuffer.UV4Kind
  20813. * - VertexBuffer.UV5Kind
  20814. * - VertexBuffer.UV6Kind
  20815. * - VertexBuffer.ColorKind
  20816. * - VertexBuffer.MatricesIndicesKind
  20817. * - VertexBuffer.MatricesIndicesExtraKind
  20818. * - VertexBuffer.MatricesWeightsKind
  20819. * - VertexBuffer.MatricesWeightsExtraKind
  20820. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20821. */
  20822. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20823. /**
  20824. * Sets the mesh global Vertex Buffer
  20825. * @param buffer defines the buffer to use
  20826. * @returns the current mesh
  20827. */
  20828. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20829. /**
  20830. * Update a specific associated vertex buffer
  20831. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20832. * - VertexBuffer.PositionKind
  20833. * - VertexBuffer.UVKind
  20834. * - VertexBuffer.UV2Kind
  20835. * - VertexBuffer.UV3Kind
  20836. * - VertexBuffer.UV4Kind
  20837. * - VertexBuffer.UV5Kind
  20838. * - VertexBuffer.UV6Kind
  20839. * - VertexBuffer.ColorKind
  20840. * - VertexBuffer.MatricesIndicesKind
  20841. * - VertexBuffer.MatricesIndicesExtraKind
  20842. * - VertexBuffer.MatricesWeightsKind
  20843. * - VertexBuffer.MatricesWeightsExtraKind
  20844. * @param data defines the data source
  20845. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20846. * @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)
  20847. * @returns the current mesh
  20848. */
  20849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20850. /**
  20851. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20852. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20853. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20854. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20855. * @returns the current mesh
  20856. */
  20857. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20858. /**
  20859. * Creates a un-shared specific occurence of the geometry for the mesh.
  20860. * @returns the current mesh
  20861. */
  20862. makeGeometryUnique(): Mesh;
  20863. /**
  20864. * Set the index buffer of this mesh
  20865. * @param indices defines the source data
  20866. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20867. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20868. * @returns the current mesh
  20869. */
  20870. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20871. /**
  20872. * Update the current index buffer
  20873. * @param indices defines the source data
  20874. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20875. * @returns the current mesh
  20876. */
  20877. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20878. /**
  20879. * Invert the geometry to move from a right handed system to a left handed one.
  20880. * @returns the current mesh
  20881. */
  20882. toLeftHanded(): Mesh;
  20883. /** @hidden */
  20884. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20885. /** @hidden */
  20886. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20887. /**
  20888. * Registers for this mesh a javascript function called just before the rendering process
  20889. * @param func defines the function to call before rendering this mesh
  20890. * @returns the current mesh
  20891. */
  20892. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20893. /**
  20894. * Disposes a previously registered javascript function called before the rendering
  20895. * @param func defines the function to remove
  20896. * @returns the current mesh
  20897. */
  20898. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20899. /**
  20900. * Registers for this mesh a javascript function called just after the rendering is complete
  20901. * @param func defines the function to call after rendering this mesh
  20902. * @returns the current mesh
  20903. */
  20904. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20905. /**
  20906. * Disposes a previously registered javascript function called after the rendering.
  20907. * @param func defines the function to remove
  20908. * @returns the current mesh
  20909. */
  20910. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20911. /** @hidden */
  20912. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20913. /** @hidden */
  20914. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20915. /** @hidden */
  20916. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20917. /**
  20918. * 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
  20919. * @param subMesh defines the subMesh to render
  20920. * @param enableAlphaMode defines if alpha mode can be changed
  20921. * @returns the current mesh
  20922. */
  20923. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20924. private _onBeforeDraw;
  20925. /**
  20926. * Renormalize the mesh and patch it up if there are no weights
  20927. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20928. * However in the case of zero weights then we set just a single influence to 1.
  20929. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20930. */
  20931. cleanMatrixWeights(): void;
  20932. private normalizeSkinFourWeights;
  20933. private normalizeSkinWeightsAndExtra;
  20934. /**
  20935. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20936. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20937. * the user know there was an issue with importing the mesh
  20938. * @returns a validation object with skinned, valid and report string
  20939. */
  20940. validateSkinning(): {
  20941. skinned: boolean;
  20942. valid: boolean;
  20943. report: string;
  20944. };
  20945. /** @hidden */
  20946. _checkDelayState(): Mesh;
  20947. private _queueLoad;
  20948. /**
  20949. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20950. * A mesh is in the frustum if its bounding box intersects the frustum
  20951. * @param frustumPlanes defines the frustum to test
  20952. * @returns true if the mesh is in the frustum planes
  20953. */
  20954. isInFrustum(frustumPlanes: Plane[]): boolean;
  20955. /**
  20956. * Sets the mesh material by the material or multiMaterial `id` property
  20957. * @param id is a string identifying the material or the multiMaterial
  20958. * @returns the current mesh
  20959. */
  20960. setMaterialByID(id: string): Mesh;
  20961. /**
  20962. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20963. * @returns an array of IAnimatable
  20964. */
  20965. getAnimatables(): IAnimatable[];
  20966. /**
  20967. * Modifies the mesh geometry according to the passed transformation matrix.
  20968. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20969. * The mesh normals are modified using the same transformation.
  20970. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20971. * @param transform defines the transform matrix to use
  20972. * @see http://doc.babylonjs.com/resources/baking_transformations
  20973. * @returns the current mesh
  20974. */
  20975. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20976. /**
  20977. * Modifies the mesh geometry according to its own current World Matrix.
  20978. * The mesh World Matrix is then reset.
  20979. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20980. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20981. * @see http://doc.babylonjs.com/resources/baking_transformations
  20982. * @returns the current mesh
  20983. */
  20984. bakeCurrentTransformIntoVertices(): Mesh;
  20985. /** @hidden */
  20986. readonly _positions: Nullable<Vector3[]>;
  20987. /** @hidden */
  20988. _resetPointsArrayCache(): Mesh;
  20989. /** @hidden */
  20990. _generatePointsArray(): boolean;
  20991. /**
  20992. * Returns a new Mesh object generated from the current mesh properties.
  20993. * This method must not get confused with createInstance()
  20994. * @param name is a string, the name given to the new mesh
  20995. * @param newParent can be any Node object (default `null`)
  20996. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20997. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20998. * @returns a new mesh
  20999. */
  21000. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21001. /**
  21002. * Releases resources associated with this mesh.
  21003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21005. */
  21006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21007. /**
  21008. * Modifies the mesh geometry according to a displacement map.
  21009. * 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.
  21010. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21011. * @param url is a string, the URL from the image file is to be downloaded.
  21012. * @param minHeight is the lower limit of the displacement.
  21013. * @param maxHeight is the upper limit of the displacement.
  21014. * @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.
  21015. * @param uvOffset is an optional vector2 used to offset UV.
  21016. * @param uvScale is an optional vector2 used to scale UV.
  21017. * @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.
  21018. * @returns the Mesh.
  21019. */
  21020. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21021. /**
  21022. * Modifies the mesh geometry according to a displacementMap buffer.
  21023. * 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.
  21024. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21025. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21026. * @param heightMapWidth is the width of the buffer image.
  21027. * @param heightMapHeight is the height of the buffer image.
  21028. * @param minHeight is the lower limit of the displacement.
  21029. * @param maxHeight is the upper limit of the displacement.
  21030. * @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.
  21031. * @param uvOffset is an optional vector2 used to offset UV.
  21032. * @param uvScale is an optional vector2 used to scale UV.
  21033. * @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.
  21034. * @returns the Mesh.
  21035. */
  21036. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21037. /**
  21038. * Modify the mesh to get a flat shading rendering.
  21039. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21040. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21041. * @returns current mesh
  21042. */
  21043. convertToFlatShadedMesh(): Mesh;
  21044. /**
  21045. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21046. * In other words, more vertices, no more indices and a single bigger VBO.
  21047. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21048. * @returns current mesh
  21049. */
  21050. convertToUnIndexedMesh(): Mesh;
  21051. /**
  21052. * Inverses facet orientations.
  21053. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21054. * @param flipNormals will also inverts the normals
  21055. * @returns current mesh
  21056. */
  21057. flipFaces(flipNormals?: boolean): Mesh;
  21058. /** @hidden */
  21059. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21060. /** @hidden */
  21061. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21062. /**
  21063. * Creates a new InstancedMesh object from the mesh model.
  21064. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21065. * @param name defines the name of the new instance
  21066. * @returns a new InstancedMesh
  21067. */
  21068. createInstance(name: string): InstancedMesh;
  21069. /**
  21070. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21071. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21072. * @returns the current mesh
  21073. */
  21074. synchronizeInstances(): Mesh;
  21075. /**
  21076. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21077. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21078. * This should be used together with the simplification to avoid disappearing triangles.
  21079. * @param successCallback an optional success callback to be called after the optimization finished.
  21080. * @returns the current mesh
  21081. */
  21082. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21083. /**
  21084. * Serialize current mesh
  21085. * @param serializationObject defines the object which will receive the serialization data
  21086. */
  21087. serialize(serializationObject: any): void;
  21088. /** @hidden */
  21089. _syncGeometryWithMorphTargetManager(): void;
  21090. /** @hidden */
  21091. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21092. /**
  21093. * Returns a new Mesh object parsed from the source provided.
  21094. * @param parsedMesh is the source
  21095. * @param scene defines the hosting scene
  21096. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21097. * @returns a new Mesh
  21098. */
  21099. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21100. /**
  21101. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21102. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21103. * @param name defines the name of the mesh to create
  21104. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21105. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21106. * @param closePath creates a seam between the first and the last points of each path of the path array
  21107. * @param offset is taken in account only if the `pathArray` is containing a single path
  21108. * @param scene defines the hosting scene
  21109. * @param updatable defines if the mesh must be flagged as updatable
  21110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21111. * @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)
  21112. * @returns a new Mesh
  21113. */
  21114. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21115. /**
  21116. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21117. * @param name defines the name of the mesh to create
  21118. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21119. * @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
  21120. * @param scene defines the hosting scene
  21121. * @param updatable defines if the mesh must be flagged as updatable
  21122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21123. * @returns a new Mesh
  21124. */
  21125. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21126. /**
  21127. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21128. * @param name defines the name of the mesh to create
  21129. * @param size sets the size (float) of each box side (default 1)
  21130. * @param scene defines the hosting scene
  21131. * @param updatable defines if the mesh must be flagged as updatable
  21132. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21133. * @returns a new Mesh
  21134. */
  21135. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21136. /**
  21137. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21138. * @param name defines the name of the mesh to create
  21139. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21140. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21141. * @param scene defines the hosting scene
  21142. * @param updatable defines if the mesh must be flagged as updatable
  21143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21144. * @returns a new Mesh
  21145. */
  21146. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21147. /**
  21148. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21149. * @param name defines the name of the mesh to create
  21150. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21151. * @param diameterTop set the top cap diameter (floats, default 1)
  21152. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21153. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21154. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21155. * @param scene defines the hosting scene
  21156. * @param updatable defines if the mesh must be flagged as updatable
  21157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21158. * @returns a new Mesh
  21159. */
  21160. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21161. /**
  21162. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21163. * @param name defines the name of the mesh to create
  21164. * @param diameter sets the diameter size (float) of the torus (default 1)
  21165. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21166. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21167. * @param scene defines the hosting scene
  21168. * @param updatable defines if the mesh must be flagged as updatable
  21169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21170. * @returns a new Mesh
  21171. */
  21172. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21173. /**
  21174. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21175. * @param name defines the name of the mesh to create
  21176. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21177. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21178. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21179. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21180. * @param p the number of windings on X axis (positive integers, default 2)
  21181. * @param q the number of windings on Y axis (positive integers, default 3)
  21182. * @param scene defines the hosting scene
  21183. * @param updatable defines if the mesh must be flagged as updatable
  21184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21185. * @returns a new Mesh
  21186. */
  21187. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21188. /**
  21189. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21190. * @param name defines the name of the mesh to create
  21191. * @param points is an array successive Vector3
  21192. * @param scene defines the hosting scene
  21193. * @param updatable defines if the mesh must be flagged as updatable
  21194. * @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).
  21195. * @returns a new Mesh
  21196. */
  21197. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21198. /**
  21199. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21200. * @param name defines the name of the mesh to create
  21201. * @param points is an array successive Vector3
  21202. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21203. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21204. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21205. * @param scene defines the hosting scene
  21206. * @param updatable defines if the mesh must be flagged as updatable
  21207. * @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)
  21208. * @returns a new Mesh
  21209. */
  21210. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21211. /**
  21212. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21213. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21214. * 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.
  21215. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21216. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21217. * Remember you can only change the shape positions, not their number when updating a polygon.
  21218. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21219. * @param name defines the name of the mesh to create
  21220. * @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
  21221. * @param scene defines the hosting scene
  21222. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21223. * @param updatable defines if the mesh must be flagged as updatable
  21224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21225. * @param earcutInjection can be used to inject your own earcut reference
  21226. * @returns a new Mesh
  21227. */
  21228. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21229. /**
  21230. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21231. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21232. * @param name defines the name of the mesh to create
  21233. * @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
  21234. * @param depth defines the height of extrusion
  21235. * @param scene defines the hosting scene
  21236. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21237. * @param updatable defines if the mesh must be flagged as updatable
  21238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21239. * @param earcutInjection can be used to inject your own earcut reference
  21240. * @returns a new Mesh
  21241. */
  21242. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21243. /**
  21244. * Creates an extruded shape mesh.
  21245. * 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
  21246. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21247. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21248. * @param name defines the name of the mesh to create
  21249. * @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
  21250. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21251. * @param scale is the value to scale the shape
  21252. * @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
  21253. * @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
  21254. * @param scene defines the hosting scene
  21255. * @param updatable defines if the mesh must be flagged as updatable
  21256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21257. * @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)
  21258. * @returns a new Mesh
  21259. */
  21260. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21261. /**
  21262. * Creates an custom extruded shape mesh.
  21263. * The custom extrusion is a parametric shape.
  21264. * It has no predefined shape. Its final shape will depend on the input parameters.
  21265. * Please consider using the same method from the MeshBuilder class instead
  21266. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21267. * @param name defines the name of the mesh to create
  21268. * @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
  21269. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21270. * @param scaleFunction is a custom Javascript function called on each path point
  21271. * @param rotationFunction is a custom Javascript function called on each path point
  21272. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21273. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21274. * @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
  21275. * @param scene defines the hosting scene
  21276. * @param updatable defines if the mesh must be flagged as updatable
  21277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21278. * @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)
  21279. * @returns a new Mesh
  21280. */
  21281. 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;
  21282. /**
  21283. * Creates lathe mesh.
  21284. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @param name defines the name of the mesh to create
  21287. * @param 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
  21288. * @param radius is the radius value of the lathe
  21289. * @param tessellation is the side number of the lathe.
  21290. * @param scene defines the hosting scene
  21291. * @param updatable defines if the mesh must be flagged as updatable
  21292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21293. * @returns a new Mesh
  21294. */
  21295. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21296. /**
  21297. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21298. * @param name defines the name of the mesh to create
  21299. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21300. * @param scene defines the hosting scene
  21301. * @param updatable defines if the mesh must be flagged as updatable
  21302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21303. * @returns a new Mesh
  21304. */
  21305. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21306. /**
  21307. * Creates a ground mesh.
  21308. * Please consider using the same method from the MeshBuilder class instead
  21309. * @param name defines the name of the mesh to create
  21310. * @param width set the width of the ground
  21311. * @param height set the height of the ground
  21312. * @param subdivisions sets the number of subdivisions per side
  21313. * @param scene defines the hosting scene
  21314. * @param updatable defines if the mesh must be flagged as updatable
  21315. * @returns a new Mesh
  21316. */
  21317. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21318. /**
  21319. * Creates a tiled ground mesh.
  21320. * Please consider using the same method from the MeshBuilder class instead
  21321. * @param name defines the name of the mesh to create
  21322. * @param xmin set the ground minimum X coordinate
  21323. * @param zmin set the ground minimum Y coordinate
  21324. * @param xmax set the ground maximum X coordinate
  21325. * @param zmax set the ground maximum Z coordinate
  21326. * @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
  21327. * @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
  21328. * @param scene defines the hosting scene
  21329. * @param updatable defines if the mesh must be flagged as updatable
  21330. * @returns a new Mesh
  21331. */
  21332. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21333. w: number;
  21334. h: number;
  21335. }, precision: {
  21336. w: number;
  21337. h: number;
  21338. }, scene: Scene, updatable?: boolean): Mesh;
  21339. /**
  21340. * Creates a ground mesh from a height map.
  21341. * Please consider using the same method from the MeshBuilder class instead
  21342. * @see http://doc.babylonjs.com/babylon101/height_map
  21343. * @param name defines the name of the mesh to create
  21344. * @param url sets the URL of the height map image resource
  21345. * @param width set the ground width size
  21346. * @param height set the ground height size
  21347. * @param subdivisions sets the number of subdivision per side
  21348. * @param minHeight is the minimum altitude on the ground
  21349. * @param maxHeight is the maximum altitude on the ground
  21350. * @param scene defines the hosting scene
  21351. * @param updatable defines if the mesh must be flagged as updatable
  21352. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21353. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21354. * @returns a new Mesh
  21355. */
  21356. 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;
  21357. /**
  21358. * Creates a tube mesh.
  21359. * The tube is a parametric shape.
  21360. * It has no predefined shape. Its final shape will depend on the input parameters.
  21361. * Please consider using the same method from the MeshBuilder class instead
  21362. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21363. * @param name defines the name of the mesh to create
  21364. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21365. * @param radius sets the tube radius size
  21366. * @param tessellation is the number of sides on the tubular surface
  21367. * @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
  21368. * @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
  21369. * @param scene defines the hosting scene
  21370. * @param updatable defines if the mesh must be flagged as updatable
  21371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21372. * @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)
  21373. * @returns a new Mesh
  21374. */
  21375. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21376. (i: number, distance: number): number;
  21377. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21378. /**
  21379. * Creates a polyhedron mesh.
  21380. * Please consider using the same method from the MeshBuilder class instead.
  21381. * * 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
  21382. * * The parameter `size` (positive float, default 1) sets the polygon size
  21383. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21384. * * 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`
  21385. * * 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
  21386. * * 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)`)
  21387. * * 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
  21388. * * 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
  21389. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21390. * * If you create a double-sided mesh, you can choose what parts of 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
  21391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21392. * @param name defines the name of the mesh to create
  21393. * @param options defines the options used to create the mesh
  21394. * @param scene defines the hosting scene
  21395. * @returns a new Mesh
  21396. */
  21397. static CreatePolyhedron(name: string, options: {
  21398. type?: number;
  21399. size?: number;
  21400. sizeX?: number;
  21401. sizeY?: number;
  21402. sizeZ?: number;
  21403. custom?: any;
  21404. faceUV?: Vector4[];
  21405. faceColors?: Color4[];
  21406. updatable?: boolean;
  21407. sideOrientation?: number;
  21408. }, scene: Scene): Mesh;
  21409. /**
  21410. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21411. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21412. * * 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`)
  21413. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21414. * * 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
  21415. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21416. * * If you create a double-sided mesh, you can choose what parts of 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
  21417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21418. * @param name defines the name of the mesh
  21419. * @param options defines the options used to create the mesh
  21420. * @param scene defines the hosting scene
  21421. * @returns a new Mesh
  21422. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21423. */
  21424. static CreateIcoSphere(name: string, options: {
  21425. radius?: number;
  21426. flat?: boolean;
  21427. subdivisions?: number;
  21428. sideOrientation?: number;
  21429. updatable?: boolean;
  21430. }, scene: Scene): Mesh;
  21431. /**
  21432. * Creates a decal mesh.
  21433. * Please consider using the same method from the MeshBuilder class instead.
  21434. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21435. * @param name defines the name of the mesh
  21436. * @param sourceMesh defines the mesh receiving the decal
  21437. * @param position sets the position of the decal in world coordinates
  21438. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21439. * @param size sets the decal scaling
  21440. * @param angle sets the angle to rotate the decal
  21441. * @returns a new Mesh
  21442. */
  21443. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21444. /**
  21445. * Prepare internal position array for software CPU skinning
  21446. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21447. */
  21448. setPositionsForCPUSkinning(): Float32Array;
  21449. /**
  21450. * Prepare internal normal array for software CPU skinning
  21451. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21452. */
  21453. setNormalsForCPUSkinning(): Float32Array;
  21454. /**
  21455. * Updates the vertex buffer by applying transformation from the bones
  21456. * @param skeleton defines the skeleton to apply to current mesh
  21457. * @returns the current mesh
  21458. */
  21459. applySkeleton(skeleton: Skeleton): Mesh;
  21460. /**
  21461. * 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
  21462. * @param meshes defines the list of meshes to scan
  21463. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21464. */
  21465. static MinMax(meshes: AbstractMesh[]): {
  21466. min: Vector3;
  21467. max: Vector3;
  21468. };
  21469. /**
  21470. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21471. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21472. * @returns a vector3
  21473. */
  21474. static Center(meshesOrMinMaxVector: {
  21475. min: Vector3;
  21476. max: Vector3;
  21477. } | AbstractMesh[]): Vector3;
  21478. /**
  21479. * Merge the array of meshes into a single mesh for performance reasons.
  21480. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21481. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21482. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21483. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21484. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21485. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21486. * @returns a new mesh
  21487. */
  21488. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21489. /** @hidden */
  21490. addInstance(instance: InstancedMesh): void;
  21491. /** @hidden */
  21492. removeInstance(instance: InstancedMesh): void;
  21493. }
  21494. }
  21495. declare module "babylonjs/Materials/material" {
  21496. import { IAnimatable } from "babylonjs/Misc/tools";
  21497. import { SmartArray } from "babylonjs/Misc/smartArray";
  21498. import { Observable } from "babylonjs/Misc/observable";
  21499. import { Nullable } from "babylonjs/types";
  21500. import { Scene } from "babylonjs/scene";
  21501. import { Matrix } from "babylonjs/Maths/math";
  21502. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21504. import { Mesh } from "babylonjs/Meshes/mesh";
  21505. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21506. import { Effect } from "babylonjs/Materials/effect";
  21507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21508. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21509. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21510. import { Animation } from "babylonjs/Animations/animation";
  21511. /**
  21512. * Base class for the main features of a material in Babylon.js
  21513. */
  21514. export class Material implements IAnimatable {
  21515. /**
  21516. * Returns the triangle fill mode
  21517. */
  21518. static readonly TriangleFillMode: number;
  21519. /**
  21520. * Returns the wireframe mode
  21521. */
  21522. static readonly WireFrameFillMode: number;
  21523. /**
  21524. * Returns the point fill mode
  21525. */
  21526. static readonly PointFillMode: number;
  21527. /**
  21528. * Returns the point list draw mode
  21529. */
  21530. static readonly PointListDrawMode: number;
  21531. /**
  21532. * Returns the line list draw mode
  21533. */
  21534. static readonly LineListDrawMode: number;
  21535. /**
  21536. * Returns the line loop draw mode
  21537. */
  21538. static readonly LineLoopDrawMode: number;
  21539. /**
  21540. * Returns the line strip draw mode
  21541. */
  21542. static readonly LineStripDrawMode: number;
  21543. /**
  21544. * Returns the triangle strip draw mode
  21545. */
  21546. static readonly TriangleStripDrawMode: number;
  21547. /**
  21548. * Returns the triangle fan draw mode
  21549. */
  21550. static readonly TriangleFanDrawMode: number;
  21551. /**
  21552. * Stores the clock-wise side orientation
  21553. */
  21554. static readonly ClockWiseSideOrientation: number;
  21555. /**
  21556. * Stores the counter clock-wise side orientation
  21557. */
  21558. static readonly CounterClockWiseSideOrientation: number;
  21559. /**
  21560. * The dirty texture flag value
  21561. */
  21562. static readonly TextureDirtyFlag: number;
  21563. /**
  21564. * The dirty light flag value
  21565. */
  21566. static readonly LightDirtyFlag: number;
  21567. /**
  21568. * The dirty fresnel flag value
  21569. */
  21570. static readonly FresnelDirtyFlag: number;
  21571. /**
  21572. * The dirty attribute flag value
  21573. */
  21574. static readonly AttributesDirtyFlag: number;
  21575. /**
  21576. * The dirty misc flag value
  21577. */
  21578. static readonly MiscDirtyFlag: number;
  21579. /**
  21580. * The all dirty flag value
  21581. */
  21582. static readonly AllDirtyFlag: number;
  21583. /**
  21584. * The ID of the material
  21585. */
  21586. id: string;
  21587. /**
  21588. * Gets or sets the unique id of the material
  21589. */
  21590. uniqueId: number;
  21591. /**
  21592. * The name of the material
  21593. */
  21594. name: string;
  21595. /**
  21596. * Gets or sets user defined metadata
  21597. */
  21598. metadata: any;
  21599. /**
  21600. * For internal use only. Please do not use.
  21601. */
  21602. reservedDataStore: any;
  21603. /**
  21604. * Specifies if the ready state should be checked on each call
  21605. */
  21606. checkReadyOnEveryCall: boolean;
  21607. /**
  21608. * Specifies if the ready state should be checked once
  21609. */
  21610. checkReadyOnlyOnce: boolean;
  21611. /**
  21612. * The state of the material
  21613. */
  21614. state: string;
  21615. /**
  21616. * The alpha value of the material
  21617. */
  21618. protected _alpha: number;
  21619. /**
  21620. * Sets the alpha value of the material
  21621. */
  21622. /**
  21623. * Gets the alpha value of the material
  21624. */
  21625. alpha: number;
  21626. /**
  21627. * Specifies if back face culling is enabled
  21628. */
  21629. protected _backFaceCulling: boolean;
  21630. /**
  21631. * Sets the back-face culling state
  21632. */
  21633. /**
  21634. * Gets the back-face culling state
  21635. */
  21636. backFaceCulling: boolean;
  21637. /**
  21638. * Stores the value for side orientation
  21639. */
  21640. sideOrientation: number;
  21641. /**
  21642. * Callback triggered when the material is compiled
  21643. */
  21644. onCompiled: (effect: Effect) => void;
  21645. /**
  21646. * Callback triggered when an error occurs
  21647. */
  21648. onError: (effect: Effect, errors: string) => void;
  21649. /**
  21650. * Callback triggered to get the render target textures
  21651. */
  21652. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21653. /**
  21654. * Gets a boolean indicating that current material needs to register RTT
  21655. */
  21656. readonly hasRenderTargetTextures: boolean;
  21657. /**
  21658. * Specifies if the material should be serialized
  21659. */
  21660. doNotSerialize: boolean;
  21661. /**
  21662. * @hidden
  21663. */
  21664. _storeEffectOnSubMeshes: boolean;
  21665. /**
  21666. * Stores the animations for the material
  21667. */
  21668. animations: Array<Animation>;
  21669. /**
  21670. * An event triggered when the material is disposed
  21671. */
  21672. onDisposeObservable: Observable<Material>;
  21673. /**
  21674. * An observer which watches for dispose events
  21675. */
  21676. private _onDisposeObserver;
  21677. private _onUnBindObservable;
  21678. /**
  21679. * Called during a dispose event
  21680. */
  21681. onDispose: () => void;
  21682. private _onBindObservable;
  21683. /**
  21684. * An event triggered when the material is bound
  21685. */
  21686. readonly onBindObservable: Observable<AbstractMesh>;
  21687. /**
  21688. * An observer which watches for bind events
  21689. */
  21690. private _onBindObserver;
  21691. /**
  21692. * Called during a bind event
  21693. */
  21694. onBind: (Mesh: AbstractMesh) => void;
  21695. /**
  21696. * An event triggered when the material is unbound
  21697. */
  21698. readonly onUnBindObservable: Observable<Material>;
  21699. /**
  21700. * Stores the value of the alpha mode
  21701. */
  21702. private _alphaMode;
  21703. /**
  21704. * Sets the value of the alpha mode.
  21705. *
  21706. * | Value | Type | Description |
  21707. * | --- | --- | --- |
  21708. * | 0 | ALPHA_DISABLE | |
  21709. * | 1 | ALPHA_ADD | |
  21710. * | 2 | ALPHA_COMBINE | |
  21711. * | 3 | ALPHA_SUBTRACT | |
  21712. * | 4 | ALPHA_MULTIPLY | |
  21713. * | 5 | ALPHA_MAXIMIZED | |
  21714. * | 6 | ALPHA_ONEONE | |
  21715. * | 7 | ALPHA_PREMULTIPLIED | |
  21716. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21717. * | 9 | ALPHA_INTERPOLATE | |
  21718. * | 10 | ALPHA_SCREENMODE | |
  21719. *
  21720. */
  21721. /**
  21722. * Gets the value of the alpha mode
  21723. */
  21724. alphaMode: number;
  21725. /**
  21726. * Stores the state of the need depth pre-pass value
  21727. */
  21728. private _needDepthPrePass;
  21729. /**
  21730. * Sets the need depth pre-pass value
  21731. */
  21732. /**
  21733. * Gets the depth pre-pass value
  21734. */
  21735. needDepthPrePass: boolean;
  21736. /**
  21737. * Specifies if depth writing should be disabled
  21738. */
  21739. disableDepthWrite: boolean;
  21740. /**
  21741. * Specifies if depth writing should be forced
  21742. */
  21743. forceDepthWrite: boolean;
  21744. /**
  21745. * Specifies if there should be a separate pass for culling
  21746. */
  21747. separateCullingPass: boolean;
  21748. /**
  21749. * Stores the state specifing if fog should be enabled
  21750. */
  21751. private _fogEnabled;
  21752. /**
  21753. * Sets the state for enabling fog
  21754. */
  21755. /**
  21756. * Gets the value of the fog enabled state
  21757. */
  21758. fogEnabled: boolean;
  21759. /**
  21760. * Stores the size of points
  21761. */
  21762. pointSize: number;
  21763. /**
  21764. * Stores the z offset value
  21765. */
  21766. zOffset: number;
  21767. /**
  21768. * Gets a value specifying if wireframe mode is enabled
  21769. */
  21770. /**
  21771. * Sets the state of wireframe mode
  21772. */
  21773. wireframe: boolean;
  21774. /**
  21775. * Gets the value specifying if point clouds are enabled
  21776. */
  21777. /**
  21778. * Sets the state of point cloud mode
  21779. */
  21780. pointsCloud: boolean;
  21781. /**
  21782. * Gets the material fill mode
  21783. */
  21784. /**
  21785. * Sets the material fill mode
  21786. */
  21787. fillMode: number;
  21788. /**
  21789. * @hidden
  21790. * Stores the effects for the material
  21791. */
  21792. _effect: Nullable<Effect>;
  21793. /**
  21794. * @hidden
  21795. * Specifies if the material was previously ready
  21796. */
  21797. _wasPreviouslyReady: boolean;
  21798. /**
  21799. * Specifies if uniform buffers should be used
  21800. */
  21801. private _useUBO;
  21802. /**
  21803. * Stores a reference to the scene
  21804. */
  21805. private _scene;
  21806. /**
  21807. * Stores the fill mode state
  21808. */
  21809. private _fillMode;
  21810. /**
  21811. * Specifies if the depth write state should be cached
  21812. */
  21813. private _cachedDepthWriteState;
  21814. /**
  21815. * Stores the uniform buffer
  21816. */
  21817. protected _uniformBuffer: UniformBuffer;
  21818. /** @hidden */
  21819. _indexInSceneMaterialArray: number;
  21820. /** @hidden */
  21821. meshMap: Nullable<{
  21822. [id: string]: AbstractMesh | undefined;
  21823. }>;
  21824. /**
  21825. * Creates a material instance
  21826. * @param name defines the name of the material
  21827. * @param scene defines the scene to reference
  21828. * @param doNotAdd specifies if the material should be added to the scene
  21829. */
  21830. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21831. /**
  21832. * Returns a string representation of the current material
  21833. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21834. * @returns a string with material information
  21835. */
  21836. toString(fullDetails?: boolean): string;
  21837. /**
  21838. * Gets the class name of the material
  21839. * @returns a string with the class name of the material
  21840. */
  21841. getClassName(): string;
  21842. /**
  21843. * Specifies if updates for the material been locked
  21844. */
  21845. readonly isFrozen: boolean;
  21846. /**
  21847. * Locks updates for the material
  21848. */
  21849. freeze(): void;
  21850. /**
  21851. * Unlocks updates for the material
  21852. */
  21853. unfreeze(): void;
  21854. /**
  21855. * Specifies if the material is ready to be used
  21856. * @param mesh defines the mesh to check
  21857. * @param useInstances specifies if instances should be used
  21858. * @returns a boolean indicating if the material is ready to be used
  21859. */
  21860. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21861. /**
  21862. * Specifies that the submesh is ready to be used
  21863. * @param mesh defines the mesh to check
  21864. * @param subMesh defines which submesh to check
  21865. * @param useInstances specifies that instances should be used
  21866. * @returns a boolean indicating that the submesh is ready or not
  21867. */
  21868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21869. /**
  21870. * Returns the material effect
  21871. * @returns the effect associated with the material
  21872. */
  21873. getEffect(): Nullable<Effect>;
  21874. /**
  21875. * Returns the current scene
  21876. * @returns a Scene
  21877. */
  21878. getScene(): Scene;
  21879. /**
  21880. * Specifies if the material will require alpha blending
  21881. * @returns a boolean specifying if alpha blending is needed
  21882. */
  21883. needAlphaBlending(): boolean;
  21884. /**
  21885. * Specifies if the mesh will require alpha blending
  21886. * @param mesh defines the mesh to check
  21887. * @returns a boolean specifying if alpha blending is needed for the mesh
  21888. */
  21889. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21890. /**
  21891. * Specifies if this material should be rendered in alpha test mode
  21892. * @returns a boolean specifying if an alpha test is needed.
  21893. */
  21894. needAlphaTesting(): boolean;
  21895. /**
  21896. * Gets the texture used for the alpha test
  21897. * @returns the texture to use for alpha testing
  21898. */
  21899. getAlphaTestTexture(): Nullable<BaseTexture>;
  21900. /**
  21901. * Marks the material to indicate that it needs to be re-calculated
  21902. */
  21903. markDirty(): void;
  21904. /** @hidden */
  21905. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21906. /**
  21907. * Binds the material to the mesh
  21908. * @param world defines the world transformation matrix
  21909. * @param mesh defines the mesh to bind the material to
  21910. */
  21911. bind(world: Matrix, mesh?: Mesh): void;
  21912. /**
  21913. * Binds the submesh to the material
  21914. * @param world defines the world transformation matrix
  21915. * @param mesh defines the mesh containing the submesh
  21916. * @param subMesh defines the submesh to bind the material to
  21917. */
  21918. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21919. /**
  21920. * Binds the world matrix to the material
  21921. * @param world defines the world transformation matrix
  21922. */
  21923. bindOnlyWorldMatrix(world: Matrix): void;
  21924. /**
  21925. * Binds the scene's uniform buffer to the effect.
  21926. * @param effect defines the effect to bind to the scene uniform buffer
  21927. * @param sceneUbo defines the uniform buffer storing scene data
  21928. */
  21929. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21930. /**
  21931. * Binds the view matrix to the effect
  21932. * @param effect defines the effect to bind the view matrix to
  21933. */
  21934. bindView(effect: Effect): void;
  21935. /**
  21936. * Binds the view projection matrix to the effect
  21937. * @param effect defines the effect to bind the view projection matrix to
  21938. */
  21939. bindViewProjection(effect: Effect): void;
  21940. /**
  21941. * Specifies if material alpha testing should be turned on for the mesh
  21942. * @param mesh defines the mesh to check
  21943. */
  21944. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21945. /**
  21946. * Processes to execute after binding the material to a mesh
  21947. * @param mesh defines the rendered mesh
  21948. */
  21949. protected _afterBind(mesh?: Mesh): void;
  21950. /**
  21951. * Unbinds the material from the mesh
  21952. */
  21953. unbind(): void;
  21954. /**
  21955. * Gets the active textures from the material
  21956. * @returns an array of textures
  21957. */
  21958. getActiveTextures(): BaseTexture[];
  21959. /**
  21960. * Specifies if the material uses a texture
  21961. * @param texture defines the texture to check against the material
  21962. * @returns a boolean specifying if the material uses the texture
  21963. */
  21964. hasTexture(texture: BaseTexture): boolean;
  21965. /**
  21966. * Makes a duplicate of the material, and gives it a new name
  21967. * @param name defines the new name for the duplicated material
  21968. * @returns the cloned material
  21969. */
  21970. clone(name: string): Nullable<Material>;
  21971. /**
  21972. * Gets the meshes bound to the material
  21973. * @returns an array of meshes bound to the material
  21974. */
  21975. getBindedMeshes(): AbstractMesh[];
  21976. /**
  21977. * Force shader compilation
  21978. * @param mesh defines the mesh associated with this material
  21979. * @param onCompiled defines a function to execute once the material is compiled
  21980. * @param options defines the options to configure the compilation
  21981. */
  21982. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21983. clipPlane: boolean;
  21984. }>): void;
  21985. /**
  21986. * Force shader compilation
  21987. * @param mesh defines the mesh that will use this material
  21988. * @param options defines additional options for compiling the shaders
  21989. * @returns a promise that resolves when the compilation completes
  21990. */
  21991. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21992. clipPlane: boolean;
  21993. }>): Promise<void>;
  21994. private static readonly _ImageProcessingDirtyCallBack;
  21995. private static readonly _TextureDirtyCallBack;
  21996. private static readonly _FresnelDirtyCallBack;
  21997. private static readonly _MiscDirtyCallBack;
  21998. private static readonly _LightsDirtyCallBack;
  21999. private static readonly _AttributeDirtyCallBack;
  22000. private static _FresnelAndMiscDirtyCallBack;
  22001. private static _TextureAndMiscDirtyCallBack;
  22002. private static readonly _DirtyCallbackArray;
  22003. private static readonly _RunDirtyCallBacks;
  22004. /**
  22005. * Marks a define in the material to indicate that it needs to be re-computed
  22006. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22007. */
  22008. markAsDirty(flag: number): void;
  22009. /**
  22010. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22011. * @param func defines a function which checks material defines against the submeshes
  22012. */
  22013. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22014. /**
  22015. * Indicates that image processing needs to be re-calculated for all submeshes
  22016. */
  22017. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22018. /**
  22019. * Indicates that textures need to be re-calculated for all submeshes
  22020. */
  22021. protected _markAllSubMeshesAsTexturesDirty(): void;
  22022. /**
  22023. * Indicates that fresnel needs to be re-calculated for all submeshes
  22024. */
  22025. protected _markAllSubMeshesAsFresnelDirty(): void;
  22026. /**
  22027. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22028. */
  22029. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22030. /**
  22031. * Indicates that lights need to be re-calculated for all submeshes
  22032. */
  22033. protected _markAllSubMeshesAsLightsDirty(): void;
  22034. /**
  22035. * Indicates that attributes need to be re-calculated for all submeshes
  22036. */
  22037. protected _markAllSubMeshesAsAttributesDirty(): void;
  22038. /**
  22039. * Indicates that misc needs to be re-calculated for all submeshes
  22040. */
  22041. protected _markAllSubMeshesAsMiscDirty(): void;
  22042. /**
  22043. * Indicates that textures and misc need to be re-calculated for all submeshes
  22044. */
  22045. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22046. /**
  22047. * Disposes the material
  22048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22051. */
  22052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22053. /** @hidden */
  22054. private releaseVertexArrayObject;
  22055. /**
  22056. * Serializes this material
  22057. * @returns the serialized material object
  22058. */
  22059. serialize(): any;
  22060. /**
  22061. * Creates a material from parsed material data
  22062. * @param parsedMaterial defines parsed material data
  22063. * @param scene defines the hosting scene
  22064. * @param rootUrl defines the root URL to use to load textures
  22065. * @returns a new material
  22066. */
  22067. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22068. }
  22069. }
  22070. declare module "babylonjs/Meshes/subMesh" {
  22071. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22072. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22073. import { Engine } from "babylonjs/Engines/engine";
  22074. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22075. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22076. import { Effect } from "babylonjs/Materials/effect";
  22077. import { Collider } from "babylonjs/Collisions/collider";
  22078. import { Material } from "babylonjs/Materials/material";
  22079. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22081. import { Mesh } from "babylonjs/Meshes/mesh";
  22082. import { Ray } from "babylonjs/Culling/ray";
  22083. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22084. /**
  22085. * Base class for submeshes
  22086. */
  22087. export class BaseSubMesh {
  22088. /** @hidden */
  22089. _materialDefines: Nullable<MaterialDefines>;
  22090. /** @hidden */
  22091. _materialEffect: Nullable<Effect>;
  22092. /**
  22093. * Gets associated effect
  22094. */
  22095. readonly effect: Nullable<Effect>;
  22096. /**
  22097. * Sets associated effect (effect used to render this submesh)
  22098. * @param effect defines the effect to associate with
  22099. * @param defines defines the set of defines used to compile this effect
  22100. */
  22101. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22102. }
  22103. /**
  22104. * Defines a subdivision inside a mesh
  22105. */
  22106. export class SubMesh extends BaseSubMesh implements ICullable {
  22107. /** the material index to use */
  22108. materialIndex: number;
  22109. /** vertex index start */
  22110. verticesStart: number;
  22111. /** vertices count */
  22112. verticesCount: number;
  22113. /** index start */
  22114. indexStart: number;
  22115. /** indices count */
  22116. indexCount: number;
  22117. /** @hidden */
  22118. _linesIndexCount: number;
  22119. private _mesh;
  22120. private _renderingMesh;
  22121. private _boundingInfo;
  22122. private _linesIndexBuffer;
  22123. /** @hidden */
  22124. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22125. /** @hidden */
  22126. _trianglePlanes: Plane[];
  22127. /** @hidden */
  22128. _lastColliderTransformMatrix: Matrix;
  22129. /** @hidden */
  22130. _renderId: number;
  22131. /** @hidden */
  22132. _alphaIndex: number;
  22133. /** @hidden */
  22134. _distanceToCamera: number;
  22135. /** @hidden */
  22136. _id: number;
  22137. private _currentMaterial;
  22138. /**
  22139. * Add a new submesh to a mesh
  22140. * @param materialIndex defines the material index to use
  22141. * @param verticesStart defines vertex index start
  22142. * @param verticesCount defines vertices count
  22143. * @param indexStart defines index start
  22144. * @param indexCount defines indices count
  22145. * @param mesh defines the parent mesh
  22146. * @param renderingMesh defines an optional rendering mesh
  22147. * @param createBoundingBox defines if bounding box should be created for this submesh
  22148. * @returns the new submesh
  22149. */
  22150. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22151. /**
  22152. * Creates a new submesh
  22153. * @param materialIndex defines the material index to use
  22154. * @param verticesStart defines vertex index start
  22155. * @param verticesCount defines vertices count
  22156. * @param indexStart defines index start
  22157. * @param indexCount defines indices count
  22158. * @param mesh defines the parent mesh
  22159. * @param renderingMesh defines an optional rendering mesh
  22160. * @param createBoundingBox defines if bounding box should be created for this submesh
  22161. */
  22162. constructor(
  22163. /** the material index to use */
  22164. materialIndex: number,
  22165. /** vertex index start */
  22166. verticesStart: number,
  22167. /** vertices count */
  22168. verticesCount: number,
  22169. /** index start */
  22170. indexStart: number,
  22171. /** indices count */
  22172. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22173. /**
  22174. * Returns true if this submesh covers the entire parent mesh
  22175. * @ignorenaming
  22176. */
  22177. readonly IsGlobal: boolean;
  22178. /**
  22179. * Returns the submesh BoudingInfo object
  22180. * @returns current bounding info (or mesh's one if the submesh is global)
  22181. */
  22182. getBoundingInfo(): BoundingInfo;
  22183. /**
  22184. * Sets the submesh BoundingInfo
  22185. * @param boundingInfo defines the new bounding info to use
  22186. * @returns the SubMesh
  22187. */
  22188. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22189. /**
  22190. * Returns the mesh of the current submesh
  22191. * @return the parent mesh
  22192. */
  22193. getMesh(): AbstractMesh;
  22194. /**
  22195. * Returns the rendering mesh of the submesh
  22196. * @returns the rendering mesh (could be different from parent mesh)
  22197. */
  22198. getRenderingMesh(): Mesh;
  22199. /**
  22200. * Returns the submesh material
  22201. * @returns null or the current material
  22202. */
  22203. getMaterial(): Nullable<Material>;
  22204. /**
  22205. * Sets a new updated BoundingInfo object to the submesh
  22206. * @returns the SubMesh
  22207. */
  22208. refreshBoundingInfo(): SubMesh;
  22209. /** @hidden */
  22210. _checkCollision(collider: Collider): boolean;
  22211. /**
  22212. * Updates the submesh BoundingInfo
  22213. * @param world defines the world matrix to use to update the bounding info
  22214. * @returns the submesh
  22215. */
  22216. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22217. /**
  22218. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22219. * @param frustumPlanes defines the frustum planes
  22220. * @returns true if the submesh is intersecting with the frustum
  22221. */
  22222. isInFrustum(frustumPlanes: Plane[]): boolean;
  22223. /**
  22224. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22225. * @param frustumPlanes defines the frustum planes
  22226. * @returns true if the submesh is inside the frustum
  22227. */
  22228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22229. /**
  22230. * Renders the submesh
  22231. * @param enableAlphaMode defines if alpha needs to be used
  22232. * @returns the submesh
  22233. */
  22234. render(enableAlphaMode: boolean): SubMesh;
  22235. /**
  22236. * @hidden
  22237. */
  22238. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22239. /**
  22240. * Checks if the submesh intersects with a ray
  22241. * @param ray defines the ray to test
  22242. * @returns true is the passed ray intersects the submesh bounding box
  22243. */
  22244. canIntersects(ray: Ray): boolean;
  22245. /**
  22246. * Intersects current submesh with a ray
  22247. * @param ray defines the ray to test
  22248. * @param positions defines mesh's positions array
  22249. * @param indices defines mesh's indices array
  22250. * @param fastCheck defines if only bounding info should be used
  22251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22252. * @returns intersection info or null if no intersection
  22253. */
  22254. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22255. /** @hidden */
  22256. private _intersectLines;
  22257. /** @hidden */
  22258. private _intersectTriangles;
  22259. /** @hidden */
  22260. _rebuild(): void;
  22261. /**
  22262. * Creates a new submesh from the passed mesh
  22263. * @param newMesh defines the new hosting mesh
  22264. * @param newRenderingMesh defines an optional rendering mesh
  22265. * @returns the new submesh
  22266. */
  22267. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22268. /**
  22269. * Release associated resources
  22270. */
  22271. dispose(): void;
  22272. /**
  22273. * Gets the class name
  22274. * @returns the string "SubMesh".
  22275. */
  22276. getClassName(): string;
  22277. /**
  22278. * Creates a new submesh from indices data
  22279. * @param materialIndex the index of the main mesh material
  22280. * @param startIndex the index where to start the copy in the mesh indices array
  22281. * @param indexCount the number of indices to copy then from the startIndex
  22282. * @param mesh the main mesh to create the submesh from
  22283. * @param renderingMesh the optional rendering mesh
  22284. * @returns a new submesh
  22285. */
  22286. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22287. }
  22288. }
  22289. declare module "babylonjs/Meshes/geometry" {
  22290. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22291. import { Scene } from "babylonjs/scene";
  22292. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22293. import { Engine } from "babylonjs/Engines/engine";
  22294. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22295. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22296. import { Effect } from "babylonjs/Materials/effect";
  22297. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22298. import { Mesh } from "babylonjs/Meshes/mesh";
  22299. /**
  22300. * Class used to store geometry data (vertex buffers + index buffer)
  22301. */
  22302. export class Geometry implements IGetSetVerticesData {
  22303. /**
  22304. * Gets or sets the ID of the geometry
  22305. */
  22306. id: string;
  22307. /**
  22308. * Gets or sets the unique ID of the geometry
  22309. */
  22310. uniqueId: number;
  22311. /**
  22312. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22313. */
  22314. delayLoadState: number;
  22315. /**
  22316. * Gets the file containing the data to load when running in delay load state
  22317. */
  22318. delayLoadingFile: Nullable<string>;
  22319. /**
  22320. * Callback called when the geometry is updated
  22321. */
  22322. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22323. private _scene;
  22324. private _engine;
  22325. private _meshes;
  22326. private _totalVertices;
  22327. /** @hidden */
  22328. _indices: IndicesArray;
  22329. /** @hidden */
  22330. _vertexBuffers: {
  22331. [key: string]: VertexBuffer;
  22332. };
  22333. private _isDisposed;
  22334. private _extend;
  22335. private _boundingBias;
  22336. /** @hidden */
  22337. _delayInfo: Array<string>;
  22338. private _indexBuffer;
  22339. private _indexBufferIsUpdatable;
  22340. /** @hidden */
  22341. _boundingInfo: Nullable<BoundingInfo>;
  22342. /** @hidden */
  22343. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22344. /** @hidden */
  22345. _softwareSkinningFrameId: number;
  22346. private _vertexArrayObjects;
  22347. private _updatable;
  22348. /** @hidden */
  22349. _positions: Nullable<Vector3[]>;
  22350. /**
  22351. * 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
  22352. */
  22353. /**
  22354. * 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
  22355. */
  22356. boundingBias: Vector2;
  22357. /**
  22358. * Static function used to attach a new empty geometry to a mesh
  22359. * @param mesh defines the mesh to attach the geometry to
  22360. * @returns the new Geometry
  22361. */
  22362. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22363. /**
  22364. * Creates a new geometry
  22365. * @param id defines the unique ID
  22366. * @param scene defines the hosting scene
  22367. * @param vertexData defines the VertexData used to get geometry data
  22368. * @param updatable defines if geometry must be updatable (false by default)
  22369. * @param mesh defines the mesh that will be associated with the geometry
  22370. */
  22371. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22372. /**
  22373. * Gets the current extend of the geometry
  22374. */
  22375. readonly extend: {
  22376. minimum: Vector3;
  22377. maximum: Vector3;
  22378. };
  22379. /**
  22380. * Gets the hosting scene
  22381. * @returns the hosting Scene
  22382. */
  22383. getScene(): Scene;
  22384. /**
  22385. * Gets the hosting engine
  22386. * @returns the hosting Engine
  22387. */
  22388. getEngine(): Engine;
  22389. /**
  22390. * Defines if the geometry is ready to use
  22391. * @returns true if the geometry is ready to be used
  22392. */
  22393. isReady(): boolean;
  22394. /**
  22395. * Gets a value indicating that the geometry should not be serialized
  22396. */
  22397. readonly doNotSerialize: boolean;
  22398. /** @hidden */
  22399. _rebuild(): void;
  22400. /**
  22401. * Affects all geometry data in one call
  22402. * @param vertexData defines the geometry data
  22403. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22404. */
  22405. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22406. /**
  22407. * Set specific vertex data
  22408. * @param kind defines the data kind (Position, normal, etc...)
  22409. * @param data defines the vertex data to use
  22410. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22411. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22412. */
  22413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22414. /**
  22415. * Removes a specific vertex data
  22416. * @param kind defines the data kind (Position, normal, etc...)
  22417. */
  22418. removeVerticesData(kind: string): void;
  22419. /**
  22420. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22421. * @param buffer defines the vertex buffer to use
  22422. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22423. */
  22424. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22425. /**
  22426. * Update a specific vertex buffer
  22427. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22428. * It will do nothing if the buffer is not updatable
  22429. * @param kind defines the data kind (Position, normal, etc...)
  22430. * @param data defines the data to use
  22431. * @param offset defines the offset in the target buffer where to store the data
  22432. * @param useBytes set to true if the offset is in bytes
  22433. */
  22434. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22435. /**
  22436. * Update a specific vertex buffer
  22437. * This function will create a new buffer if the current one is not updatable
  22438. * @param kind defines the data kind (Position, normal, etc...)
  22439. * @param data defines the data to use
  22440. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22441. */
  22442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22443. private _updateBoundingInfo;
  22444. /** @hidden */
  22445. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22446. /**
  22447. * Gets total number of vertices
  22448. * @returns the total number of vertices
  22449. */
  22450. getTotalVertices(): number;
  22451. /**
  22452. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22453. * @param kind defines the data kind (Position, normal, etc...)
  22454. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22455. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22456. * @returns a float array containing vertex data
  22457. */
  22458. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22459. /**
  22460. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22461. * @param kind defines the data kind (Position, normal, etc...)
  22462. * @returns true if the vertex buffer with the specified kind is updatable
  22463. */
  22464. isVertexBufferUpdatable(kind: string): boolean;
  22465. /**
  22466. * Gets a specific vertex buffer
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @returns a VertexBuffer
  22469. */
  22470. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22471. /**
  22472. * Returns all vertex buffers
  22473. * @return an object holding all vertex buffers indexed by kind
  22474. */
  22475. getVertexBuffers(): Nullable<{
  22476. [key: string]: VertexBuffer;
  22477. }>;
  22478. /**
  22479. * Gets a boolean indicating if specific vertex buffer is present
  22480. * @param kind defines the data kind (Position, normal, etc...)
  22481. * @returns true if data is present
  22482. */
  22483. isVerticesDataPresent(kind: string): boolean;
  22484. /**
  22485. * Gets a list of all attached data kinds (Position, normal, etc...)
  22486. * @returns a list of string containing all kinds
  22487. */
  22488. getVerticesDataKinds(): string[];
  22489. /**
  22490. * Update index buffer
  22491. * @param indices defines the indices to store in the index buffer
  22492. * @param offset defines the offset in the target buffer where to store the data
  22493. */
  22494. updateIndices(indices: IndicesArray, offset?: number): void;
  22495. /**
  22496. * Creates a new index buffer
  22497. * @param indices defines the indices to store in the index buffer
  22498. * @param totalVertices defines the total number of vertices (could be null)
  22499. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22500. */
  22501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22502. /**
  22503. * Return the total number of indices
  22504. * @returns the total number of indices
  22505. */
  22506. getTotalIndices(): number;
  22507. /**
  22508. * Gets the index buffer array
  22509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22511. * @returns the index buffer array
  22512. */
  22513. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22514. /**
  22515. * Gets the index buffer
  22516. * @return the index buffer
  22517. */
  22518. getIndexBuffer(): Nullable<WebGLBuffer>;
  22519. /** @hidden */
  22520. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22521. /**
  22522. * Release the associated resources for a specific mesh
  22523. * @param mesh defines the source mesh
  22524. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22525. */
  22526. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22527. /**
  22528. * Apply current geometry to a given mesh
  22529. * @param mesh defines the mesh to apply geometry to
  22530. */
  22531. applyToMesh(mesh: Mesh): void;
  22532. private _updateExtend;
  22533. private _applyToMesh;
  22534. private notifyUpdate;
  22535. /**
  22536. * Load the geometry if it was flagged as delay loaded
  22537. * @param scene defines the hosting scene
  22538. * @param onLoaded defines a callback called when the geometry is loaded
  22539. */
  22540. load(scene: Scene, onLoaded?: () => void): void;
  22541. private _queueLoad;
  22542. /**
  22543. * Invert the geometry to move from a right handed system to a left handed one.
  22544. */
  22545. toLeftHanded(): void;
  22546. /** @hidden */
  22547. _resetPointsArrayCache(): void;
  22548. /** @hidden */
  22549. _generatePointsArray(): boolean;
  22550. /**
  22551. * Gets a value indicating if the geometry is disposed
  22552. * @returns true if the geometry was disposed
  22553. */
  22554. isDisposed(): boolean;
  22555. private _disposeVertexArrayObjects;
  22556. /**
  22557. * Free all associated resources
  22558. */
  22559. dispose(): void;
  22560. /**
  22561. * Clone the current geometry into a new geometry
  22562. * @param id defines the unique ID of the new geometry
  22563. * @returns a new geometry object
  22564. */
  22565. copy(id: string): Geometry;
  22566. /**
  22567. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22568. * @return a JSON representation of the current geometry data (without the vertices data)
  22569. */
  22570. serialize(): any;
  22571. private toNumberArray;
  22572. /**
  22573. * Serialize all vertices data into a JSON oject
  22574. * @returns a JSON representation of the current geometry data
  22575. */
  22576. serializeVerticeData(): any;
  22577. /**
  22578. * Extracts a clone of a mesh geometry
  22579. * @param mesh defines the source mesh
  22580. * @param id defines the unique ID of the new geometry object
  22581. * @returns the new geometry object
  22582. */
  22583. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22584. /**
  22585. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22586. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22587. * Be aware Math.random() could cause collisions, but:
  22588. * "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"
  22589. * @returns a string containing a new GUID
  22590. */
  22591. static RandomId(): string;
  22592. /** @hidden */
  22593. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22594. private static _CleanMatricesWeights;
  22595. /**
  22596. * Create a new geometry from persisted data (Using .babylon file format)
  22597. * @param parsedVertexData defines the persisted data
  22598. * @param scene defines the hosting scene
  22599. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22600. * @returns the new geometry object
  22601. */
  22602. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22603. }
  22604. }
  22605. declare module "babylonjs/Meshes/mesh.vertexData" {
  22606. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22607. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22608. import { Geometry } from "babylonjs/Meshes/geometry";
  22609. import { Mesh } from "babylonjs/Meshes/mesh";
  22610. /**
  22611. * Define an interface for all classes that will get and set the data on vertices
  22612. */
  22613. export interface IGetSetVerticesData {
  22614. /**
  22615. * Gets a boolean indicating if specific vertex data is present
  22616. * @param kind defines the vertex data kind to use
  22617. * @returns true is data kind is present
  22618. */
  22619. isVerticesDataPresent(kind: string): boolean;
  22620. /**
  22621. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22622. * @param kind defines the data kind (Position, normal, etc...)
  22623. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22625. * @returns a float array containing vertex data
  22626. */
  22627. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22628. /**
  22629. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22630. * @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.
  22631. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22632. * @returns the indices array or an empty array if the mesh has no geometry
  22633. */
  22634. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22635. /**
  22636. * Set specific vertex data
  22637. * @param kind defines the data kind (Position, normal, etc...)
  22638. * @param data defines the vertex data to use
  22639. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22640. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22641. */
  22642. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22643. /**
  22644. * Update a specific associated vertex buffer
  22645. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22646. * - VertexBuffer.PositionKind
  22647. * - VertexBuffer.UVKind
  22648. * - VertexBuffer.UV2Kind
  22649. * - VertexBuffer.UV3Kind
  22650. * - VertexBuffer.UV4Kind
  22651. * - VertexBuffer.UV5Kind
  22652. * - VertexBuffer.UV6Kind
  22653. * - VertexBuffer.ColorKind
  22654. * - VertexBuffer.MatricesIndicesKind
  22655. * - VertexBuffer.MatricesIndicesExtraKind
  22656. * - VertexBuffer.MatricesWeightsKind
  22657. * - VertexBuffer.MatricesWeightsExtraKind
  22658. * @param data defines the data source
  22659. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22660. * @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)
  22661. */
  22662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22663. /**
  22664. * Creates a new index buffer
  22665. * @param indices defines the indices to store in the index buffer
  22666. * @param totalVertices defines the total number of vertices (could be null)
  22667. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22668. */
  22669. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22670. }
  22671. /**
  22672. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22673. */
  22674. export class VertexData {
  22675. /**
  22676. * Mesh side orientation : usually the external or front surface
  22677. */
  22678. static readonly FRONTSIDE: number;
  22679. /**
  22680. * Mesh side orientation : usually the internal or back surface
  22681. */
  22682. static readonly BACKSIDE: number;
  22683. /**
  22684. * Mesh side orientation : both internal and external or front and back surfaces
  22685. */
  22686. static readonly DOUBLESIDE: number;
  22687. /**
  22688. * Mesh side orientation : by default, `FRONTSIDE`
  22689. */
  22690. static readonly DEFAULTSIDE: number;
  22691. /**
  22692. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22693. */
  22694. positions: Nullable<FloatArray>;
  22695. /**
  22696. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22697. */
  22698. normals: Nullable<FloatArray>;
  22699. /**
  22700. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22701. */
  22702. tangents: Nullable<FloatArray>;
  22703. /**
  22704. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22705. */
  22706. uvs: Nullable<FloatArray>;
  22707. /**
  22708. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22709. */
  22710. uvs2: Nullable<FloatArray>;
  22711. /**
  22712. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22713. */
  22714. uvs3: Nullable<FloatArray>;
  22715. /**
  22716. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22717. */
  22718. uvs4: Nullable<FloatArray>;
  22719. /**
  22720. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22721. */
  22722. uvs5: Nullable<FloatArray>;
  22723. /**
  22724. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22725. */
  22726. uvs6: Nullable<FloatArray>;
  22727. /**
  22728. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22729. */
  22730. colors: Nullable<FloatArray>;
  22731. /**
  22732. * 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).
  22733. */
  22734. matricesIndices: Nullable<FloatArray>;
  22735. /**
  22736. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22737. */
  22738. matricesWeights: Nullable<FloatArray>;
  22739. /**
  22740. * An array extending the number of possible indices
  22741. */
  22742. matricesIndicesExtra: Nullable<FloatArray>;
  22743. /**
  22744. * An array extending the number of possible weights when the number of indices is extended
  22745. */
  22746. matricesWeightsExtra: Nullable<FloatArray>;
  22747. /**
  22748. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22749. */
  22750. indices: Nullable<IndicesArray>;
  22751. /**
  22752. * Uses the passed data array to set the set the values for the specified kind of data
  22753. * @param data a linear array of floating numbers
  22754. * @param kind the type of data that is being set, eg positions, colors etc
  22755. */
  22756. set(data: FloatArray, kind: string): void;
  22757. /**
  22758. * Associates the vertexData to the passed Mesh.
  22759. * Sets it as updatable or not (default `false`)
  22760. * @param mesh the mesh the vertexData is applied to
  22761. * @param updatable when used and having the value true allows new data to update the vertexData
  22762. * @returns the VertexData
  22763. */
  22764. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22765. /**
  22766. * Associates the vertexData to the passed Geometry.
  22767. * Sets it as updatable or not (default `false`)
  22768. * @param geometry the geometry the vertexData is applied to
  22769. * @param updatable when used and having the value true allows new data to update the vertexData
  22770. * @returns VertexData
  22771. */
  22772. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22773. /**
  22774. * Updates the associated mesh
  22775. * @param mesh the mesh to be updated
  22776. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22777. * @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
  22778. * @returns VertexData
  22779. */
  22780. updateMesh(mesh: Mesh): VertexData;
  22781. /**
  22782. * Updates the associated geometry
  22783. * @param geometry the geometry to be updated
  22784. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22785. * @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
  22786. * @returns VertexData.
  22787. */
  22788. updateGeometry(geometry: Geometry): VertexData;
  22789. private _applyTo;
  22790. private _update;
  22791. /**
  22792. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22793. * @param matrix the transforming matrix
  22794. * @returns the VertexData
  22795. */
  22796. transform(matrix: Matrix): VertexData;
  22797. /**
  22798. * Merges the passed VertexData into the current one
  22799. * @param other the VertexData to be merged into the current one
  22800. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22801. * @returns the modified VertexData
  22802. */
  22803. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22804. private _mergeElement;
  22805. private _validate;
  22806. /**
  22807. * Serializes the VertexData
  22808. * @returns a serialized object
  22809. */
  22810. serialize(): any;
  22811. /**
  22812. * Extracts the vertexData from a mesh
  22813. * @param mesh the mesh from which to extract the VertexData
  22814. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22815. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22816. * @returns the object VertexData associated to the passed mesh
  22817. */
  22818. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22819. /**
  22820. * Extracts the vertexData from the geometry
  22821. * @param geometry the geometry from which to extract the VertexData
  22822. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22823. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22824. * @returns the object VertexData associated to the passed mesh
  22825. */
  22826. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22827. private static _ExtractFrom;
  22828. /**
  22829. * Creates the VertexData for a Ribbon
  22830. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22831. * * pathArray array of paths, each of which an array of successive Vector3
  22832. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22833. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22834. * * 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
  22835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22836. * * 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)
  22837. * * 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)
  22838. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22839. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22840. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22841. * @returns the VertexData of the ribbon
  22842. */
  22843. static CreateRibbon(options: {
  22844. pathArray: Vector3[][];
  22845. closeArray?: boolean;
  22846. closePath?: boolean;
  22847. offset?: number;
  22848. sideOrientation?: number;
  22849. frontUVs?: Vector4;
  22850. backUVs?: Vector4;
  22851. invertUV?: boolean;
  22852. uvs?: Vector2[];
  22853. colors?: Color4[];
  22854. }): VertexData;
  22855. /**
  22856. * Creates the VertexData for a box
  22857. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22858. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22859. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22860. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22861. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22862. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22863. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22864. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22865. * * 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)
  22866. * * 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)
  22867. * @returns the VertexData of the box
  22868. */
  22869. static CreateBox(options: {
  22870. size?: number;
  22871. width?: number;
  22872. height?: number;
  22873. depth?: number;
  22874. faceUV?: Vector4[];
  22875. faceColors?: Color4[];
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22882. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22883. * * segments sets the number of horizontal strips optional, default 32
  22884. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22885. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22886. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22887. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22888. * * 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
  22889. * * 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
  22890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22891. * * 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)
  22892. * * 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)
  22893. * @returns the VertexData of the ellipsoid
  22894. */
  22895. static CreateSphere(options: {
  22896. segments?: number;
  22897. diameter?: number;
  22898. diameterX?: number;
  22899. diameterY?: number;
  22900. diameterZ?: number;
  22901. arc?: number;
  22902. slice?: number;
  22903. sideOrientation?: number;
  22904. frontUVs?: Vector4;
  22905. backUVs?: Vector4;
  22906. }): VertexData;
  22907. /**
  22908. * Creates the VertexData for a cylinder, cone or prism
  22909. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22910. * * height sets the height (y direction) of the cylinder, optional, default 2
  22911. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22912. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22913. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22914. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22915. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22916. * * 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
  22917. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22918. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22919. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22920. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22922. * * 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)
  22923. * * 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)
  22924. * @returns the VertexData of the cylinder, cone or prism
  22925. */
  22926. static CreateCylinder(options: {
  22927. height?: number;
  22928. diameterTop?: number;
  22929. diameterBottom?: number;
  22930. diameter?: number;
  22931. tessellation?: number;
  22932. subdivisions?: number;
  22933. arc?: number;
  22934. faceColors?: Color4[];
  22935. faceUV?: Vector4[];
  22936. hasRings?: boolean;
  22937. enclose?: boolean;
  22938. sideOrientation?: number;
  22939. frontUVs?: Vector4;
  22940. backUVs?: Vector4;
  22941. }): VertexData;
  22942. /**
  22943. * Creates the VertexData for a torus
  22944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22945. * * diameter the diameter of the torus, optional default 1
  22946. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22947. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22949. * * 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)
  22950. * * 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)
  22951. * @returns the VertexData of the torus
  22952. */
  22953. static CreateTorus(options: {
  22954. diameter?: number;
  22955. thickness?: number;
  22956. tessellation?: number;
  22957. sideOrientation?: number;
  22958. frontUVs?: Vector4;
  22959. backUVs?: Vector4;
  22960. }): VertexData;
  22961. /**
  22962. * Creates the VertexData of the LineSystem
  22963. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22964. * - lines an array of lines, each line being an array of successive Vector3
  22965. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22966. * @returns the VertexData of the LineSystem
  22967. */
  22968. static CreateLineSystem(options: {
  22969. lines: Vector3[][];
  22970. colors?: Nullable<Color4[][]>;
  22971. }): VertexData;
  22972. /**
  22973. * Create the VertexData for a DashedLines
  22974. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22975. * - points an array successive Vector3
  22976. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22977. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22978. * - dashNb the intended total number of dashes, optional, default 200
  22979. * @returns the VertexData for the DashedLines
  22980. */
  22981. static CreateDashedLines(options: {
  22982. points: Vector3[];
  22983. dashSize?: number;
  22984. gapSize?: number;
  22985. dashNb?: number;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData for a Ground
  22989. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22990. * - width the width (x direction) of the ground, optional, default 1
  22991. * - height the height (z direction) of the ground, optional, default 1
  22992. * - subdivisions the number of subdivisions per side, optional, default 1
  22993. * @returns the VertexData of the Ground
  22994. */
  22995. static CreateGround(options: {
  22996. width?: number;
  22997. height?: number;
  22998. subdivisions?: number;
  22999. subdivisionsX?: number;
  23000. subdivisionsY?: number;
  23001. }): VertexData;
  23002. /**
  23003. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23004. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23005. * * xmin the ground minimum X coordinate, optional, default -1
  23006. * * zmin the ground minimum Z coordinate, optional, default -1
  23007. * * xmax the ground maximum X coordinate, optional, default 1
  23008. * * zmax the ground maximum Z coordinate, optional, default 1
  23009. * * 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}
  23010. * * 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}
  23011. * @returns the VertexData of the TiledGround
  23012. */
  23013. static CreateTiledGround(options: {
  23014. xmin: number;
  23015. zmin: number;
  23016. xmax: number;
  23017. zmax: number;
  23018. subdivisions?: {
  23019. w: number;
  23020. h: number;
  23021. };
  23022. precision?: {
  23023. w: number;
  23024. h: number;
  23025. };
  23026. }): VertexData;
  23027. /**
  23028. * Creates the VertexData of the Ground designed from a heightmap
  23029. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23030. * * width the width (x direction) of the ground
  23031. * * height the height (z direction) of the ground
  23032. * * subdivisions the number of subdivisions per side
  23033. * * minHeight the minimum altitude on the ground, optional, default 0
  23034. * * maxHeight the maximum altitude on the ground, optional default 1
  23035. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23036. * * buffer the array holding the image color data
  23037. * * bufferWidth the width of image
  23038. * * bufferHeight the height of image
  23039. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23040. * @returns the VertexData of the Ground designed from a heightmap
  23041. */
  23042. static CreateGroundFromHeightMap(options: {
  23043. width: number;
  23044. height: number;
  23045. subdivisions: number;
  23046. minHeight: number;
  23047. maxHeight: number;
  23048. colorFilter: Color3;
  23049. buffer: Uint8Array;
  23050. bufferWidth: number;
  23051. bufferHeight: number;
  23052. alphaFilter: number;
  23053. }): VertexData;
  23054. /**
  23055. * Creates the VertexData for a Plane
  23056. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23057. * * size sets the width and height of the plane to the value of size, optional default 1
  23058. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23059. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23061. * * 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)
  23062. * * 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)
  23063. * @returns the VertexData of the box
  23064. */
  23065. static CreatePlane(options: {
  23066. size?: number;
  23067. width?: number;
  23068. height?: number;
  23069. sideOrientation?: number;
  23070. frontUVs?: Vector4;
  23071. backUVs?: Vector4;
  23072. }): VertexData;
  23073. /**
  23074. * Creates the VertexData of the Disc or regular Polygon
  23075. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23076. * * radius the radius of the disc, optional default 0.5
  23077. * * tessellation the number of polygon sides, optional, default 64
  23078. * * 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
  23079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23080. * * 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)
  23081. * * 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)
  23082. * @returns the VertexData of the box
  23083. */
  23084. static CreateDisc(options: {
  23085. radius?: number;
  23086. tessellation?: number;
  23087. arc?: number;
  23088. sideOrientation?: number;
  23089. frontUVs?: Vector4;
  23090. backUVs?: Vector4;
  23091. }): VertexData;
  23092. /**
  23093. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23094. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23095. * @param polygon a mesh built from polygonTriangulation.build()
  23096. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23097. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23098. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23099. * @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)
  23100. * @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)
  23101. * @returns the VertexData of the Polygon
  23102. */
  23103. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23104. /**
  23105. * Creates the VertexData of the IcoSphere
  23106. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23107. * * radius the radius of the IcoSphere, optional default 1
  23108. * * radiusX allows stretching in the x direction, optional, default radius
  23109. * * radiusY allows stretching in the y direction, optional, default radius
  23110. * * radiusZ allows stretching in the z direction, optional, default radius
  23111. * * flat when true creates a flat shaded mesh, optional, default true
  23112. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23114. * * 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)
  23115. * * 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)
  23116. * @returns the VertexData of the IcoSphere
  23117. */
  23118. static CreateIcoSphere(options: {
  23119. radius?: number;
  23120. radiusX?: number;
  23121. radiusY?: number;
  23122. radiusZ?: number;
  23123. flat?: boolean;
  23124. subdivisions?: number;
  23125. sideOrientation?: number;
  23126. frontUVs?: Vector4;
  23127. backUVs?: Vector4;
  23128. }): VertexData;
  23129. /**
  23130. * Creates the VertexData for a Polyhedron
  23131. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23132. * * type provided types are:
  23133. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23134. * * 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)
  23135. * * size the size of the IcoSphere, optional default 1
  23136. * * sizeX allows stretching in the x direction, optional, default size
  23137. * * sizeY allows stretching in the y direction, optional, default size
  23138. * * sizeZ allows stretching in the z direction, optional, default size
  23139. * * 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
  23140. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23141. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23142. * * flat when true creates a flat shaded mesh, optional, default true
  23143. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23145. * * 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)
  23146. * * 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)
  23147. * @returns the VertexData of the Polyhedron
  23148. */
  23149. static CreatePolyhedron(options: {
  23150. type?: number;
  23151. size?: number;
  23152. sizeX?: number;
  23153. sizeY?: number;
  23154. sizeZ?: number;
  23155. custom?: any;
  23156. faceUV?: Vector4[];
  23157. faceColors?: Color4[];
  23158. flat?: boolean;
  23159. sideOrientation?: number;
  23160. frontUVs?: Vector4;
  23161. backUVs?: Vector4;
  23162. }): VertexData;
  23163. /**
  23164. * Creates the VertexData for a TorusKnot
  23165. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23166. * * radius the radius of the torus knot, optional, default 2
  23167. * * tube the thickness of the tube, optional, default 0.5
  23168. * * radialSegments the number of sides on each tube segments, optional, default 32
  23169. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23170. * * p the number of windings around the z axis, optional, default 2
  23171. * * q the number of windings around the x axis, optional, default 3
  23172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23173. * * 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)
  23174. * * 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)
  23175. * @returns the VertexData of the Torus Knot
  23176. */
  23177. static CreateTorusKnot(options: {
  23178. radius?: number;
  23179. tube?: number;
  23180. radialSegments?: number;
  23181. tubularSegments?: number;
  23182. p?: number;
  23183. q?: number;
  23184. sideOrientation?: number;
  23185. frontUVs?: Vector4;
  23186. backUVs?: Vector4;
  23187. }): VertexData;
  23188. /**
  23189. * Compute normals for given positions and indices
  23190. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23191. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23192. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23193. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23194. * * facetNormals : optional array of facet normals (vector3)
  23195. * * facetPositions : optional array of facet positions (vector3)
  23196. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23197. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23198. * * bInfo : optional bounding info, required for facetPartitioning computation
  23199. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23200. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23201. * * useRightHandedSystem: optional boolean to for right handed system computation
  23202. * * depthSort : optional boolean to enable the facet depth sort computation
  23203. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23204. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23205. */
  23206. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23207. facetNormals?: any;
  23208. facetPositions?: any;
  23209. facetPartitioning?: any;
  23210. ratio?: number;
  23211. bInfo?: any;
  23212. bbSize?: Vector3;
  23213. subDiv?: any;
  23214. useRightHandedSystem?: boolean;
  23215. depthSort?: boolean;
  23216. distanceTo?: Vector3;
  23217. depthSortedFacets?: any;
  23218. }): void;
  23219. /** @hidden */
  23220. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23221. /**
  23222. * Applies VertexData created from the imported parameters to the geometry
  23223. * @param parsedVertexData the parsed data from an imported file
  23224. * @param geometry the geometry to apply the VertexData to
  23225. */
  23226. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23227. }
  23228. }
  23229. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23230. import { Nullable } from "babylonjs/types";
  23231. import { Scene } from "babylonjs/scene";
  23232. import { Vector4 } from "babylonjs/Maths/math";
  23233. import { Mesh } from "babylonjs/Meshes/mesh";
  23234. /**
  23235. * Class containing static functions to help procedurally build meshes
  23236. */
  23237. export class DiscBuilder {
  23238. /**
  23239. * Creates a plane polygonal mesh. By default, this is a disc
  23240. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23241. * * 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
  23242. * * 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
  23243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23244. * * If you create a double-sided mesh, you can choose what parts of 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
  23245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23246. * @param name defines the name of the mesh
  23247. * @param options defines the options used to create the mesh
  23248. * @param scene defines the hosting scene
  23249. * @returns the plane polygonal mesh
  23250. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23251. */
  23252. static CreateDisc(name: string, options: {
  23253. radius?: number;
  23254. tessellation?: number;
  23255. arc?: number;
  23256. updatable?: boolean;
  23257. sideOrientation?: number;
  23258. frontUVs?: Vector4;
  23259. backUVs?: Vector4;
  23260. }, scene?: Nullable<Scene>): Mesh;
  23261. }
  23262. }
  23263. declare module "babylonjs/Particles/solidParticleSystem" {
  23264. import { Vector3 } from "babylonjs/Maths/math";
  23265. import { Mesh } from "babylonjs/Meshes/mesh";
  23266. import { Scene, IDisposable } from "babylonjs/scene";
  23267. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23268. /**
  23269. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23270. *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.
  23271. * The SPS is also a particle system. It provides some methods to manage the particles.
  23272. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23273. *
  23274. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23275. */
  23276. export class SolidParticleSystem implements IDisposable {
  23277. /**
  23278. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23279. * Example : var p = SPS.particles[i];
  23280. */
  23281. particles: SolidParticle[];
  23282. /**
  23283. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23284. */
  23285. nbParticles: number;
  23286. /**
  23287. * If the particles must ever face the camera (default false). Useful for planar particles.
  23288. */
  23289. billboard: boolean;
  23290. /**
  23291. * Recompute normals when adding a shape
  23292. */
  23293. recomputeNormals: boolean;
  23294. /**
  23295. * This a counter ofr your own usage. It's not set by any SPS functions.
  23296. */
  23297. counter: number;
  23298. /**
  23299. * The SPS name. This name is also given to the underlying mesh.
  23300. */
  23301. name: string;
  23302. /**
  23303. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23304. */
  23305. mesh: Mesh;
  23306. /**
  23307. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23308. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23309. */
  23310. vars: any;
  23311. /**
  23312. * This array is populated when the SPS is set as 'pickable'.
  23313. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23314. * Each element of this array is an object `{idx: int, faceId: int}`.
  23315. * `idx` is the picked particle index in the `SPS.particles` array
  23316. * `faceId` is the picked face index counted within this particle.
  23317. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23318. */
  23319. pickedParticles: {
  23320. idx: number;
  23321. faceId: number;
  23322. }[];
  23323. /**
  23324. * This array is populated when `enableDepthSort` is set to true.
  23325. * Each element of this array is an instance of the class DepthSortedParticle.
  23326. */
  23327. depthSortedParticles: DepthSortedParticle[];
  23328. /**
  23329. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23330. * @hidden
  23331. */
  23332. _bSphereOnly: boolean;
  23333. /**
  23334. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23335. * @hidden
  23336. */
  23337. _bSphereRadiusFactor: number;
  23338. private _scene;
  23339. private _positions;
  23340. private _indices;
  23341. private _normals;
  23342. private _colors;
  23343. private _uvs;
  23344. private _indices32;
  23345. private _positions32;
  23346. private _normals32;
  23347. private _fixedNormal32;
  23348. private _colors32;
  23349. private _uvs32;
  23350. private _index;
  23351. private _updatable;
  23352. private _pickable;
  23353. private _isVisibilityBoxLocked;
  23354. private _alwaysVisible;
  23355. private _depthSort;
  23356. private _shapeCounter;
  23357. private _copy;
  23358. private _color;
  23359. private _computeParticleColor;
  23360. private _computeParticleTexture;
  23361. private _computeParticleRotation;
  23362. private _computeParticleVertex;
  23363. private _computeBoundingBox;
  23364. private _depthSortParticles;
  23365. private _camera;
  23366. private _mustUnrotateFixedNormals;
  23367. private _particlesIntersect;
  23368. private _needs32Bits;
  23369. /**
  23370. * Creates a SPS (Solid Particle System) object.
  23371. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23372. * @param scene (Scene) is the scene in which the SPS is added.
  23373. * @param options defines the options of the sps e.g.
  23374. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23375. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23376. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23377. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23378. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23379. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23380. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23381. */
  23382. constructor(name: string, scene: Scene, options?: {
  23383. updatable?: boolean;
  23384. isPickable?: boolean;
  23385. enableDepthSort?: boolean;
  23386. particleIntersection?: boolean;
  23387. boundingSphereOnly?: boolean;
  23388. bSphereRadiusFactor?: number;
  23389. });
  23390. /**
  23391. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23392. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23393. * @returns the created mesh
  23394. */
  23395. buildMesh(): Mesh;
  23396. /**
  23397. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23398. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23399. * Thus the particles generated from `digest()` have their property `position` set yet.
  23400. * @param mesh ( Mesh ) is the mesh to be digested
  23401. * @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
  23402. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23403. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23404. * @returns the current SPS
  23405. */
  23406. digest(mesh: Mesh, options?: {
  23407. facetNb?: number;
  23408. number?: number;
  23409. delta?: number;
  23410. }): SolidParticleSystem;
  23411. private _unrotateFixedNormals;
  23412. private _resetCopy;
  23413. private _meshBuilder;
  23414. private _posToShape;
  23415. private _uvsToShapeUV;
  23416. private _addParticle;
  23417. /**
  23418. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23419. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23420. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23421. * @param nb (positive integer) the number of particles to be created from this model
  23422. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23423. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23424. * @returns the number of shapes in the system
  23425. */
  23426. addShape(mesh: Mesh, nb: number, options?: {
  23427. positionFunction?: any;
  23428. vertexFunction?: any;
  23429. }): number;
  23430. private _rebuildParticle;
  23431. /**
  23432. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23433. * @returns the SPS.
  23434. */
  23435. rebuildMesh(): SolidParticleSystem;
  23436. /**
  23437. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23438. * This method calls `updateParticle()` for each particle of the SPS.
  23439. * For an animated SPS, it is usually called within the render loop.
  23440. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23441. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23442. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23443. * @returns the SPS.
  23444. */
  23445. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23446. /**
  23447. * Disposes the SPS.
  23448. */
  23449. dispose(): void;
  23450. /**
  23451. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23452. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23453. * @returns the SPS.
  23454. */
  23455. refreshVisibleSize(): SolidParticleSystem;
  23456. /**
  23457. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23458. * @param size the size (float) of the visibility box
  23459. * note : this doesn't lock the SPS mesh bounding box.
  23460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23461. */
  23462. setVisibilityBox(size: number): void;
  23463. /**
  23464. * Gets whether the SPS as always visible or not
  23465. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23466. */
  23467. /**
  23468. * Sets the SPS as always visible or not
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23470. */
  23471. isAlwaysVisible: boolean;
  23472. /**
  23473. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23474. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23475. */
  23476. /**
  23477. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23478. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23479. */
  23480. isVisibilityBoxLocked: boolean;
  23481. /**
  23482. * Tells to `setParticles()` to compute the particle rotations or not.
  23483. * Default value : true. The SPS is faster when it's set to false.
  23484. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23485. */
  23486. /**
  23487. * Gets if `setParticles()` computes the particle rotations or not.
  23488. * Default value : true. The SPS is faster when it's set to false.
  23489. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23490. */
  23491. computeParticleRotation: boolean;
  23492. /**
  23493. * Tells to `setParticles()` to compute the particle colors or not.
  23494. * Default value : true. The SPS is faster when it's set to false.
  23495. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23496. */
  23497. /**
  23498. * Gets if `setParticles()` computes the particle colors or not.
  23499. * Default value : true. The SPS is faster when it's set to false.
  23500. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23501. */
  23502. computeParticleColor: boolean;
  23503. /**
  23504. * Gets if `setParticles()` computes the particle textures or not.
  23505. * Default value : true. The SPS is faster when it's set to false.
  23506. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23507. */
  23508. computeParticleTexture: boolean;
  23509. /**
  23510. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23511. * Default value : false. The SPS is faster when it's set to false.
  23512. * Note : the particle custom vertex positions aren't stored values.
  23513. */
  23514. /**
  23515. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23516. * Default value : false. The SPS is faster when it's set to false.
  23517. * Note : the particle custom vertex positions aren't stored values.
  23518. */
  23519. computeParticleVertex: boolean;
  23520. /**
  23521. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23522. */
  23523. /**
  23524. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23525. */
  23526. computeBoundingBox: boolean;
  23527. /**
  23528. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23529. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23530. * Default : `true`
  23531. */
  23532. /**
  23533. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23534. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23535. * Default : `true`
  23536. */
  23537. depthSortParticles: boolean;
  23538. /**
  23539. * This function does nothing. It may be overwritten to set all the particle first values.
  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. */
  23543. initParticles(): void;
  23544. /**
  23545. * This function does nothing. It may be overwritten to recycle a particle.
  23546. * The SPS doesn't call this function, you may have to call it by your own.
  23547. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23548. * @param particle The particle to recycle
  23549. * @returns the recycled particle
  23550. */
  23551. recycleParticle(particle: SolidParticle): SolidParticle;
  23552. /**
  23553. * Updates a particle : this function should be overwritten by the user.
  23554. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23555. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23556. * @example : just set a particle position or velocity and recycle conditions
  23557. * @param particle The particle to update
  23558. * @returns the updated particle
  23559. */
  23560. updateParticle(particle: SolidParticle): SolidParticle;
  23561. /**
  23562. * Updates a vertex of a particle : it can be overwritten by the user.
  23563. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23564. * @param particle the current particle
  23565. * @param vertex the current index of the current particle
  23566. * @param pt the index of the current vertex in the particle shape
  23567. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23568. * @example : just set a vertex particle position
  23569. * @returns the updated vertex
  23570. */
  23571. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23572. /**
  23573. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23574. * This does nothing and may be overwritten by the user.
  23575. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23576. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23577. * @param update the boolean update value actually passed to setParticles()
  23578. */
  23579. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23580. /**
  23581. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23582. * This will be passed three parameters.
  23583. * This does nothing and may be overwritten by the user.
  23584. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23585. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23586. * @param update the boolean update value actually passed to setParticles()
  23587. */
  23588. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23589. }
  23590. }
  23591. declare module "babylonjs/Particles/solidParticle" {
  23592. import { Nullable } from "babylonjs/types";
  23593. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23594. import { Mesh } from "babylonjs/Meshes/mesh";
  23595. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23596. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23597. /**
  23598. * Represents one particle of a solid particle system.
  23599. */
  23600. export class SolidParticle {
  23601. /**
  23602. * particle global index
  23603. */
  23604. idx: number;
  23605. /**
  23606. * The color of the particle
  23607. */
  23608. color: Nullable<Color4>;
  23609. /**
  23610. * The world space position of the particle.
  23611. */
  23612. position: Vector3;
  23613. /**
  23614. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23615. */
  23616. rotation: Vector3;
  23617. /**
  23618. * The world space rotation quaternion of the particle.
  23619. */
  23620. rotationQuaternion: Nullable<Quaternion>;
  23621. /**
  23622. * The scaling of the particle.
  23623. */
  23624. scaling: Vector3;
  23625. /**
  23626. * The uvs of the particle.
  23627. */
  23628. uvs: Vector4;
  23629. /**
  23630. * The current speed of the particle.
  23631. */
  23632. velocity: Vector3;
  23633. /**
  23634. * The pivot point in the particle local space.
  23635. */
  23636. pivot: Vector3;
  23637. /**
  23638. * Must the particle be translated from its pivot point in its local space ?
  23639. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23640. * Default : false
  23641. */
  23642. translateFromPivot: boolean;
  23643. /**
  23644. * Is the particle active or not ?
  23645. */
  23646. alive: boolean;
  23647. /**
  23648. * Is the particle visible or not ?
  23649. */
  23650. isVisible: boolean;
  23651. /**
  23652. * Index of this particle in the global "positions" array (Internal use)
  23653. * @hidden
  23654. */
  23655. _pos: number;
  23656. /**
  23657. * @hidden Index of this particle in the global "indices" array (Internal use)
  23658. */
  23659. _ind: number;
  23660. /**
  23661. * @hidden ModelShape of this particle (Internal use)
  23662. */
  23663. _model: ModelShape;
  23664. /**
  23665. * ModelShape id of this particle
  23666. */
  23667. shapeId: number;
  23668. /**
  23669. * Index of the particle in its shape id (Internal use)
  23670. */
  23671. idxInShape: number;
  23672. /**
  23673. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23674. */
  23675. _modelBoundingInfo: BoundingInfo;
  23676. /**
  23677. * @hidden Particle BoundingInfo object (Internal use)
  23678. */
  23679. _boundingInfo: BoundingInfo;
  23680. /**
  23681. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23682. */
  23683. _sps: SolidParticleSystem;
  23684. /**
  23685. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23686. */
  23687. _stillInvisible: boolean;
  23688. /**
  23689. * @hidden Last computed particle rotation matrix
  23690. */
  23691. _rotationMatrix: number[];
  23692. /**
  23693. * Parent particle Id, if any.
  23694. * Default null.
  23695. */
  23696. parentId: Nullable<number>;
  23697. /**
  23698. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23699. * The possible values are :
  23700. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23701. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23702. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23703. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23704. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23705. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23706. * */
  23707. cullingStrategy: number;
  23708. /**
  23709. * @hidden Internal global position in the SPS.
  23710. */
  23711. _globalPosition: Vector3;
  23712. /**
  23713. * Creates a Solid Particle object.
  23714. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23715. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23716. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23717. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23718. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23719. * @param shapeId (integer) is the model shape identifier in the SPS.
  23720. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23721. * @param sps defines the sps it is associated to
  23722. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23723. */
  23724. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23725. /**
  23726. * Legacy support, changed scale to scaling
  23727. */
  23728. /**
  23729. * Legacy support, changed scale to scaling
  23730. */
  23731. scale: Vector3;
  23732. /**
  23733. * Legacy support, changed quaternion to rotationQuaternion
  23734. */
  23735. /**
  23736. * Legacy support, changed quaternion to rotationQuaternion
  23737. */
  23738. quaternion: Nullable<Quaternion>;
  23739. /**
  23740. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23741. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23742. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23743. * @returns true if it intersects
  23744. */
  23745. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23746. /**
  23747. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23748. * A particle is in the frustum if its bounding box intersects the frustum
  23749. * @param frustumPlanes defines the frustum to test
  23750. * @returns true if the particle is in the frustum planes
  23751. */
  23752. isInFrustum(frustumPlanes: Plane[]): boolean;
  23753. /**
  23754. * get the rotation matrix of the particle
  23755. * @hidden
  23756. */
  23757. getRotationMatrix(m: Matrix): void;
  23758. }
  23759. /**
  23760. * Represents the shape of the model used by one particle of a solid particle system.
  23761. * SPS internal tool, don't use it manually.
  23762. */
  23763. export class ModelShape {
  23764. /**
  23765. * The shape id
  23766. * @hidden
  23767. */
  23768. shapeID: number;
  23769. /**
  23770. * flat array of model positions (internal use)
  23771. * @hidden
  23772. */
  23773. _shape: Vector3[];
  23774. /**
  23775. * flat array of model UVs (internal use)
  23776. * @hidden
  23777. */
  23778. _shapeUV: number[];
  23779. /**
  23780. * length of the shape in the model indices array (internal use)
  23781. * @hidden
  23782. */
  23783. _indicesLength: number;
  23784. /**
  23785. * Custom position function (internal use)
  23786. * @hidden
  23787. */
  23788. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23789. /**
  23790. * Custom vertex function (internal use)
  23791. * @hidden
  23792. */
  23793. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23794. /**
  23795. * 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.
  23796. * SPS internal tool, don't use it manually.
  23797. * @hidden
  23798. */
  23799. 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>);
  23800. }
  23801. /**
  23802. * Represents a Depth Sorted Particle in the solid particle system.
  23803. */
  23804. export class DepthSortedParticle {
  23805. /**
  23806. * Index of the particle in the "indices" array
  23807. */
  23808. ind: number;
  23809. /**
  23810. * Length of the particle shape in the "indices" array
  23811. */
  23812. indicesLength: number;
  23813. /**
  23814. * Squared distance from the particle to the camera
  23815. */
  23816. sqDistance: number;
  23817. }
  23818. }
  23819. declare module "babylonjs/Meshes/abstractMesh" {
  23820. import { Observable } from "babylonjs/Misc/observable";
  23821. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23822. import { Camera } from "babylonjs/Cameras/camera";
  23823. import { Scene, IDisposable } from "babylonjs/scene";
  23824. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23825. import { Node } from "babylonjs/node";
  23826. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23827. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23828. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23829. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23830. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23831. import { Material } from "babylonjs/Materials/material";
  23832. import { Light } from "babylonjs/Lights/light";
  23833. import { Skeleton } from "babylonjs/Bones/skeleton";
  23834. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23835. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23836. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23837. import { Ray } from "babylonjs/Culling/ray";
  23838. import { Collider } from "babylonjs/Collisions/collider";
  23839. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23840. /**
  23841. * Class used to store all common mesh properties
  23842. */
  23843. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23844. /** No occlusion */
  23845. static OCCLUSION_TYPE_NONE: number;
  23846. /** Occlusion set to optimisitic */
  23847. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23848. /** Occlusion set to strict */
  23849. static OCCLUSION_TYPE_STRICT: number;
  23850. /** Use an accurante occlusion algorithm */
  23851. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23852. /** Use a conservative occlusion algorithm */
  23853. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23854. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23855. * Test order :
  23856. * Is the bounding sphere outside the frustum ?
  23857. * If not, are the bounding box vertices outside the frustum ?
  23858. * It not, then the cullable object is in the frustum.
  23859. */
  23860. static readonly CULLINGSTRATEGY_STANDARD: number;
  23861. /** Culling strategy : Bounding Sphere Only.
  23862. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23863. * It's also less accurate than the standard because some not visible objects can still be selected.
  23864. * Test : is the bounding sphere outside the frustum ?
  23865. * If not, then the cullable object is in the frustum.
  23866. */
  23867. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23868. /** Culling strategy : Optimistic Inclusion.
  23869. * This in an inclusion test first, then the standard exclusion test.
  23870. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23871. * 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.
  23872. * Anyway, it's as accurate as the standard strategy.
  23873. * Test :
  23874. * Is the cullable object bounding sphere center in the frustum ?
  23875. * If not, apply the default culling strategy.
  23876. */
  23877. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23878. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23879. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23880. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23881. * 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.
  23882. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23883. * Test :
  23884. * Is the cullable object bounding sphere center in the frustum ?
  23885. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23886. */
  23887. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23888. /**
  23889. * No billboard
  23890. */
  23891. static readonly BILLBOARDMODE_NONE: number;
  23892. /** Billboard on X axis */
  23893. static readonly BILLBOARDMODE_X: number;
  23894. /** Billboard on Y axis */
  23895. static readonly BILLBOARDMODE_Y: number;
  23896. /** Billboard on Z axis */
  23897. static readonly BILLBOARDMODE_Z: number;
  23898. /** Billboard on all axes */
  23899. static readonly BILLBOARDMODE_ALL: number;
  23900. private _facetData;
  23901. /**
  23902. * The culling strategy to use to check whether the mesh must be rendered or not.
  23903. * This value can be changed at any time and will be used on the next render mesh selection.
  23904. * The possible values are :
  23905. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23906. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23907. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23908. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23909. * Please read each static variable documentation to get details about the culling process.
  23910. * */
  23911. cullingStrategy: number;
  23912. /**
  23913. * Gets the number of facets in the mesh
  23914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23915. */
  23916. readonly facetNb: number;
  23917. /**
  23918. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23920. */
  23921. partitioningSubdivisions: number;
  23922. /**
  23923. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23924. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23926. */
  23927. partitioningBBoxRatio: number;
  23928. /**
  23929. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23930. * Works only for updatable meshes.
  23931. * Doesn't work with multi-materials
  23932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23933. */
  23934. mustDepthSortFacets: boolean;
  23935. /**
  23936. * The location (Vector3) where the facet depth sort must be computed from.
  23937. * By default, the active camera position.
  23938. * Used only when facet depth sort is enabled
  23939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23940. */
  23941. facetDepthSortFrom: Vector3;
  23942. /**
  23943. * gets a boolean indicating if facetData is enabled
  23944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23945. */
  23946. readonly isFacetDataEnabled: boolean;
  23947. /** @hidden */
  23948. _updateNonUniformScalingState(value: boolean): boolean;
  23949. /**
  23950. * An event triggered when this mesh collides with another one
  23951. */
  23952. onCollideObservable: Observable<AbstractMesh>;
  23953. private _onCollideObserver;
  23954. /** Set a function to call when this mesh collides with another one */
  23955. onCollide: () => void;
  23956. /**
  23957. * An event triggered when the collision's position changes
  23958. */
  23959. onCollisionPositionChangeObservable: Observable<Vector3>;
  23960. private _onCollisionPositionChangeObserver;
  23961. /** Set a function to call when the collision's position changes */
  23962. onCollisionPositionChange: () => void;
  23963. /**
  23964. * An event triggered when material is changed
  23965. */
  23966. onMaterialChangedObservable: Observable<AbstractMesh>;
  23967. /**
  23968. * Gets or sets the orientation for POV movement & rotation
  23969. */
  23970. definedFacingForward: boolean;
  23971. /** @hidden */
  23972. _occlusionQuery: Nullable<WebGLQuery>;
  23973. private _visibility;
  23974. /**
  23975. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23976. */
  23977. /**
  23978. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23979. */
  23980. visibility: number;
  23981. /** Gets or sets the alpha index used to sort transparent meshes
  23982. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23983. */
  23984. alphaIndex: number;
  23985. /**
  23986. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23987. */
  23988. isVisible: boolean;
  23989. /**
  23990. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23991. */
  23992. isPickable: boolean;
  23993. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23994. showSubMeshesBoundingBox: boolean;
  23995. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23997. */
  23998. isBlocker: boolean;
  23999. /**
  24000. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24001. */
  24002. enablePointerMoveEvents: boolean;
  24003. /**
  24004. * Specifies the rendering group id for this mesh (0 by default)
  24005. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24006. */
  24007. renderingGroupId: number;
  24008. private _material;
  24009. /** Gets or sets current material */
  24010. material: Nullable<Material>;
  24011. private _receiveShadows;
  24012. /**
  24013. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24014. * @see http://doc.babylonjs.com/babylon101/shadows
  24015. */
  24016. receiveShadows: boolean;
  24017. /** Defines color to use when rendering outline */
  24018. outlineColor: Color3;
  24019. /** Define width to use when rendering outline */
  24020. outlineWidth: number;
  24021. /** Defines color to use when rendering overlay */
  24022. overlayColor: Color3;
  24023. /** Defines alpha to use when rendering overlay */
  24024. overlayAlpha: number;
  24025. private _hasVertexAlpha;
  24026. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24027. hasVertexAlpha: boolean;
  24028. private _useVertexColors;
  24029. /** 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) */
  24030. useVertexColors: boolean;
  24031. private _computeBonesUsingShaders;
  24032. /**
  24033. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24034. */
  24035. computeBonesUsingShaders: boolean;
  24036. private _numBoneInfluencers;
  24037. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24038. numBoneInfluencers: number;
  24039. private _applyFog;
  24040. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24041. applyFog: boolean;
  24042. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24043. useOctreeForRenderingSelection: boolean;
  24044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24045. useOctreeForPicking: boolean;
  24046. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24047. useOctreeForCollisions: boolean;
  24048. private _layerMask;
  24049. /**
  24050. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24051. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24052. */
  24053. layerMask: number;
  24054. /**
  24055. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24056. */
  24057. alwaysSelectAsActiveMesh: boolean;
  24058. /**
  24059. * Gets or sets the current action manager
  24060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24061. */
  24062. actionManager: Nullable<AbstractActionManager>;
  24063. private _checkCollisions;
  24064. private _collisionMask;
  24065. private _collisionGroup;
  24066. /**
  24067. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24069. */
  24070. ellipsoid: Vector3;
  24071. /**
  24072. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24073. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24074. */
  24075. ellipsoidOffset: Vector3;
  24076. private _collider;
  24077. private _oldPositionForCollisions;
  24078. private _diffPositionForCollisions;
  24079. /**
  24080. * Gets or sets a collision mask used to mask collisions (default is -1).
  24081. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24082. */
  24083. collisionMask: number;
  24084. /**
  24085. * Gets or sets the current collision group mask (-1 by default).
  24086. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24087. */
  24088. collisionGroup: number;
  24089. /**
  24090. * Defines edge width used when edgesRenderer is enabled
  24091. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24092. */
  24093. edgesWidth: number;
  24094. /**
  24095. * Defines edge color used when edgesRenderer is enabled
  24096. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24097. */
  24098. edgesColor: Color4;
  24099. /** @hidden */
  24100. _edgesRenderer: Nullable<IEdgesRenderer>;
  24101. /** @hidden */
  24102. _masterMesh: Nullable<AbstractMesh>;
  24103. /** @hidden */
  24104. _boundingInfo: Nullable<BoundingInfo>;
  24105. /** @hidden */
  24106. _renderId: number;
  24107. /**
  24108. * Gets or sets the list of subMeshes
  24109. * @see http://doc.babylonjs.com/how_to/multi_materials
  24110. */
  24111. subMeshes: SubMesh[];
  24112. /** @hidden */
  24113. _intersectionsInProgress: AbstractMesh[];
  24114. /** @hidden */
  24115. _unIndexed: boolean;
  24116. /** @hidden */
  24117. _lightSources: Light[];
  24118. /** @hidden */
  24119. readonly _positions: Nullable<Vector3[]>;
  24120. /** @hidden */
  24121. _waitingActions: any;
  24122. /** @hidden */
  24123. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24124. private _skeleton;
  24125. /** @hidden */
  24126. _bonesTransformMatrices: Nullable<Float32Array>;
  24127. /**
  24128. * Gets or sets a skeleton to apply skining transformations
  24129. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24130. */
  24131. skeleton: Nullable<Skeleton>;
  24132. /**
  24133. * An event triggered when the mesh is rebuilt.
  24134. */
  24135. onRebuildObservable: Observable<AbstractMesh>;
  24136. /**
  24137. * Creates a new AbstractMesh
  24138. * @param name defines the name of the mesh
  24139. * @param scene defines the hosting scene
  24140. */
  24141. constructor(name: string, scene?: Nullable<Scene>);
  24142. /**
  24143. * Returns the string "AbstractMesh"
  24144. * @returns "AbstractMesh"
  24145. */
  24146. getClassName(): string;
  24147. /**
  24148. * Gets a string representation of the current mesh
  24149. * @param fullDetails defines a boolean indicating if full details must be included
  24150. * @returns a string representation of the current mesh
  24151. */
  24152. toString(fullDetails?: boolean): string;
  24153. /** @hidden */
  24154. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24155. /** @hidden */
  24156. _rebuild(): void;
  24157. /** @hidden */
  24158. _resyncLightSources(): void;
  24159. /** @hidden */
  24160. _resyncLighSource(light: Light): void;
  24161. /** @hidden */
  24162. _unBindEffect(): void;
  24163. /** @hidden */
  24164. _removeLightSource(light: Light): void;
  24165. private _markSubMeshesAsDirty;
  24166. /** @hidden */
  24167. _markSubMeshesAsLightDirty(): void;
  24168. /** @hidden */
  24169. _markSubMeshesAsAttributesDirty(): void;
  24170. /** @hidden */
  24171. _markSubMeshesAsMiscDirty(): void;
  24172. /**
  24173. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24174. */
  24175. scaling: Vector3;
  24176. /**
  24177. * Returns true if the mesh is blocked. Implemented by child classes
  24178. */
  24179. readonly isBlocked: boolean;
  24180. /**
  24181. * Returns the mesh itself by default. Implemented by child classes
  24182. * @param camera defines the camera to use to pick the right LOD level
  24183. * @returns the currentAbstractMesh
  24184. */
  24185. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24186. /**
  24187. * Returns 0 by default. Implemented by child classes
  24188. * @returns an integer
  24189. */
  24190. getTotalVertices(): number;
  24191. /**
  24192. * Returns a positive integer : the total number of indices in this mesh geometry.
  24193. * @returns the numner of indices or zero if the mesh has no geometry.
  24194. */
  24195. getTotalIndices(): number;
  24196. /**
  24197. * Returns null by default. Implemented by child classes
  24198. * @returns null
  24199. */
  24200. getIndices(): Nullable<IndicesArray>;
  24201. /**
  24202. * Returns the array of the requested vertex data kind. Implemented by child classes
  24203. * @param kind defines the vertex data kind to use
  24204. * @returns null
  24205. */
  24206. getVerticesData(kind: string): Nullable<FloatArray>;
  24207. /**
  24208. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24209. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24210. * Note that a new underlying VertexBuffer object is created each call.
  24211. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24212. * @param kind defines vertex data kind:
  24213. * * VertexBuffer.PositionKind
  24214. * * VertexBuffer.UVKind
  24215. * * VertexBuffer.UV2Kind
  24216. * * VertexBuffer.UV3Kind
  24217. * * VertexBuffer.UV4Kind
  24218. * * VertexBuffer.UV5Kind
  24219. * * VertexBuffer.UV6Kind
  24220. * * VertexBuffer.ColorKind
  24221. * * VertexBuffer.MatricesIndicesKind
  24222. * * VertexBuffer.MatricesIndicesExtraKind
  24223. * * VertexBuffer.MatricesWeightsKind
  24224. * * VertexBuffer.MatricesWeightsExtraKind
  24225. * @param data defines the data source
  24226. * @param updatable defines if the data must be flagged as updatable (or static)
  24227. * @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
  24228. * @returns the current mesh
  24229. */
  24230. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24231. /**
  24232. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24233. * If the mesh has no geometry, it is simply returned as it is.
  24234. * @param kind defines vertex data kind:
  24235. * * VertexBuffer.PositionKind
  24236. * * VertexBuffer.UVKind
  24237. * * VertexBuffer.UV2Kind
  24238. * * VertexBuffer.UV3Kind
  24239. * * VertexBuffer.UV4Kind
  24240. * * VertexBuffer.UV5Kind
  24241. * * VertexBuffer.UV6Kind
  24242. * * VertexBuffer.ColorKind
  24243. * * VertexBuffer.MatricesIndicesKind
  24244. * * VertexBuffer.MatricesIndicesExtraKind
  24245. * * VertexBuffer.MatricesWeightsKind
  24246. * * VertexBuffer.MatricesWeightsExtraKind
  24247. * @param data defines the data source
  24248. * @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
  24249. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24250. * @returns the current mesh
  24251. */
  24252. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24253. /**
  24254. * Sets the mesh indices,
  24255. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24256. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24257. * @param totalVertices Defines the total number of vertices
  24258. * @returns the current mesh
  24259. */
  24260. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24261. /**
  24262. * Gets a boolean indicating if specific vertex data is present
  24263. * @param kind defines the vertex data kind to use
  24264. * @returns true is data kind is present
  24265. */
  24266. isVerticesDataPresent(kind: string): boolean;
  24267. /**
  24268. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24269. * @returns a BoundingInfo
  24270. */
  24271. getBoundingInfo(): BoundingInfo;
  24272. /**
  24273. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24274. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24275. * @returns the current mesh
  24276. */
  24277. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24278. /**
  24279. * Overwrite the current bounding info
  24280. * @param boundingInfo defines the new bounding info
  24281. * @returns the current mesh
  24282. */
  24283. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24284. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24285. readonly useBones: boolean;
  24286. /** @hidden */
  24287. _preActivate(): void;
  24288. /** @hidden */
  24289. _preActivateForIntermediateRendering(renderId: number): void;
  24290. /** @hidden */
  24291. _activate(renderId: number): void;
  24292. /**
  24293. * Gets the current world matrix
  24294. * @returns a Matrix
  24295. */
  24296. getWorldMatrix(): Matrix;
  24297. /** @hidden */
  24298. _getWorldMatrixDeterminant(): number;
  24299. /**
  24300. * Perform relative position change from the point of view of behind the front of the mesh.
  24301. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24302. * Supports definition of mesh facing forward or backward
  24303. * @param amountRight defines the distance on the right axis
  24304. * @param amountUp defines the distance on the up axis
  24305. * @param amountForward defines the distance on the forward axis
  24306. * @returns the current mesh
  24307. */
  24308. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24309. /**
  24310. * Calculate relative position change from the point of view of behind the front of the mesh.
  24311. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24312. * Supports definition of mesh facing forward or backward
  24313. * @param amountRight defines the distance on the right axis
  24314. * @param amountUp defines the distance on the up axis
  24315. * @param amountForward defines the distance on the forward axis
  24316. * @returns the new displacement vector
  24317. */
  24318. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24319. /**
  24320. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24321. * Supports definition of mesh facing forward or backward
  24322. * @param flipBack defines the flip
  24323. * @param twirlClockwise defines the twirl
  24324. * @param tiltRight defines the tilt
  24325. * @returns the current mesh
  24326. */
  24327. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24328. /**
  24329. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24330. * Supports definition of mesh facing forward or backward.
  24331. * @param flipBack defines the flip
  24332. * @param twirlClockwise defines the twirl
  24333. * @param tiltRight defines the tilt
  24334. * @returns the new rotation vector
  24335. */
  24336. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24337. /**
  24338. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24339. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24340. * @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
  24341. * @returns the new bounding vectors
  24342. */
  24343. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24344. min: Vector3;
  24345. max: Vector3;
  24346. };
  24347. /**
  24348. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24349. * This means the mesh underlying bounding box and sphere are recomputed.
  24350. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24351. * @returns the current mesh
  24352. */
  24353. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24354. /** @hidden */
  24355. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24356. /** @hidden */
  24357. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24358. /** @hidden */
  24359. _updateBoundingInfo(): AbstractMesh;
  24360. /** @hidden */
  24361. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24362. /** @hidden */
  24363. protected _afterComputeWorldMatrix(): void;
  24364. /**
  24365. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24366. * A mesh is in the frustum if its bounding box intersects the frustum
  24367. * @param frustumPlanes defines the frustum to test
  24368. * @returns true if the mesh is in the frustum planes
  24369. */
  24370. isInFrustum(frustumPlanes: Plane[]): boolean;
  24371. /**
  24372. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24373. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24374. * @param frustumPlanes defines the frustum to test
  24375. * @returns true if the mesh is completely in the frustum planes
  24376. */
  24377. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24378. /**
  24379. * True if the mesh intersects another mesh or a SolidParticle object
  24380. * @param mesh defines a target mesh or SolidParticle to test
  24381. * @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)
  24382. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24383. * @returns true if there is an intersection
  24384. */
  24385. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24386. /**
  24387. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24388. * @param point defines the point to test
  24389. * @returns true if there is an intersection
  24390. */
  24391. intersectsPoint(point: Vector3): boolean;
  24392. /**
  24393. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24395. */
  24396. checkCollisions: boolean;
  24397. /**
  24398. * Gets Collider object used to compute collisions (not physics)
  24399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24400. */
  24401. readonly collider: Collider;
  24402. /**
  24403. * Move the mesh using collision engine
  24404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24405. * @param displacement defines the requested displacement vector
  24406. * @returns the current mesh
  24407. */
  24408. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24409. private _onCollisionPositionChange;
  24410. /** @hidden */
  24411. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24412. /** @hidden */
  24413. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24414. /** @hidden */
  24415. _checkCollision(collider: Collider): AbstractMesh;
  24416. /** @hidden */
  24417. _generatePointsArray(): boolean;
  24418. /**
  24419. * Checks if the passed Ray intersects with the mesh
  24420. * @param ray defines the ray to use
  24421. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24422. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24423. * @returns the picking info
  24424. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24425. */
  24426. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24427. /**
  24428. * Clones the current mesh
  24429. * @param name defines the mesh name
  24430. * @param newParent defines the new mesh parent
  24431. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24432. * @returns the new mesh
  24433. */
  24434. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24435. /**
  24436. * Disposes all the submeshes of the current meshnp
  24437. * @returns the current mesh
  24438. */
  24439. releaseSubMeshes(): AbstractMesh;
  24440. /**
  24441. * Releases resources associated with this abstract mesh.
  24442. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24443. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24444. */
  24445. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24446. /**
  24447. * Adds the passed mesh as a child to the current mesh
  24448. * @param mesh defines the child mesh
  24449. * @returns the current mesh
  24450. */
  24451. addChild(mesh: AbstractMesh): AbstractMesh;
  24452. /**
  24453. * Removes the passed mesh from the current mesh children list
  24454. * @param mesh defines the child mesh
  24455. * @returns the current mesh
  24456. */
  24457. removeChild(mesh: AbstractMesh): AbstractMesh;
  24458. /** @hidden */
  24459. private _initFacetData;
  24460. /**
  24461. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24462. * This method can be called within the render loop.
  24463. * 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
  24464. * @returns the current mesh
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24466. */
  24467. updateFacetData(): AbstractMesh;
  24468. /**
  24469. * Returns the facetLocalNormals array.
  24470. * The normals are expressed in the mesh local spac
  24471. * @returns an array of Vector3
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24473. */
  24474. getFacetLocalNormals(): Vector3[];
  24475. /**
  24476. * Returns the facetLocalPositions array.
  24477. * The facet positions are expressed in the mesh local space
  24478. * @returns an array of Vector3
  24479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24480. */
  24481. getFacetLocalPositions(): Vector3[];
  24482. /**
  24483. * Returns the facetLocalPartioning array
  24484. * @returns an array of array of numbers
  24485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24486. */
  24487. getFacetLocalPartitioning(): number[][];
  24488. /**
  24489. * Returns the i-th facet position in the world system.
  24490. * This method allocates a new Vector3 per call
  24491. * @param i defines the facet index
  24492. * @returns a new Vector3
  24493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24494. */
  24495. getFacetPosition(i: number): Vector3;
  24496. /**
  24497. * Sets the reference Vector3 with the i-th facet position in the world system
  24498. * @param i defines the facet index
  24499. * @param ref defines the target vector
  24500. * @returns the current mesh
  24501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24502. */
  24503. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24504. /**
  24505. * Returns the i-th facet normal in the world system.
  24506. * This method allocates a new Vector3 per call
  24507. * @param i defines the facet index
  24508. * @returns a new Vector3
  24509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24510. */
  24511. getFacetNormal(i: number): Vector3;
  24512. /**
  24513. * Sets the reference Vector3 with the i-th facet normal in the world system
  24514. * @param i defines the facet index
  24515. * @param ref defines the target vector
  24516. * @returns the current mesh
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24518. */
  24519. getFacetNormalToRef(i: number, ref: Vector3): this;
  24520. /**
  24521. * 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)
  24522. * @param x defines x coordinate
  24523. * @param y defines y coordinate
  24524. * @param z defines z coordinate
  24525. * @returns the array of facet indexes
  24526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24527. */
  24528. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24529. /**
  24530. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24531. * @param projected sets as the (x,y,z) world projection on the facet
  24532. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  24533. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  24534. * @param x defines x coordinate
  24535. * @param y defines y coordinate
  24536. * @param z defines z coordinate
  24537. * @returns the face index if found (or null instead)
  24538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24539. */
  24540. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24541. /**
  24542. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24543. * @param projected sets as the (x,y,z) local projection on the facet
  24544. * @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
  24545. * @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
  24546. * @param x defines x coordinate
  24547. * @param y defines y coordinate
  24548. * @param z defines z coordinate
  24549. * @returns the face index if found (or null instead)
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24551. */
  24552. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24553. /**
  24554. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24555. * @returns the parameters
  24556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24557. */
  24558. getFacetDataParameters(): any;
  24559. /**
  24560. * Disables the feature FacetData and frees the related memory
  24561. * @returns the current mesh
  24562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24563. */
  24564. disableFacetData(): AbstractMesh;
  24565. /**
  24566. * Updates the AbstractMesh indices array
  24567. * @param indices defines the data source
  24568. * @returns the current mesh
  24569. */
  24570. updateIndices(indices: IndicesArray): AbstractMesh;
  24571. /**
  24572. * Creates new normals data for the mesh
  24573. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24574. * @returns the current mesh
  24575. */
  24576. createNormals(updatable: boolean): AbstractMesh;
  24577. /**
  24578. * Align the mesh with a normal
  24579. * @param normal defines the normal to use
  24580. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24581. * @returns the current mesh
  24582. */
  24583. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24584. /** @hidden */
  24585. _checkOcclusionQuery(): boolean;
  24586. }
  24587. }
  24588. declare module "babylonjs/Actions/actionEvent" {
  24589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24590. import { Nullable } from "babylonjs/types";
  24591. import { Sprite } from "babylonjs/Sprites/sprite";
  24592. import { Scene } from "babylonjs/scene";
  24593. import { Vector2 } from "babylonjs/Maths/math";
  24594. /**
  24595. * Interface used to define ActionEvent
  24596. */
  24597. export interface IActionEvent {
  24598. /** The mesh or sprite that triggered the action */
  24599. source: any;
  24600. /** The X mouse cursor position at the time of the event */
  24601. pointerX: number;
  24602. /** The Y mouse cursor position at the time of the event */
  24603. pointerY: number;
  24604. /** The mesh that is currently pointed at (can be null) */
  24605. meshUnderPointer: Nullable<AbstractMesh>;
  24606. /** the original (browser) event that triggered the ActionEvent */
  24607. sourceEvent?: any;
  24608. /** additional data for the event */
  24609. additionalData?: any;
  24610. }
  24611. /**
  24612. * ActionEvent is the event being sent when an action is triggered.
  24613. */
  24614. export class ActionEvent implements IActionEvent {
  24615. /** The mesh or sprite that triggered the action */
  24616. source: any;
  24617. /** The X mouse cursor position at the time of the event */
  24618. pointerX: number;
  24619. /** The Y mouse cursor position at the time of the event */
  24620. pointerY: number;
  24621. /** The mesh that is currently pointed at (can be null) */
  24622. meshUnderPointer: Nullable<AbstractMesh>;
  24623. /** the original (browser) event that triggered the ActionEvent */
  24624. sourceEvent?: any;
  24625. /** additional data for the event */
  24626. additionalData?: any;
  24627. /**
  24628. * Creates a new ActionEvent
  24629. * @param source The mesh or sprite that triggered the action
  24630. * @param pointerX The X mouse cursor position at the time of the event
  24631. * @param pointerY The Y mouse cursor position at the time of the event
  24632. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24633. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24634. * @param additionalData additional data for the event
  24635. */
  24636. constructor(
  24637. /** The mesh or sprite that triggered the action */
  24638. source: any,
  24639. /** The X mouse cursor position at the time of the event */
  24640. pointerX: number,
  24641. /** The Y mouse cursor position at the time of the event */
  24642. pointerY: number,
  24643. /** The mesh that is currently pointed at (can be null) */
  24644. meshUnderPointer: Nullable<AbstractMesh>,
  24645. /** the original (browser) event that triggered the ActionEvent */
  24646. sourceEvent?: any,
  24647. /** additional data for the event */
  24648. additionalData?: any);
  24649. /**
  24650. * Helper function to auto-create an ActionEvent from a source mesh.
  24651. * @param source The source mesh that triggered the event
  24652. * @param evt The original (browser) event
  24653. * @param additionalData additional data for the event
  24654. * @returns the new ActionEvent
  24655. */
  24656. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24657. /**
  24658. * Helper function to auto-create an ActionEvent from a source sprite
  24659. * @param source The source sprite that triggered the event
  24660. * @param scene Scene associated with the sprite
  24661. * @param evt The original (browser) event
  24662. * @param additionalData additional data for the event
  24663. * @returns the new ActionEvent
  24664. */
  24665. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24666. /**
  24667. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24668. * @param scene the scene where the event occurred
  24669. * @param evt The original (browser) event
  24670. * @returns the new ActionEvent
  24671. */
  24672. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24673. /**
  24674. * Helper function to auto-create an ActionEvent from a primitive
  24675. * @param prim defines the target primitive
  24676. * @param pointerPos defines the pointer position
  24677. * @param evt The original (browser) event
  24678. * @param additionalData additional data for the event
  24679. * @returns the new ActionEvent
  24680. */
  24681. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24682. }
  24683. }
  24684. declare module "babylonjs/Actions/abstractActionManager" {
  24685. import { IDisposable } from "babylonjs/scene";
  24686. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24687. import { IAction } from "babylonjs/Actions/action";
  24688. import { Nullable } from "babylonjs/types";
  24689. /**
  24690. * Abstract class used to decouple action Manager from scene and meshes.
  24691. * Do not instantiate.
  24692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24693. */
  24694. export abstract class AbstractActionManager implements IDisposable {
  24695. /** Gets the list of active triggers */
  24696. static Triggers: {
  24697. [key: string]: number;
  24698. };
  24699. /** Gets the cursor to use when hovering items */
  24700. hoverCursor: string;
  24701. /** Gets the list of actions */
  24702. actions: IAction[];
  24703. /**
  24704. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24705. */
  24706. isRecursive: boolean;
  24707. /**
  24708. * Releases all associated resources
  24709. */
  24710. abstract dispose(): void;
  24711. /**
  24712. * Does this action manager has pointer triggers
  24713. */
  24714. abstract readonly hasPointerTriggers: boolean;
  24715. /**
  24716. * Does this action manager has pick triggers
  24717. */
  24718. abstract readonly hasPickTriggers: boolean;
  24719. /**
  24720. * Process a specific trigger
  24721. * @param trigger defines the trigger to process
  24722. * @param evt defines the event details to be processed
  24723. */
  24724. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24725. /**
  24726. * Does this action manager handles actions of any of the given triggers
  24727. * @param triggers defines the triggers to be tested
  24728. * @return a boolean indicating whether one (or more) of the triggers is handled
  24729. */
  24730. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24731. /**
  24732. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24733. * speed.
  24734. * @param triggerA defines the trigger to be tested
  24735. * @param triggerB defines the trigger to be tested
  24736. * @return a boolean indicating whether one (or more) of the triggers is handled
  24737. */
  24738. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24739. /**
  24740. * Does this action manager handles actions of a given trigger
  24741. * @param trigger defines the trigger to be tested
  24742. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24743. * @return whether the trigger is handled
  24744. */
  24745. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24746. /**
  24747. * Serialize this manager to a JSON object
  24748. * @param name defines the property name to store this manager
  24749. * @returns a JSON representation of this manager
  24750. */
  24751. abstract serialize(name: string): any;
  24752. /**
  24753. * Registers an action to this action manager
  24754. * @param action defines the action to be registered
  24755. * @return the action amended (prepared) after registration
  24756. */
  24757. abstract registerAction(action: IAction): Nullable<IAction>;
  24758. /**
  24759. * Unregisters an action to this action manager
  24760. * @param action defines the action to be unregistered
  24761. * @return a boolean indicating whether the action has been unregistered
  24762. */
  24763. abstract unregisterAction(action: IAction): Boolean;
  24764. /**
  24765. * Does exist one action manager with at least one trigger
  24766. **/
  24767. static readonly HasTriggers: boolean;
  24768. /**
  24769. * Does exist one action manager with at least one pick trigger
  24770. **/
  24771. static readonly HasPickTriggers: boolean;
  24772. /**
  24773. * Does exist one action manager that handles actions of a given trigger
  24774. * @param trigger defines the trigger to be tested
  24775. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24776. **/
  24777. static HasSpecificTrigger(trigger: number): boolean;
  24778. }
  24779. }
  24780. declare module "babylonjs/node" {
  24781. import { Scene } from "babylonjs/scene";
  24782. import { Nullable } from "babylonjs/types";
  24783. import { Matrix } from "babylonjs/Maths/math";
  24784. import { Engine } from "babylonjs/Engines/engine";
  24785. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24786. import { Observable } from "babylonjs/Misc/observable";
  24787. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24788. import { Animatable } from "babylonjs/Animations/animatable";
  24789. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24790. import { Animation } from "babylonjs/Animations/animation";
  24791. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24793. /**
  24794. * Defines how a node can be built from a string name.
  24795. */
  24796. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24797. /**
  24798. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24799. */
  24800. export class Node implements IBehaviorAware<Node> {
  24801. /** @hidden */
  24802. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24803. private static _NodeConstructors;
  24804. /**
  24805. * Add a new node constructor
  24806. * @param type defines the type name of the node to construct
  24807. * @param constructorFunc defines the constructor function
  24808. */
  24809. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24810. /**
  24811. * Returns a node constructor based on type name
  24812. * @param type defines the type name
  24813. * @param name defines the new node name
  24814. * @param scene defines the hosting scene
  24815. * @param options defines optional options to transmit to constructors
  24816. * @returns the new constructor or null
  24817. */
  24818. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24819. /**
  24820. * Gets or sets the name of the node
  24821. */
  24822. name: string;
  24823. /**
  24824. * Gets or sets the id of the node
  24825. */
  24826. id: string;
  24827. /**
  24828. * Gets or sets the unique id of the node
  24829. */
  24830. uniqueId: number;
  24831. /**
  24832. * Gets or sets a string used to store user defined state for the node
  24833. */
  24834. state: string;
  24835. /**
  24836. * Gets or sets an object used to store user defined information for the node
  24837. */
  24838. metadata: any;
  24839. /**
  24840. * For internal use only. Please do not use.
  24841. */
  24842. reservedDataStore: any;
  24843. /**
  24844. * Gets or sets a boolean used to define if the node must be serialized
  24845. */
  24846. doNotSerialize: boolean;
  24847. /** @hidden */
  24848. _isDisposed: boolean;
  24849. /**
  24850. * Gets a list of Animations associated with the node
  24851. */
  24852. animations: import("babylonjs/Animations/animation").Animation[];
  24853. protected _ranges: {
  24854. [name: string]: Nullable<AnimationRange>;
  24855. };
  24856. /**
  24857. * Callback raised when the node is ready to be used
  24858. */
  24859. onReady: (node: Node) => void;
  24860. private _isEnabled;
  24861. private _isParentEnabled;
  24862. private _isReady;
  24863. /** @hidden */
  24864. _currentRenderId: number;
  24865. private _parentRenderId;
  24866. protected _childRenderId: number;
  24867. /** @hidden */
  24868. _waitingParentId: Nullable<string>;
  24869. /** @hidden */
  24870. _scene: Scene;
  24871. /** @hidden */
  24872. _cache: any;
  24873. private _parentNode;
  24874. private _children;
  24875. /** @hidden */
  24876. _worldMatrix: Matrix;
  24877. /** @hidden */
  24878. _worldMatrixDeterminant: number;
  24879. /** @hidden */
  24880. private _sceneRootNodesIndex;
  24881. /**
  24882. * Gets a boolean indicating if the node has been disposed
  24883. * @returns true if the node was disposed
  24884. */
  24885. isDisposed(): boolean;
  24886. /**
  24887. * Gets or sets the parent of the node
  24888. */
  24889. parent: Nullable<Node>;
  24890. private addToSceneRootNodes;
  24891. private removeFromSceneRootNodes;
  24892. private _animationPropertiesOverride;
  24893. /**
  24894. * Gets or sets the animation properties override
  24895. */
  24896. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24897. /**
  24898. * Gets a string idenfifying the name of the class
  24899. * @returns "Node" string
  24900. */
  24901. getClassName(): string;
  24902. /** @hidden */
  24903. readonly _isNode: boolean;
  24904. /**
  24905. * An event triggered when the mesh is disposed
  24906. */
  24907. onDisposeObservable: Observable<Node>;
  24908. private _onDisposeObserver;
  24909. /**
  24910. * Sets a callback that will be raised when the node will be disposed
  24911. */
  24912. onDispose: () => void;
  24913. /**
  24914. * Creates a new Node
  24915. * @param name the name and id to be given to this node
  24916. * @param scene the scene this node will be added to
  24917. * @param addToRootNodes the node will be added to scene.rootNodes
  24918. */
  24919. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24920. /**
  24921. * Gets the scene of the node
  24922. * @returns a scene
  24923. */
  24924. getScene(): Scene;
  24925. /**
  24926. * Gets the engine of the node
  24927. * @returns a Engine
  24928. */
  24929. getEngine(): Engine;
  24930. private _behaviors;
  24931. /**
  24932. * Attach a behavior to the node
  24933. * @see http://doc.babylonjs.com/features/behaviour
  24934. * @param behavior defines the behavior to attach
  24935. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24936. * @returns the current Node
  24937. */
  24938. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24939. /**
  24940. * Remove an attached behavior
  24941. * @see http://doc.babylonjs.com/features/behaviour
  24942. * @param behavior defines the behavior to attach
  24943. * @returns the current Node
  24944. */
  24945. removeBehavior(behavior: Behavior<Node>): Node;
  24946. /**
  24947. * Gets the list of attached behaviors
  24948. * @see http://doc.babylonjs.com/features/behaviour
  24949. */
  24950. readonly behaviors: Behavior<Node>[];
  24951. /**
  24952. * Gets an attached behavior by name
  24953. * @param name defines the name of the behavior to look for
  24954. * @see http://doc.babylonjs.com/features/behaviour
  24955. * @returns null if behavior was not found else the requested behavior
  24956. */
  24957. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24958. /**
  24959. * Returns the latest update of the World matrix
  24960. * @returns a Matrix
  24961. */
  24962. getWorldMatrix(): Matrix;
  24963. /** @hidden */
  24964. _getWorldMatrixDeterminant(): number;
  24965. /**
  24966. * Returns directly the latest state of the mesh World matrix.
  24967. * A Matrix is returned.
  24968. */
  24969. readonly worldMatrixFromCache: Matrix;
  24970. /** @hidden */
  24971. _initCache(): void;
  24972. /** @hidden */
  24973. updateCache(force?: boolean): void;
  24974. /** @hidden */
  24975. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24976. /** @hidden */
  24977. _updateCache(ignoreParentClass?: boolean): void;
  24978. /** @hidden */
  24979. _isSynchronized(): boolean;
  24980. /** @hidden */
  24981. _markSyncedWithParent(): void;
  24982. /** @hidden */
  24983. isSynchronizedWithParent(): boolean;
  24984. /** @hidden */
  24985. isSynchronized(): boolean;
  24986. /**
  24987. * Is this node ready to be used/rendered
  24988. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24989. * @return true if the node is ready
  24990. */
  24991. isReady(completeCheck?: boolean): boolean;
  24992. /**
  24993. * Is this node enabled?
  24994. * 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
  24995. * @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
  24996. * @return whether this node (and its parent) is enabled
  24997. */
  24998. isEnabled(checkAncestors?: boolean): boolean;
  24999. /** @hidden */
  25000. protected _syncParentEnabledState(): void;
  25001. /**
  25002. * Set the enabled state of this node
  25003. * @param value defines the new enabled state
  25004. */
  25005. setEnabled(value: boolean): void;
  25006. /**
  25007. * Is this node a descendant of the given node?
  25008. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25009. * @param ancestor defines the parent node to inspect
  25010. * @returns a boolean indicating if this node is a descendant of the given node
  25011. */
  25012. isDescendantOf(ancestor: Node): boolean;
  25013. /** @hidden */
  25014. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25015. /**
  25016. * Will return all nodes that have this node as ascendant
  25017. * @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
  25018. * @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
  25019. * @return all children nodes of all types
  25020. */
  25021. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25022. /**
  25023. * Get all child-meshes of this node
  25024. * @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)
  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. * @returns an array of AbstractMesh
  25027. */
  25028. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25029. /**
  25030. * Get all direct children of this node
  25031. * @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
  25032. * @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)
  25033. * @returns an array of Node
  25034. */
  25035. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25036. /** @hidden */
  25037. _setReady(state: boolean): void;
  25038. /**
  25039. * Get an animation by name
  25040. * @param name defines the name of the animation to look for
  25041. * @returns null if not found else the requested animation
  25042. */
  25043. getAnimationByName(name: string): Nullable<Animation>;
  25044. /**
  25045. * Creates an animation range for this node
  25046. * @param name defines the name of the range
  25047. * @param from defines the starting key
  25048. * @param to defines the end key
  25049. */
  25050. createAnimationRange(name: string, from: number, to: number): void;
  25051. /**
  25052. * Delete a specific animation range
  25053. * @param name defines the name of the range to delete
  25054. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25055. */
  25056. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25057. /**
  25058. * Get an animation range by name
  25059. * @param name defines the name of the animation range to look for
  25060. * @returns null if not found else the requested animation range
  25061. */
  25062. getAnimationRange(name: string): Nullable<AnimationRange>;
  25063. /**
  25064. * Gets the list of all animation ranges defined on this node
  25065. * @returns an array
  25066. */
  25067. getAnimationRanges(): Nullable<AnimationRange>[];
  25068. /**
  25069. * Will start the animation sequence
  25070. * @param name defines the range frames for animation sequence
  25071. * @param loop defines if the animation should loop (false by default)
  25072. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25073. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25074. * @returns the object created for this animation. If range does not exist, it will return null
  25075. */
  25076. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25077. /**
  25078. * Serialize animation ranges into a JSON compatible object
  25079. * @returns serialization object
  25080. */
  25081. serializeAnimationRanges(): any;
  25082. /**
  25083. * Computes the world matrix of the node
  25084. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25085. * @returns the world matrix
  25086. */
  25087. computeWorldMatrix(force?: boolean): Matrix;
  25088. /**
  25089. * Releases resources associated with this node.
  25090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25092. */
  25093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25094. /**
  25095. * Parse animation range data from a serialization object and store them into a given node
  25096. * @param node defines where to store the animation ranges
  25097. * @param parsedNode defines the serialization object to read data from
  25098. * @param scene defines the hosting scene
  25099. */
  25100. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25101. }
  25102. }
  25103. declare module "babylonjs/Animations/animation" {
  25104. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25105. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25106. import { Nullable } from "babylonjs/types";
  25107. import { Scene } from "babylonjs/scene";
  25108. import { IAnimatable } from "babylonjs/Misc/tools";
  25109. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25110. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25111. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25112. import { Node } from "babylonjs/node";
  25113. import { Animatable } from "babylonjs/Animations/animatable";
  25114. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25115. /**
  25116. * Class used to store any kind of animation
  25117. */
  25118. export class Animation {
  25119. /**Name of the animation */
  25120. name: string;
  25121. /**Property to animate */
  25122. targetProperty: string;
  25123. /**The frames per second of the animation */
  25124. framePerSecond: number;
  25125. /**The data type of the animation */
  25126. dataType: number;
  25127. /**The loop mode of the animation */
  25128. loopMode?: number | undefined;
  25129. /**Specifies if blending should be enabled */
  25130. enableBlending?: boolean | undefined;
  25131. /**
  25132. * Use matrix interpolation instead of using direct key value when animating matrices
  25133. */
  25134. static AllowMatricesInterpolation: boolean;
  25135. /**
  25136. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25137. */
  25138. static AllowMatrixDecomposeForInterpolation: boolean;
  25139. /**
  25140. * Stores the key frames of the animation
  25141. */
  25142. private _keys;
  25143. /**
  25144. * Stores the easing function of the animation
  25145. */
  25146. private _easingFunction;
  25147. /**
  25148. * @hidden Internal use only
  25149. */
  25150. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25151. /**
  25152. * The set of event that will be linked to this animation
  25153. */
  25154. private _events;
  25155. /**
  25156. * Stores an array of target property paths
  25157. */
  25158. targetPropertyPath: string[];
  25159. /**
  25160. * Stores the blending speed of the animation
  25161. */
  25162. blendingSpeed: number;
  25163. /**
  25164. * Stores the animation ranges for the animation
  25165. */
  25166. private _ranges;
  25167. /**
  25168. * @hidden Internal use
  25169. */
  25170. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25171. /**
  25172. * Sets up an animation
  25173. * @param property The property to animate
  25174. * @param animationType The animation type to apply
  25175. * @param framePerSecond The frames per second of the animation
  25176. * @param easingFunction The easing function used in the animation
  25177. * @returns The created animation
  25178. */
  25179. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25180. /**
  25181. * Create and start an animation on a node
  25182. * @param name defines the name of the global animation that will be run on all nodes
  25183. * @param node defines the root node where the animation will take place
  25184. * @param targetProperty defines property to animate
  25185. * @param framePerSecond defines the number of frame per second yo use
  25186. * @param totalFrame defines the number of frames in total
  25187. * @param from defines the initial value
  25188. * @param to defines the final value
  25189. * @param loopMode defines which loop mode you want to use (off by default)
  25190. * @param easingFunction defines the easing function to use (linear by default)
  25191. * @param onAnimationEnd defines the callback to call when animation end
  25192. * @returns the animatable created for this animation
  25193. */
  25194. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25195. /**
  25196. * Create and start an animation on a node and its descendants
  25197. * @param name defines the name of the global animation that will be run on all nodes
  25198. * @param node defines the root node where the animation will take place
  25199. * @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
  25200. * @param targetProperty defines property to animate
  25201. * @param framePerSecond defines the number of frame per second to use
  25202. * @param totalFrame defines the number of frames in total
  25203. * @param from defines the initial value
  25204. * @param to defines the final value
  25205. * @param loopMode defines which loop mode you want to use (off by default)
  25206. * @param easingFunction defines the easing function to use (linear by default)
  25207. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25208. * @returns the list of animatables created for all nodes
  25209. * @example https://www.babylonjs-playground.com/#MH0VLI
  25210. */
  25211. 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[]>;
  25212. /**
  25213. * Creates a new animation, merges it with the existing animations and starts it
  25214. * @param name Name of the animation
  25215. * @param node Node which contains the scene that begins the animations
  25216. * @param targetProperty Specifies which property to animate
  25217. * @param framePerSecond The frames per second of the animation
  25218. * @param totalFrame The total number of frames
  25219. * @param from The frame at the beginning of the animation
  25220. * @param to The frame at the end of the animation
  25221. * @param loopMode Specifies the loop mode of the animation
  25222. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25223. * @param onAnimationEnd Callback to run once the animation is complete
  25224. * @returns Nullable animation
  25225. */
  25226. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25227. /**
  25228. * Transition property of an host to the target Value
  25229. * @param property The property to transition
  25230. * @param targetValue The target Value of the property
  25231. * @param host The object where the property to animate belongs
  25232. * @param scene Scene used to run the animation
  25233. * @param frameRate Framerate (in frame/s) to use
  25234. * @param transition The transition type we want to use
  25235. * @param duration The duration of the animation, in milliseconds
  25236. * @param onAnimationEnd Callback trigger at the end of the animation
  25237. * @returns Nullable animation
  25238. */
  25239. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25240. /**
  25241. * Return the array of runtime animations currently using this animation
  25242. */
  25243. readonly runtimeAnimations: RuntimeAnimation[];
  25244. /**
  25245. * Specifies if any of the runtime animations are currently running
  25246. */
  25247. readonly hasRunningRuntimeAnimations: boolean;
  25248. /**
  25249. * Initializes the animation
  25250. * @param name Name of the animation
  25251. * @param targetProperty Property to animate
  25252. * @param framePerSecond The frames per second of the animation
  25253. * @param dataType The data type of the animation
  25254. * @param loopMode The loop mode of the animation
  25255. * @param enableBlending Specifies if blending should be enabled
  25256. */
  25257. constructor(
  25258. /**Name of the animation */
  25259. name: string,
  25260. /**Property to animate */
  25261. targetProperty: string,
  25262. /**The frames per second of the animation */
  25263. framePerSecond: number,
  25264. /**The data type of the animation */
  25265. dataType: number,
  25266. /**The loop mode of the animation */
  25267. loopMode?: number | undefined,
  25268. /**Specifies if blending should be enabled */
  25269. enableBlending?: boolean | undefined);
  25270. /**
  25271. * Converts the animation to a string
  25272. * @param fullDetails support for multiple levels of logging within scene loading
  25273. * @returns String form of the animation
  25274. */
  25275. toString(fullDetails?: boolean): string;
  25276. /**
  25277. * Add an event to this animation
  25278. * @param event Event to add
  25279. */
  25280. addEvent(event: AnimationEvent): void;
  25281. /**
  25282. * Remove all events found at the given frame
  25283. * @param frame The frame to remove events from
  25284. */
  25285. removeEvents(frame: number): void;
  25286. /**
  25287. * Retrieves all the events from the animation
  25288. * @returns Events from the animation
  25289. */
  25290. getEvents(): AnimationEvent[];
  25291. /**
  25292. * Creates an animation range
  25293. * @param name Name of the animation range
  25294. * @param from Starting frame of the animation range
  25295. * @param to Ending frame of the animation
  25296. */
  25297. createRange(name: string, from: number, to: number): void;
  25298. /**
  25299. * Deletes an animation range by name
  25300. * @param name Name of the animation range to delete
  25301. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25302. */
  25303. deleteRange(name: string, deleteFrames?: boolean): void;
  25304. /**
  25305. * Gets the animation range by name, or null if not defined
  25306. * @param name Name of the animation range
  25307. * @returns Nullable animation range
  25308. */
  25309. getRange(name: string): Nullable<AnimationRange>;
  25310. /**
  25311. * Gets the key frames from the animation
  25312. * @returns The key frames of the animation
  25313. */
  25314. getKeys(): Array<IAnimationKey>;
  25315. /**
  25316. * Gets the highest frame rate of the animation
  25317. * @returns Highest frame rate of the animation
  25318. */
  25319. getHighestFrame(): number;
  25320. /**
  25321. * Gets the easing function of the animation
  25322. * @returns Easing function of the animation
  25323. */
  25324. getEasingFunction(): IEasingFunction;
  25325. /**
  25326. * Sets the easing function of the animation
  25327. * @param easingFunction A custom mathematical formula for animation
  25328. */
  25329. setEasingFunction(easingFunction: EasingFunction): void;
  25330. /**
  25331. * Interpolates a scalar linearly
  25332. * @param startValue Start value of the animation curve
  25333. * @param endValue End value of the animation curve
  25334. * @param gradient Scalar amount to interpolate
  25335. * @returns Interpolated scalar value
  25336. */
  25337. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25338. /**
  25339. * Interpolates a scalar cubically
  25340. * @param startValue Start value of the animation curve
  25341. * @param outTangent End tangent of the animation
  25342. * @param endValue End value of the animation curve
  25343. * @param inTangent Start tangent of the animation curve
  25344. * @param gradient Scalar amount to interpolate
  25345. * @returns Interpolated scalar value
  25346. */
  25347. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25348. /**
  25349. * Interpolates a quaternion using a spherical linear interpolation
  25350. * @param startValue Start value of the animation curve
  25351. * @param endValue End value of the animation curve
  25352. * @param gradient Scalar amount to interpolate
  25353. * @returns Interpolated quaternion value
  25354. */
  25355. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25356. /**
  25357. * Interpolates a quaternion cubically
  25358. * @param startValue Start value of the animation curve
  25359. * @param outTangent End tangent of the animation curve
  25360. * @param endValue End value of the animation curve
  25361. * @param inTangent Start tangent of the animation curve
  25362. * @param gradient Scalar amount to interpolate
  25363. * @returns Interpolated quaternion value
  25364. */
  25365. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25366. /**
  25367. * Interpolates a Vector3 linearl
  25368. * @param startValue Start value of the animation curve
  25369. * @param endValue End value of the animation curve
  25370. * @param gradient Scalar amount to interpolate
  25371. * @returns Interpolated scalar value
  25372. */
  25373. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25374. /**
  25375. * Interpolates a Vector3 cubically
  25376. * @param startValue Start value of the animation curve
  25377. * @param outTangent End tangent of the animation
  25378. * @param endValue End value of the animation curve
  25379. * @param inTangent Start tangent of the animation curve
  25380. * @param gradient Scalar amount to interpolate
  25381. * @returns InterpolatedVector3 value
  25382. */
  25383. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25384. /**
  25385. * Interpolates a Vector2 linearly
  25386. * @param startValue Start value of the animation curve
  25387. * @param endValue End value of the animation curve
  25388. * @param gradient Scalar amount to interpolate
  25389. * @returns Interpolated Vector2 value
  25390. */
  25391. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25392. /**
  25393. * Interpolates a Vector2 cubically
  25394. * @param startValue Start value of the animation curve
  25395. * @param outTangent End tangent of the animation
  25396. * @param endValue End value of the animation curve
  25397. * @param inTangent Start tangent of the animation curve
  25398. * @param gradient Scalar amount to interpolate
  25399. * @returns Interpolated Vector2 value
  25400. */
  25401. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25402. /**
  25403. * Interpolates a size linearly
  25404. * @param startValue Start value of the animation curve
  25405. * @param endValue End value of the animation curve
  25406. * @param gradient Scalar amount to interpolate
  25407. * @returns Interpolated Size value
  25408. */
  25409. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25410. /**
  25411. * Interpolates a Color3 linearly
  25412. * @param startValue Start value of the animation curve
  25413. * @param endValue End value of the animation curve
  25414. * @param gradient Scalar amount to interpolate
  25415. * @returns Interpolated Color3 value
  25416. */
  25417. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25418. /**
  25419. * @hidden Internal use only
  25420. */
  25421. _getKeyValue(value: any): any;
  25422. /**
  25423. * @hidden Internal use only
  25424. */
  25425. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25426. /**
  25427. * Defines the function to use to interpolate matrices
  25428. * @param startValue defines the start matrix
  25429. * @param endValue defines the end matrix
  25430. * @param gradient defines the gradient between both matrices
  25431. * @param result defines an optional target matrix where to store the interpolation
  25432. * @returns the interpolated matrix
  25433. */
  25434. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25435. /**
  25436. * Makes a copy of the animation
  25437. * @returns Cloned animation
  25438. */
  25439. clone(): Animation;
  25440. /**
  25441. * Sets the key frames of the animation
  25442. * @param values The animation key frames to set
  25443. */
  25444. setKeys(values: Array<IAnimationKey>): void;
  25445. /**
  25446. * Serializes the animation to an object
  25447. * @returns Serialized object
  25448. */
  25449. serialize(): any;
  25450. /**
  25451. * Float animation type
  25452. */
  25453. private static _ANIMATIONTYPE_FLOAT;
  25454. /**
  25455. * Vector3 animation type
  25456. */
  25457. private static _ANIMATIONTYPE_VECTOR3;
  25458. /**
  25459. * Quaternion animation type
  25460. */
  25461. private static _ANIMATIONTYPE_QUATERNION;
  25462. /**
  25463. * Matrix animation type
  25464. */
  25465. private static _ANIMATIONTYPE_MATRIX;
  25466. /**
  25467. * Color3 animation type
  25468. */
  25469. private static _ANIMATIONTYPE_COLOR3;
  25470. /**
  25471. * Vector2 animation type
  25472. */
  25473. private static _ANIMATIONTYPE_VECTOR2;
  25474. /**
  25475. * Size animation type
  25476. */
  25477. private static _ANIMATIONTYPE_SIZE;
  25478. /**
  25479. * Relative Loop Mode
  25480. */
  25481. private static _ANIMATIONLOOPMODE_RELATIVE;
  25482. /**
  25483. * Cycle Loop Mode
  25484. */
  25485. private static _ANIMATIONLOOPMODE_CYCLE;
  25486. /**
  25487. * Constant Loop Mode
  25488. */
  25489. private static _ANIMATIONLOOPMODE_CONSTANT;
  25490. /**
  25491. * Get the float animation type
  25492. */
  25493. static readonly ANIMATIONTYPE_FLOAT: number;
  25494. /**
  25495. * Get the Vector3 animation type
  25496. */
  25497. static readonly ANIMATIONTYPE_VECTOR3: number;
  25498. /**
  25499. * Get the Vector2 animation type
  25500. */
  25501. static readonly ANIMATIONTYPE_VECTOR2: number;
  25502. /**
  25503. * Get the Size animation type
  25504. */
  25505. static readonly ANIMATIONTYPE_SIZE: number;
  25506. /**
  25507. * Get the Quaternion animation type
  25508. */
  25509. static readonly ANIMATIONTYPE_QUATERNION: number;
  25510. /**
  25511. * Get the Matrix animation type
  25512. */
  25513. static readonly ANIMATIONTYPE_MATRIX: number;
  25514. /**
  25515. * Get the Color3 animation type
  25516. */
  25517. static readonly ANIMATIONTYPE_COLOR3: number;
  25518. /**
  25519. * Get the Relative Loop Mode
  25520. */
  25521. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25522. /**
  25523. * Get the Cycle Loop Mode
  25524. */
  25525. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25526. /**
  25527. * Get the Constant Loop Mode
  25528. */
  25529. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25530. /** @hidden */
  25531. static _UniversalLerp(left: any, right: any, amount: number): any;
  25532. /**
  25533. * Parses an animation object and creates an animation
  25534. * @param parsedAnimation Parsed animation object
  25535. * @returns Animation object
  25536. */
  25537. static Parse(parsedAnimation: any): Animation;
  25538. /**
  25539. * Appends the serialized animations from the source animations
  25540. * @param source Source containing the animations
  25541. * @param destination Target to store the animations
  25542. */
  25543. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25544. }
  25545. }
  25546. declare module "babylonjs/Materials/Textures/baseTexture" {
  25547. import { Observable } from "babylonjs/Misc/observable";
  25548. import { IAnimatable } from "babylonjs/Misc/tools";
  25549. import { Nullable } from "babylonjs/types";
  25550. import { Scene } from "babylonjs/scene";
  25551. import { Matrix, ISize } from "babylonjs/Maths/math";
  25552. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25554. /**
  25555. * Base class of all the textures in babylon.
  25556. * It groups all the common properties the materials, post process, lights... might need
  25557. * in order to make a correct use of the texture.
  25558. */
  25559. export class BaseTexture implements IAnimatable {
  25560. /**
  25561. * Default anisotropic filtering level for the application.
  25562. * It is set to 4 as a good tradeoff between perf and quality.
  25563. */
  25564. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25565. /**
  25566. * Gets or sets the unique id of the texture
  25567. */
  25568. uniqueId: number;
  25569. /**
  25570. * Define the name of the texture.
  25571. */
  25572. name: string;
  25573. /**
  25574. * Gets or sets an object used to store user defined information.
  25575. */
  25576. metadata: any;
  25577. /**
  25578. * For internal use only. Please do not use.
  25579. */
  25580. reservedDataStore: any;
  25581. private _hasAlpha;
  25582. /**
  25583. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25584. */
  25585. hasAlpha: boolean;
  25586. /**
  25587. * Defines if the alpha value should be determined via the rgb values.
  25588. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25589. */
  25590. getAlphaFromRGB: boolean;
  25591. /**
  25592. * Intensity or strength of the texture.
  25593. * It is commonly used by materials to fine tune the intensity of the texture
  25594. */
  25595. level: number;
  25596. /**
  25597. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25598. * This is part of the texture as textures usually maps to one uv set.
  25599. */
  25600. coordinatesIndex: number;
  25601. private _coordinatesMode;
  25602. /**
  25603. * How a texture is mapped.
  25604. *
  25605. * | Value | Type | Description |
  25606. * | ----- | ----------------------------------- | ----------- |
  25607. * | 0 | EXPLICIT_MODE | |
  25608. * | 1 | SPHERICAL_MODE | |
  25609. * | 2 | PLANAR_MODE | |
  25610. * | 3 | CUBIC_MODE | |
  25611. * | 4 | PROJECTION_MODE | |
  25612. * | 5 | SKYBOX_MODE | |
  25613. * | 6 | INVCUBIC_MODE | |
  25614. * | 7 | EQUIRECTANGULAR_MODE | |
  25615. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25616. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25617. */
  25618. coordinatesMode: number;
  25619. /**
  25620. * | Value | Type | Description |
  25621. * | ----- | ------------------ | ----------- |
  25622. * | 0 | CLAMP_ADDRESSMODE | |
  25623. * | 1 | WRAP_ADDRESSMODE | |
  25624. * | 2 | MIRROR_ADDRESSMODE | |
  25625. */
  25626. wrapU: number;
  25627. /**
  25628. * | Value | Type | Description |
  25629. * | ----- | ------------------ | ----------- |
  25630. * | 0 | CLAMP_ADDRESSMODE | |
  25631. * | 1 | WRAP_ADDRESSMODE | |
  25632. * | 2 | MIRROR_ADDRESSMODE | |
  25633. */
  25634. wrapV: number;
  25635. /**
  25636. * | Value | Type | Description |
  25637. * | ----- | ------------------ | ----------- |
  25638. * | 0 | CLAMP_ADDRESSMODE | |
  25639. * | 1 | WRAP_ADDRESSMODE | |
  25640. * | 2 | MIRROR_ADDRESSMODE | |
  25641. */
  25642. wrapR: number;
  25643. /**
  25644. * With compliant hardware and browser (supporting anisotropic filtering)
  25645. * this defines the level of anisotropic filtering in the texture.
  25646. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25647. */
  25648. anisotropicFilteringLevel: number;
  25649. /**
  25650. * Define if the texture is a cube texture or if false a 2d texture.
  25651. */
  25652. isCube: boolean;
  25653. /**
  25654. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25655. */
  25656. is3D: boolean;
  25657. /**
  25658. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25659. * HDR texture are usually stored in linear space.
  25660. * This only impacts the PBR and Background materials
  25661. */
  25662. gammaSpace: boolean;
  25663. /**
  25664. * Gets whether or not the texture contains RGBD data.
  25665. */
  25666. readonly isRGBD: boolean;
  25667. /**
  25668. * Is Z inverted in the texture (useful in a cube texture).
  25669. */
  25670. invertZ: boolean;
  25671. /**
  25672. * Are mip maps generated for this texture or not.
  25673. */
  25674. readonly noMipmap: boolean;
  25675. /**
  25676. * @hidden
  25677. */
  25678. lodLevelInAlpha: boolean;
  25679. /**
  25680. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25681. */
  25682. lodGenerationOffset: number;
  25683. /**
  25684. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25685. */
  25686. lodGenerationScale: number;
  25687. /**
  25688. * Define if the texture is a render target.
  25689. */
  25690. isRenderTarget: boolean;
  25691. /**
  25692. * Define the unique id of the texture in the scene.
  25693. */
  25694. readonly uid: string;
  25695. /**
  25696. * Return a string representation of the texture.
  25697. * @returns the texture as a string
  25698. */
  25699. toString(): string;
  25700. /**
  25701. * Get the class name of the texture.
  25702. * @returns "BaseTexture"
  25703. */
  25704. getClassName(): string;
  25705. /**
  25706. * Define the list of animation attached to the texture.
  25707. */
  25708. animations: import("babylonjs/Animations/animation").Animation[];
  25709. /**
  25710. * An event triggered when the texture is disposed.
  25711. */
  25712. onDisposeObservable: Observable<BaseTexture>;
  25713. private _onDisposeObserver;
  25714. /**
  25715. * Callback triggered when the texture has been disposed.
  25716. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25717. */
  25718. onDispose: () => void;
  25719. /**
  25720. * Define the current state of the loading sequence when in delayed load mode.
  25721. */
  25722. delayLoadState: number;
  25723. private _scene;
  25724. /** @hidden */
  25725. _texture: Nullable<InternalTexture>;
  25726. private _uid;
  25727. /**
  25728. * Define if the texture is preventinga material to render or not.
  25729. * If not and the texture is not ready, the engine will use a default black texture instead.
  25730. */
  25731. readonly isBlocking: boolean;
  25732. /**
  25733. * Instantiates a new BaseTexture.
  25734. * Base class of all the textures in babylon.
  25735. * It groups all the common properties the materials, post process, lights... might need
  25736. * in order to make a correct use of the texture.
  25737. * @param scene Define the scene the texture blongs to
  25738. */
  25739. constructor(scene: Nullable<Scene>);
  25740. /**
  25741. * Get the scene the texture belongs to.
  25742. * @returns the scene or null if undefined
  25743. */
  25744. getScene(): Nullable<Scene>;
  25745. /**
  25746. * Get the texture transform matrix used to offset tile the texture for istance.
  25747. * @returns the transformation matrix
  25748. */
  25749. getTextureMatrix(): Matrix;
  25750. /**
  25751. * Get the texture reflection matrix used to rotate/transform the reflection.
  25752. * @returns the reflection matrix
  25753. */
  25754. getReflectionTextureMatrix(): Matrix;
  25755. /**
  25756. * Get the underlying lower level texture from Babylon.
  25757. * @returns the insternal texture
  25758. */
  25759. getInternalTexture(): Nullable<InternalTexture>;
  25760. /**
  25761. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25762. * @returns true if ready or not blocking
  25763. */
  25764. isReadyOrNotBlocking(): boolean;
  25765. /**
  25766. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25767. * @returns true if fully ready
  25768. */
  25769. isReady(): boolean;
  25770. private _cachedSize;
  25771. /**
  25772. * Get the size of the texture.
  25773. * @returns the texture size.
  25774. */
  25775. getSize(): ISize;
  25776. /**
  25777. * Get the base size of the texture.
  25778. * It can be different from the size if the texture has been resized for POT for instance
  25779. * @returns the base size
  25780. */
  25781. getBaseSize(): ISize;
  25782. /**
  25783. * Update the sampling mode of the texture.
  25784. * Default is Trilinear mode.
  25785. *
  25786. * | Value | Type | Description |
  25787. * | ----- | ------------------ | ----------- |
  25788. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25789. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25790. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25791. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25792. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25793. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25794. * | 7 | NEAREST_LINEAR | |
  25795. * | 8 | NEAREST_NEAREST | |
  25796. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25797. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25798. * | 11 | LINEAR_LINEAR | |
  25799. * | 12 | LINEAR_NEAREST | |
  25800. *
  25801. * > _mag_: magnification filter (close to the viewer)
  25802. * > _min_: minification filter (far from the viewer)
  25803. * > _mip_: filter used between mip map levels
  25804. *@param samplingMode Define the new sampling mode of the texture
  25805. */
  25806. updateSamplingMode(samplingMode: number): void;
  25807. /**
  25808. * Scales the texture if is `canRescale()`
  25809. * @param ratio the resize factor we want to use to rescale
  25810. */
  25811. scale(ratio: number): void;
  25812. /**
  25813. * Get if the texture can rescale.
  25814. */
  25815. readonly canRescale: boolean;
  25816. /** @hidden */
  25817. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25818. /** @hidden */
  25819. _rebuild(): void;
  25820. /**
  25821. * Triggers the load sequence in delayed load mode.
  25822. */
  25823. delayLoad(): void;
  25824. /**
  25825. * Clones the texture.
  25826. * @returns the cloned texture
  25827. */
  25828. clone(): Nullable<BaseTexture>;
  25829. /**
  25830. * Get the texture underlying type (INT, FLOAT...)
  25831. */
  25832. readonly textureType: number;
  25833. /**
  25834. * Get the texture underlying format (RGB, RGBA...)
  25835. */
  25836. readonly textureFormat: number;
  25837. /**
  25838. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25839. * This will returns an RGBA array buffer containing either in values (0-255) or
  25840. * float values (0-1) depending of the underlying buffer type.
  25841. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25842. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25843. * @param buffer defines a user defined buffer to fill with data (can be null)
  25844. * @returns The Array buffer containing the pixels data.
  25845. */
  25846. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25847. /**
  25848. * Release and destroy the underlying lower level texture aka internalTexture.
  25849. */
  25850. releaseInternalTexture(): void;
  25851. /**
  25852. * Get the polynomial representation of the texture data.
  25853. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25854. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25855. */
  25856. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25857. /** @hidden */
  25858. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25859. /** @hidden */
  25860. readonly _lodTextureMid: Nullable<BaseTexture>;
  25861. /** @hidden */
  25862. readonly _lodTextureLow: Nullable<BaseTexture>;
  25863. /**
  25864. * Dispose the texture and release its associated resources.
  25865. */
  25866. dispose(): void;
  25867. /**
  25868. * Serialize the texture into a JSON representation that can be parsed later on.
  25869. * @returns the JSON representation of the texture
  25870. */
  25871. serialize(): any;
  25872. /**
  25873. * Helper function to be called back once a list of texture contains only ready textures.
  25874. * @param textures Define the list of textures to wait for
  25875. * @param callback Define the callback triggered once the entire list will be ready
  25876. */
  25877. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25878. }
  25879. }
  25880. declare module "babylonjs/Materials/uniformBuffer" {
  25881. import { Nullable, FloatArray } from "babylonjs/types";
  25882. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25883. import { Engine } from "babylonjs/Engines/engine";
  25884. import { Effect } from "babylonjs/Materials/effect";
  25885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25886. /**
  25887. * Uniform buffer objects.
  25888. *
  25889. * Handles blocks of uniform on the GPU.
  25890. *
  25891. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25892. *
  25893. * For more information, please refer to :
  25894. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25895. */
  25896. export class UniformBuffer {
  25897. private _engine;
  25898. private _buffer;
  25899. private _data;
  25900. private _bufferData;
  25901. private _dynamic?;
  25902. private _uniformLocations;
  25903. private _uniformSizes;
  25904. private _uniformLocationPointer;
  25905. private _needSync;
  25906. private _noUBO;
  25907. private _currentEffect;
  25908. private static _MAX_UNIFORM_SIZE;
  25909. private static _tempBuffer;
  25910. /**
  25911. * Lambda to Update a 3x3 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25916. /**
  25917. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25922. /**
  25923. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  25928. /**
  25929. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25934. /**
  25935. * Lambda to Update a vec3 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25940. /**
  25941. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25946. /**
  25947. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  25952. /**
  25953. * Lambda to Update vec3 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. updateVector3: (name: string, vector: Vector3) => void;
  25958. /**
  25959. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  25964. /**
  25965. * Lambda to Update vec3 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25970. /**
  25971. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25972. * This is dynamic to allow compat with webgl 1 and 2.
  25973. * You will need to pass the name of the uniform as well as the value.
  25974. */
  25975. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25976. /**
  25977. * Instantiates a new Uniform buffer objects.
  25978. *
  25979. * Handles blocks of uniform on the GPU.
  25980. *
  25981. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25982. *
  25983. * For more information, please refer to :
  25984. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25985. * @param engine Define the engine the buffer is associated with
  25986. * @param data Define the data contained in the buffer
  25987. * @param dynamic Define if the buffer is updatable
  25988. */
  25989. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25990. /**
  25991. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25992. * or just falling back on setUniformXXX calls.
  25993. */
  25994. readonly useUbo: boolean;
  25995. /**
  25996. * Indicates if the WebGL underlying uniform buffer is in sync
  25997. * with the javascript cache data.
  25998. */
  25999. readonly isSync: boolean;
  26000. /**
  26001. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26002. * Also, a dynamic UniformBuffer will disable cache verification and always
  26003. * update the underlying WebGL uniform buffer to the GPU.
  26004. * @returns if Dynamic, otherwise false
  26005. */
  26006. isDynamic(): boolean;
  26007. /**
  26008. * The data cache on JS side.
  26009. * @returns the underlying data as a float array
  26010. */
  26011. getData(): Float32Array;
  26012. /**
  26013. * The underlying WebGL Uniform buffer.
  26014. * @returns the webgl buffer
  26015. */
  26016. getBuffer(): Nullable<WebGLBuffer>;
  26017. /**
  26018. * std140 layout specifies how to align data within an UBO structure.
  26019. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26020. * for specs.
  26021. */
  26022. private _fillAlignment;
  26023. /**
  26024. * Adds an uniform in the buffer.
  26025. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26026. * for the layout to be correct !
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. * @param size Data size, or data directly.
  26029. */
  26030. addUniform(name: string, size: number | number[]): void;
  26031. /**
  26032. * Adds a Matrix 4x4 to the uniform buffer.
  26033. * @param name Name of the uniform, as used in the uniform block in the shader.
  26034. * @param mat A 4x4 matrix.
  26035. */
  26036. addMatrix(name: string, mat: Matrix): void;
  26037. /**
  26038. * Adds a vec2 to the uniform buffer.
  26039. * @param name Name of the uniform, as used in the uniform block in the shader.
  26040. * @param x Define the x component value of the vec2
  26041. * @param y Define the y component value of the vec2
  26042. */
  26043. addFloat2(name: string, x: number, y: number): void;
  26044. /**
  26045. * Adds a vec3 to the uniform buffer.
  26046. * @param name Name of the uniform, as used in the uniform block in the shader.
  26047. * @param x Define the x component value of the vec3
  26048. * @param y Define the y component value of the vec3
  26049. * @param z Define the z component value of the vec3
  26050. */
  26051. addFloat3(name: string, x: number, y: number, z: number): void;
  26052. /**
  26053. * Adds a vec3 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 vec3 from a Color
  26056. */
  26057. addColor3(name: string, color: Color3): void;
  26058. /**
  26059. * Adds a vec4 to the uniform buffer.
  26060. * @param name Name of the uniform, as used in the uniform block in the shader.
  26061. * @param color Define the rgb components from a Color
  26062. * @param alpha Define the a component of the vec4
  26063. */
  26064. addColor4(name: string, color: Color3, alpha: number): void;
  26065. /**
  26066. * Adds a vec3 to the uniform buffer.
  26067. * @param name Name of the uniform, as used in the uniform block in the shader.
  26068. * @param vector Define the vec3 components from a Vector
  26069. */
  26070. addVector3(name: string, vector: Vector3): void;
  26071. /**
  26072. * Adds a Matrix 3x3 to the uniform buffer.
  26073. * @param name Name of the uniform, as used in the uniform block in the shader.
  26074. */
  26075. addMatrix3x3(name: string): void;
  26076. /**
  26077. * Adds a Matrix 2x2 to the uniform buffer.
  26078. * @param name Name of the uniform, as used in the uniform block in the shader.
  26079. */
  26080. addMatrix2x2(name: string): void;
  26081. /**
  26082. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26083. */
  26084. create(): void;
  26085. /** @hidden */
  26086. _rebuild(): void;
  26087. /**
  26088. * Updates the WebGL Uniform Buffer on the GPU.
  26089. * If the `dynamic` flag is set to true, no cache comparison is done.
  26090. * Otherwise, the buffer will be updated only if the cache differs.
  26091. */
  26092. update(): void;
  26093. /**
  26094. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26095. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26096. * @param data Define the flattened data
  26097. * @param size Define the size of the data.
  26098. */
  26099. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26100. private _updateMatrix3x3ForUniform;
  26101. private _updateMatrix3x3ForEffect;
  26102. private _updateMatrix2x2ForEffect;
  26103. private _updateMatrix2x2ForUniform;
  26104. private _updateFloatForEffect;
  26105. private _updateFloatForUniform;
  26106. private _updateFloat2ForEffect;
  26107. private _updateFloat2ForUniform;
  26108. private _updateFloat3ForEffect;
  26109. private _updateFloat3ForUniform;
  26110. private _updateFloat4ForEffect;
  26111. private _updateFloat4ForUniform;
  26112. private _updateMatrixForEffect;
  26113. private _updateMatrixForUniform;
  26114. private _updateVector3ForEffect;
  26115. private _updateVector3ForUniform;
  26116. private _updateVector4ForEffect;
  26117. private _updateVector4ForUniform;
  26118. private _updateColor3ForEffect;
  26119. private _updateColor3ForUniform;
  26120. private _updateColor4ForEffect;
  26121. private _updateColor4ForUniform;
  26122. /**
  26123. * Sets a sampler uniform on the effect.
  26124. * @param name Define the name of the sampler.
  26125. * @param texture Define the texture to set in the sampler
  26126. */
  26127. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26128. /**
  26129. * Directly updates the value of the uniform in the cache AND on the GPU.
  26130. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26131. * @param data Define the flattened data
  26132. */
  26133. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26134. /**
  26135. * Binds this uniform buffer to an effect.
  26136. * @param effect Define the effect to bind the buffer to
  26137. * @param name Name of the uniform block in the shader.
  26138. */
  26139. bindToEffect(effect: Effect, name: string): void;
  26140. /**
  26141. * Disposes the uniform buffer.
  26142. */
  26143. dispose(): void;
  26144. }
  26145. }
  26146. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26147. import { Nullable } from "babylonjs/types";
  26148. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26149. /**
  26150. * This represents the required contract to create a new type of texture loader.
  26151. */
  26152. export interface IInternalTextureLoader {
  26153. /**
  26154. * Defines wether the loader supports cascade loading the different faces.
  26155. */
  26156. supportCascades: boolean;
  26157. /**
  26158. * This returns if the loader support the current file information.
  26159. * @param extension defines the file extension of the file being loaded
  26160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26161. * @param fallback defines the fallback internal texture if any
  26162. * @param isBase64 defines whether the texture is encoded as a base64
  26163. * @param isBuffer defines whether the texture data are stored as a buffer
  26164. * @returns true if the loader can load the specified file
  26165. */
  26166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26167. /**
  26168. * Transform the url before loading if required.
  26169. * @param rootUrl the url of the texture
  26170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26171. * @returns the transformed texture
  26172. */
  26173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26174. /**
  26175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26176. * @param rootUrl the url of the texture
  26177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26178. * @returns the fallback texture
  26179. */
  26180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26181. /**
  26182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26183. * @param data contains the texture data
  26184. * @param texture defines the BabylonJS internal texture
  26185. * @param createPolynomials will be true if polynomials have been requested
  26186. * @param onLoad defines the callback to trigger once the texture is ready
  26187. * @param onError defines the callback to trigger in case of error
  26188. */
  26189. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26190. /**
  26191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26192. * @param data contains the texture data
  26193. * @param texture defines the BabylonJS internal texture
  26194. * @param callback defines the method to call once ready to upload
  26195. */
  26196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26197. }
  26198. }
  26199. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26200. import { Scene } from "babylonjs/scene";
  26201. import { Engine } from "babylonjs/Engines/engine";
  26202. import { Texture } from "babylonjs/Materials/Textures/texture";
  26203. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26204. /**
  26205. * Creation options of the multi render target texture.
  26206. */
  26207. export interface IMultiRenderTargetOptions {
  26208. /**
  26209. * Define if the texture needs to create mip maps after render.
  26210. */
  26211. generateMipMaps?: boolean;
  26212. /**
  26213. * Define the types of all the draw buffers we want to create
  26214. */
  26215. types?: number[];
  26216. /**
  26217. * Define the sampling modes of all the draw buffers we want to create
  26218. */
  26219. samplingModes?: number[];
  26220. /**
  26221. * Define if a depth buffer is required
  26222. */
  26223. generateDepthBuffer?: boolean;
  26224. /**
  26225. * Define if a stencil buffer is required
  26226. */
  26227. generateStencilBuffer?: boolean;
  26228. /**
  26229. * Define if a depth texture is required instead of a depth buffer
  26230. */
  26231. generateDepthTexture?: boolean;
  26232. /**
  26233. * Define the number of desired draw buffers
  26234. */
  26235. textureCount?: number;
  26236. /**
  26237. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26238. */
  26239. doNotChangeAspectRatio?: boolean;
  26240. /**
  26241. * Define the default type of the buffers we are creating
  26242. */
  26243. defaultType?: number;
  26244. }
  26245. /**
  26246. * A multi render target, like a render target provides the ability to render to a texture.
  26247. * Unlike the render target, it can render to several draw buffers in one draw.
  26248. * This is specially interesting in deferred rendering or for any effects requiring more than
  26249. * just one color from a single pass.
  26250. */
  26251. export class MultiRenderTarget extends RenderTargetTexture {
  26252. private _internalTextures;
  26253. private _textures;
  26254. private _multiRenderTargetOptions;
  26255. /**
  26256. * Get if draw buffers are currently supported by the used hardware and browser.
  26257. */
  26258. readonly isSupported: boolean;
  26259. /**
  26260. * Get the list of textures generated by the multi render target.
  26261. */
  26262. readonly textures: Texture[];
  26263. /**
  26264. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26265. */
  26266. readonly depthTexture: Texture;
  26267. /**
  26268. * Set the wrapping mode on U of all the textures we are rendering to.
  26269. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26270. */
  26271. wrapU: number;
  26272. /**
  26273. * Set the wrapping mode on V of all the textures we are rendering to.
  26274. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26275. */
  26276. wrapV: number;
  26277. /**
  26278. * Instantiate a new multi render target texture.
  26279. * A multi render target, like a render target provides the ability to render to a texture.
  26280. * Unlike the render target, it can render to several draw buffers in one draw.
  26281. * This is specially interesting in deferred rendering or for any effects requiring more than
  26282. * just one color from a single pass.
  26283. * @param name Define the name of the texture
  26284. * @param size Define the size of the buffers to render to
  26285. * @param count Define the number of target we are rendering into
  26286. * @param scene Define the scene the texture belongs to
  26287. * @param options Define the options used to create the multi render target
  26288. */
  26289. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26290. /** @hidden */
  26291. _rebuild(): void;
  26292. private _createInternalTextures;
  26293. private _createTextures;
  26294. /**
  26295. * Define the number of samples used if MSAA is enabled.
  26296. */
  26297. samples: number;
  26298. /**
  26299. * Resize all the textures in the multi render target.
  26300. * Be carrefull as it will recreate all the data in the new texture.
  26301. * @param size Define the new size
  26302. */
  26303. resize(size: any): void;
  26304. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26305. /**
  26306. * Dispose the render targets and their associated resources
  26307. */
  26308. dispose(): void;
  26309. /**
  26310. * Release all the underlying texture used as draw buffers.
  26311. */
  26312. releaseInternalTextures(): void;
  26313. }
  26314. }
  26315. declare module "babylonjs/Audio/analyser" {
  26316. import { Scene } from "babylonjs/scene";
  26317. /**
  26318. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26320. */
  26321. export class Analyser {
  26322. /**
  26323. * Gets or sets the smoothing
  26324. * @ignorenaming
  26325. */
  26326. SMOOTHING: number;
  26327. /**
  26328. * Gets or sets the FFT table size
  26329. * @ignorenaming
  26330. */
  26331. FFT_SIZE: number;
  26332. /**
  26333. * Gets or sets the bar graph amplitude
  26334. * @ignorenaming
  26335. */
  26336. BARGRAPHAMPLITUDE: number;
  26337. /**
  26338. * Gets or sets the position of the debug canvas
  26339. * @ignorenaming
  26340. */
  26341. DEBUGCANVASPOS: {
  26342. x: number;
  26343. y: number;
  26344. };
  26345. /**
  26346. * Gets or sets the debug canvas size
  26347. * @ignorenaming
  26348. */
  26349. DEBUGCANVASSIZE: {
  26350. width: number;
  26351. height: number;
  26352. };
  26353. private _byteFreqs;
  26354. private _byteTime;
  26355. private _floatFreqs;
  26356. private _webAudioAnalyser;
  26357. private _debugCanvas;
  26358. private _debugCanvasContext;
  26359. private _scene;
  26360. private _registerFunc;
  26361. private _audioEngine;
  26362. /**
  26363. * Creates a new analyser
  26364. * @param scene defines hosting scene
  26365. */
  26366. constructor(scene: Scene);
  26367. /**
  26368. * Get the number of data values you will have to play with for the visualization
  26369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26370. * @returns a number
  26371. */
  26372. getFrequencyBinCount(): number;
  26373. /**
  26374. * Gets the current frequency data as a byte array
  26375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26376. * @returns a Uint8Array
  26377. */
  26378. getByteFrequencyData(): Uint8Array;
  26379. /**
  26380. * Gets the current waveform as a byte array
  26381. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26382. * @returns a Uint8Array
  26383. */
  26384. getByteTimeDomainData(): Uint8Array;
  26385. /**
  26386. * Gets the current frequency data as a float array
  26387. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26388. * @returns a Float32Array
  26389. */
  26390. getFloatFrequencyData(): Float32Array;
  26391. /**
  26392. * Renders the debug canvas
  26393. */
  26394. drawDebugCanvas(): void;
  26395. /**
  26396. * Stops rendering the debug canvas and removes it
  26397. */
  26398. stopDebugCanvas(): void;
  26399. /**
  26400. * Connects two audio nodes
  26401. * @param inputAudioNode defines first node to connect
  26402. * @param outputAudioNode defines second node to connect
  26403. */
  26404. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26405. /**
  26406. * Releases all associated resources
  26407. */
  26408. dispose(): void;
  26409. }
  26410. }
  26411. declare module "babylonjs/Audio/audioEngine" {
  26412. import { IDisposable } from "babylonjs/scene";
  26413. import { Analyser } from "babylonjs/Audio/analyser";
  26414. import { Nullable } from "babylonjs/types";
  26415. import { Observable } from "babylonjs/Misc/observable";
  26416. /**
  26417. * This represents an audio engine and it is responsible
  26418. * to play, synchronize and analyse sounds throughout the application.
  26419. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26420. */
  26421. export interface IAudioEngine extends IDisposable {
  26422. /**
  26423. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26424. */
  26425. readonly canUseWebAudio: boolean;
  26426. /**
  26427. * Gets the current AudioContext if available.
  26428. */
  26429. readonly audioContext: Nullable<AudioContext>;
  26430. /**
  26431. * The master gain node defines the global audio volume of your audio engine.
  26432. */
  26433. readonly masterGain: GainNode;
  26434. /**
  26435. * Gets whether or not mp3 are supported by your browser.
  26436. */
  26437. readonly isMP3supported: boolean;
  26438. /**
  26439. * Gets whether or not ogg are supported by your browser.
  26440. */
  26441. readonly isOGGsupported: boolean;
  26442. /**
  26443. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26444. * @ignoreNaming
  26445. */
  26446. WarnedWebAudioUnsupported: boolean;
  26447. /**
  26448. * Defines if the audio engine relies on a custom unlocked button.
  26449. * In this case, the embedded button will not be displayed.
  26450. */
  26451. useCustomUnlockedButton: boolean;
  26452. /**
  26453. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26454. */
  26455. readonly unlocked: boolean;
  26456. /**
  26457. * Event raised when audio has been unlocked on the browser.
  26458. */
  26459. onAudioUnlockedObservable: Observable<AudioEngine>;
  26460. /**
  26461. * Event raised when audio has been locked on the browser.
  26462. */
  26463. onAudioLockedObservable: Observable<AudioEngine>;
  26464. /**
  26465. * Flags the audio engine in Locked state.
  26466. * This happens due to new browser policies preventing audio to autoplay.
  26467. */
  26468. lock(): void;
  26469. /**
  26470. * Unlocks the audio engine once a user action has been done on the dom.
  26471. * This is helpful to resume play once browser policies have been satisfied.
  26472. */
  26473. unlock(): void;
  26474. }
  26475. /**
  26476. * This represents the default audio engine used in babylon.
  26477. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26479. */
  26480. export class AudioEngine implements IAudioEngine {
  26481. private _audioContext;
  26482. private _audioContextInitialized;
  26483. private _muteButton;
  26484. private _hostElement;
  26485. /**
  26486. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26487. */
  26488. canUseWebAudio: boolean;
  26489. /**
  26490. * The master gain node defines the global audio volume of your audio engine.
  26491. */
  26492. masterGain: GainNode;
  26493. /**
  26494. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26495. * @ignoreNaming
  26496. */
  26497. WarnedWebAudioUnsupported: boolean;
  26498. /**
  26499. * Gets whether or not mp3 are supported by your browser.
  26500. */
  26501. isMP3supported: boolean;
  26502. /**
  26503. * Gets whether or not ogg are supported by your browser.
  26504. */
  26505. isOGGsupported: boolean;
  26506. /**
  26507. * Gets whether audio has been unlocked on the device.
  26508. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26509. * a user interaction has happened.
  26510. */
  26511. unlocked: boolean;
  26512. /**
  26513. * Defines if the audio engine relies on a custom unlocked button.
  26514. * In this case, the embedded button will not be displayed.
  26515. */
  26516. useCustomUnlockedButton: boolean;
  26517. /**
  26518. * Event raised when audio has been unlocked on the browser.
  26519. */
  26520. onAudioUnlockedObservable: Observable<AudioEngine>;
  26521. /**
  26522. * Event raised when audio has been locked on the browser.
  26523. */
  26524. onAudioLockedObservable: Observable<AudioEngine>;
  26525. /**
  26526. * Gets the current AudioContext if available.
  26527. */
  26528. readonly audioContext: Nullable<AudioContext>;
  26529. private _connectedAnalyser;
  26530. /**
  26531. * Instantiates a new audio engine.
  26532. *
  26533. * There should be only one per page as some browsers restrict the number
  26534. * of audio contexts you can create.
  26535. * @param hostElement defines the host element where to display the mute icon if necessary
  26536. */
  26537. constructor(hostElement?: Nullable<HTMLElement>);
  26538. /**
  26539. * Flags the audio engine in Locked state.
  26540. * This happens due to new browser policies preventing audio to autoplay.
  26541. */
  26542. lock(): void;
  26543. /**
  26544. * Unlocks the audio engine once a user action has been done on the dom.
  26545. * This is helpful to resume play once browser policies have been satisfied.
  26546. */
  26547. unlock(): void;
  26548. private _resumeAudioContext;
  26549. private _initializeAudioContext;
  26550. private _tryToRun;
  26551. private _triggerRunningState;
  26552. private _triggerSuspendedState;
  26553. private _displayMuteButton;
  26554. private _moveButtonToTopLeft;
  26555. private _onResize;
  26556. private _hideMuteButton;
  26557. /**
  26558. * Destroy and release the resources associated with the audio ccontext.
  26559. */
  26560. dispose(): void;
  26561. /**
  26562. * Gets the global volume sets on the master gain.
  26563. * @returns the global volume if set or -1 otherwise
  26564. */
  26565. getGlobalVolume(): number;
  26566. /**
  26567. * Sets the global volume of your experience (sets on the master gain).
  26568. * @param newVolume Defines the new global volume of the application
  26569. */
  26570. setGlobalVolume(newVolume: number): void;
  26571. /**
  26572. * Connect the audio engine to an audio analyser allowing some amazing
  26573. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26575. * @param analyser The analyser to connect to the engine
  26576. */
  26577. connectToAnalyser(analyser: Analyser): void;
  26578. }
  26579. }
  26580. declare module "babylonjs/Loading/loadingScreen" {
  26581. /**
  26582. * Interface used to present a loading screen while loading a scene
  26583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26584. */
  26585. export interface ILoadingScreen {
  26586. /**
  26587. * Function called to display the loading screen
  26588. */
  26589. displayLoadingUI: () => void;
  26590. /**
  26591. * Function called to hide the loading screen
  26592. */
  26593. hideLoadingUI: () => void;
  26594. /**
  26595. * Gets or sets the color to use for the background
  26596. */
  26597. loadingUIBackgroundColor: string;
  26598. /**
  26599. * Gets or sets the text to display while loading
  26600. */
  26601. loadingUIText: string;
  26602. }
  26603. /**
  26604. * Class used for the default loading screen
  26605. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26606. */
  26607. export class DefaultLoadingScreen implements ILoadingScreen {
  26608. private _renderingCanvas;
  26609. private _loadingText;
  26610. private _loadingDivBackgroundColor;
  26611. private _loadingDiv;
  26612. private _loadingTextDiv;
  26613. /**
  26614. * Creates a new default loading screen
  26615. * @param _renderingCanvas defines the canvas used to render the scene
  26616. * @param _loadingText defines the default text to display
  26617. * @param _loadingDivBackgroundColor defines the default background color
  26618. */
  26619. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26620. /**
  26621. * Function called to display the loading screen
  26622. */
  26623. displayLoadingUI(): void;
  26624. /**
  26625. * Function called to hide the loading screen
  26626. */
  26627. hideLoadingUI(): void;
  26628. /**
  26629. * Gets or sets the text to display while loading
  26630. */
  26631. loadingUIText: string;
  26632. /**
  26633. * Gets or sets the color to use for the background
  26634. */
  26635. loadingUIBackgroundColor: string;
  26636. private _resizeLoadingUI;
  26637. }
  26638. }
  26639. declare module "babylonjs/Materials/Textures/videoTexture" {
  26640. import { Observable } from "babylonjs/Misc/observable";
  26641. import { Nullable } from "babylonjs/types";
  26642. import { Scene } from "babylonjs/scene";
  26643. import { Texture } from "babylonjs/Materials/Textures/texture";
  26644. /**
  26645. * Settings for finer control over video usage
  26646. */
  26647. export interface VideoTextureSettings {
  26648. /**
  26649. * Applies `autoplay` to video, if specified
  26650. */
  26651. autoPlay?: boolean;
  26652. /**
  26653. * Applies `loop` to video, if specified
  26654. */
  26655. loop?: boolean;
  26656. /**
  26657. * Automatically updates internal texture from video at every frame in the render loop
  26658. */
  26659. autoUpdateTexture: boolean;
  26660. /**
  26661. * Image src displayed during the video loading or until the user interacts with the video.
  26662. */
  26663. poster?: string;
  26664. }
  26665. /**
  26666. * If you want to display a video in your scene, this is the special texture for that.
  26667. * This special texture works similar to other textures, with the exception of a few parameters.
  26668. * @see https://doc.babylonjs.com/how_to/video_texture
  26669. */
  26670. export class VideoTexture extends Texture {
  26671. /**
  26672. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26673. */
  26674. readonly autoUpdateTexture: boolean;
  26675. /**
  26676. * The video instance used by the texture internally
  26677. */
  26678. readonly video: HTMLVideoElement;
  26679. private _onUserActionRequestedObservable;
  26680. /**
  26681. * Event triggerd when a dom action is required by the user to play the video.
  26682. * This happens due to recent changes in browser policies preventing video to auto start.
  26683. */
  26684. readonly onUserActionRequestedObservable: Observable<Texture>;
  26685. private _generateMipMaps;
  26686. private _engine;
  26687. private _stillImageCaptured;
  26688. private _displayingPosterTexture;
  26689. private _settings;
  26690. private _createInternalTextureOnEvent;
  26691. /**
  26692. * Creates a video texture.
  26693. * If you want to display a video in your scene, this is the special texture for that.
  26694. * This special texture works similar to other textures, with the exception of a few parameters.
  26695. * @see https://doc.babylonjs.com/how_to/video_texture
  26696. * @param name optional name, will detect from video source, if not defined
  26697. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26698. * @param scene is obviously the current scene.
  26699. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26700. * @param invertY is false by default but can be used to invert video on Y axis
  26701. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26702. * @param settings allows finer control over video usage
  26703. */
  26704. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26705. private _getName;
  26706. private _getVideo;
  26707. private _createInternalTexture;
  26708. private reset;
  26709. /**
  26710. * @hidden Internal method to initiate `update`.
  26711. */
  26712. _rebuild(): void;
  26713. /**
  26714. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26715. */
  26716. update(): void;
  26717. /**
  26718. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26719. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26720. */
  26721. updateTexture(isVisible: boolean): void;
  26722. protected _updateInternalTexture: () => void;
  26723. /**
  26724. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26725. * @param url New url.
  26726. */
  26727. updateURL(url: string): void;
  26728. /**
  26729. * Dispose the texture and release its associated resources.
  26730. */
  26731. dispose(): void;
  26732. /**
  26733. * Creates a video texture straight from a stream.
  26734. * @param scene Define the scene the texture should be created in
  26735. * @param stream Define the stream the texture should be created from
  26736. * @returns The created video texture as a promise
  26737. */
  26738. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26739. /**
  26740. * Creates a video texture straight from your WebCam video feed.
  26741. * @param scene Define the scene the texture should be created in
  26742. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26743. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26744. * @returns The created video texture as a promise
  26745. */
  26746. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26747. minWidth: number;
  26748. maxWidth: number;
  26749. minHeight: number;
  26750. maxHeight: number;
  26751. deviceId: string;
  26752. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26753. /**
  26754. * Creates a video texture straight from your WebCam video feed.
  26755. * @param scene Define the scene the texture should be created in
  26756. * @param onReady Define a callback to triggered once the texture will be ready
  26757. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26758. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26759. */
  26760. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26761. minWidth: number;
  26762. maxWidth: number;
  26763. minHeight: number;
  26764. maxHeight: number;
  26765. deviceId: string;
  26766. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26767. }
  26768. }
  26769. declare module "babylonjs/Engines/engine" {
  26770. import { Observable } from "babylonjs/Misc/observable";
  26771. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26772. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26773. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26774. import { Camera } from "babylonjs/Cameras/camera";
  26775. import { Scene } from "babylonjs/scene";
  26776. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26777. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26778. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26780. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26781. import { Material } from "babylonjs/Materials/material";
  26782. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26783. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26785. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26786. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26787. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26788. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26789. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26790. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26791. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26793. /**
  26794. * Interface for attribute information associated with buffer instanciation
  26795. */
  26796. export class InstancingAttributeInfo {
  26797. /**
  26798. * Index/offset of the attribute in the vertex shader
  26799. */
  26800. index: number;
  26801. /**
  26802. * size of the attribute, 1, 2, 3 or 4
  26803. */
  26804. attributeSize: number;
  26805. /**
  26806. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26807. * default is FLOAT
  26808. */
  26809. attribyteType: number;
  26810. /**
  26811. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26812. */
  26813. normalized: boolean;
  26814. /**
  26815. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26816. */
  26817. offset: number;
  26818. /**
  26819. * Name of the GLSL attribute, for debugging purpose only
  26820. */
  26821. attributeName: string;
  26822. }
  26823. /**
  26824. * Define options used to create a depth texture
  26825. */
  26826. export class DepthTextureCreationOptions {
  26827. /** Specifies whether or not a stencil should be allocated in the texture */
  26828. generateStencil?: boolean;
  26829. /** Specifies whether or not bilinear filtering is enable on the texture */
  26830. bilinearFiltering?: boolean;
  26831. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26832. comparisonFunction?: number;
  26833. /** Specifies if the created texture is a cube texture */
  26834. isCube?: boolean;
  26835. }
  26836. /**
  26837. * Class used to describe the capabilities of the engine relatively to the current browser
  26838. */
  26839. export class EngineCapabilities {
  26840. /** Maximum textures units per fragment shader */
  26841. maxTexturesImageUnits: number;
  26842. /** Maximum texture units per vertex shader */
  26843. maxVertexTextureImageUnits: number;
  26844. /** Maximum textures units in the entire pipeline */
  26845. maxCombinedTexturesImageUnits: number;
  26846. /** Maximum texture size */
  26847. maxTextureSize: number;
  26848. /** Maximum cube texture size */
  26849. maxCubemapTextureSize: number;
  26850. /** Maximum render texture size */
  26851. maxRenderTextureSize: number;
  26852. /** Maximum number of vertex attributes */
  26853. maxVertexAttribs: number;
  26854. /** Maximum number of varyings */
  26855. maxVaryingVectors: number;
  26856. /** Maximum number of uniforms per vertex shader */
  26857. maxVertexUniformVectors: number;
  26858. /** Maximum number of uniforms per fragment shader */
  26859. maxFragmentUniformVectors: number;
  26860. /** Defines if standard derivates (dx/dy) are supported */
  26861. standardDerivatives: boolean;
  26862. /** Defines if s3tc texture compression is supported */
  26863. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26864. /** Defines if pvrtc texture compression is supported */
  26865. pvrtc: any;
  26866. /** Defines if etc1 texture compression is supported */
  26867. etc1: any;
  26868. /** Defines if etc2 texture compression is supported */
  26869. etc2: any;
  26870. /** Defines if astc texture compression is supported */
  26871. astc: any;
  26872. /** Defines if float textures are supported */
  26873. textureFloat: boolean;
  26874. /** Defines if vertex array objects are supported */
  26875. vertexArrayObject: boolean;
  26876. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26877. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26878. /** Gets the maximum level of anisotropy supported */
  26879. maxAnisotropy: number;
  26880. /** Defines if instancing is supported */
  26881. instancedArrays: boolean;
  26882. /** Defines if 32 bits indices are supported */
  26883. uintIndices: boolean;
  26884. /** Defines if high precision shaders are supported */
  26885. highPrecisionShaderSupported: boolean;
  26886. /** Defines if depth reading in the fragment shader is supported */
  26887. fragmentDepthSupported: boolean;
  26888. /** Defines if float texture linear filtering is supported*/
  26889. textureFloatLinearFiltering: boolean;
  26890. /** Defines if rendering to float textures is supported */
  26891. textureFloatRender: boolean;
  26892. /** Defines if half float textures are supported*/
  26893. textureHalfFloat: boolean;
  26894. /** Defines if half float texture linear filtering is supported*/
  26895. textureHalfFloatLinearFiltering: boolean;
  26896. /** Defines if rendering to half float textures is supported */
  26897. textureHalfFloatRender: boolean;
  26898. /** Defines if textureLOD shader command is supported */
  26899. textureLOD: boolean;
  26900. /** Defines if draw buffers extension is supported */
  26901. drawBuffersExtension: boolean;
  26902. /** Defines if depth textures are supported */
  26903. depthTextureExtension: boolean;
  26904. /** Defines if float color buffer are supported */
  26905. colorBufferFloat: boolean;
  26906. /** Gets disjoint timer query extension (null if not supported) */
  26907. timerQuery: EXT_disjoint_timer_query;
  26908. /** Defines if timestamp can be used with timer query */
  26909. canUseTimestampForTimerQuery: boolean;
  26910. /** Function used to let the system compiles shaders in background */
  26911. parallelShaderCompile: {
  26912. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26913. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26914. COMPLETION_STATUS_KHR: number;
  26915. };
  26916. }
  26917. /** Interface defining initialization parameters for Engine class */
  26918. export interface EngineOptions extends WebGLContextAttributes {
  26919. /**
  26920. * Defines if the engine should no exceed a specified device ratio
  26921. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26922. */
  26923. limitDeviceRatio?: number;
  26924. /**
  26925. * Defines if webvr should be enabled automatically
  26926. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26927. */
  26928. autoEnableWebVR?: boolean;
  26929. /**
  26930. * Defines if webgl2 should be turned off even if supported
  26931. * @see http://doc.babylonjs.com/features/webgl2
  26932. */
  26933. disableWebGL2Support?: boolean;
  26934. /**
  26935. * Defines if webaudio should be initialized as well
  26936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26937. */
  26938. audioEngine?: boolean;
  26939. /**
  26940. * Defines if animations should run using a deterministic lock step
  26941. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26942. */
  26943. deterministicLockstep?: boolean;
  26944. /** Defines the maximum steps to use with deterministic lock step mode */
  26945. lockstepMaxSteps?: number;
  26946. /**
  26947. * Defines that engine should ignore context lost events
  26948. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26949. */
  26950. doNotHandleContextLost?: boolean;
  26951. /**
  26952. * Defines that engine should ignore modifying touch action attribute and style
  26953. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26954. */
  26955. doNotHandleTouchAction?: boolean;
  26956. }
  26957. /**
  26958. * Defines the interface used by display changed events
  26959. */
  26960. export interface IDisplayChangedEventArgs {
  26961. /** Gets the vrDisplay object (if any) */
  26962. vrDisplay: Nullable<any>;
  26963. /** Gets a boolean indicating if webVR is supported */
  26964. vrSupported: boolean;
  26965. }
  26966. /**
  26967. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26968. */
  26969. export class Engine {
  26970. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26971. static ExceptionList: ({
  26972. key: string;
  26973. capture: string;
  26974. captureConstraint: number;
  26975. targets: string[];
  26976. } | {
  26977. key: string;
  26978. capture: null;
  26979. captureConstraint: null;
  26980. targets: string[];
  26981. })[];
  26982. /** Gets the list of created engines */
  26983. static readonly Instances: Engine[];
  26984. /**
  26985. * Gets the latest created engine
  26986. */
  26987. static readonly LastCreatedEngine: Nullable<Engine>;
  26988. /**
  26989. * Gets the latest created scene
  26990. */
  26991. static readonly LastCreatedScene: Nullable<Scene>;
  26992. /**
  26993. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26994. * @param flag defines which part of the materials must be marked as dirty
  26995. * @param predicate defines a predicate used to filter which materials should be affected
  26996. */
  26997. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26998. /**
  26999. * Hidden
  27000. */
  27001. static _TextureLoaders: IInternalTextureLoader[];
  27002. /** Defines that alpha blending is disabled */
  27003. static readonly ALPHA_DISABLE: number;
  27004. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27005. static readonly ALPHA_ADD: number;
  27006. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27007. static readonly ALPHA_COMBINE: number;
  27008. /** Defines that alpha blending to DEST - SRC * DEST */
  27009. static readonly ALPHA_SUBTRACT: number;
  27010. /** Defines that alpha blending to SRC * DEST */
  27011. static readonly ALPHA_MULTIPLY: number;
  27012. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27013. static readonly ALPHA_MAXIMIZED: number;
  27014. /** Defines that alpha blending to SRC + DEST */
  27015. static readonly ALPHA_ONEONE: number;
  27016. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27017. static readonly ALPHA_PREMULTIPLIED: number;
  27018. /**
  27019. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27020. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27021. */
  27022. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27023. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27024. static readonly ALPHA_INTERPOLATE: number;
  27025. /**
  27026. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27027. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27028. */
  27029. static readonly ALPHA_SCREENMODE: number;
  27030. /** Defines that the ressource is not delayed*/
  27031. static readonly DELAYLOADSTATE_NONE: number;
  27032. /** Defines that the ressource was successfully delay loaded */
  27033. static readonly DELAYLOADSTATE_LOADED: number;
  27034. /** Defines that the ressource is currently delay loading */
  27035. static readonly DELAYLOADSTATE_LOADING: number;
  27036. /** Defines that the ressource is delayed and has not started loading */
  27037. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27038. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27039. static readonly NEVER: number;
  27040. /** 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 */
  27041. static readonly ALWAYS: number;
  27042. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27043. static readonly LESS: number;
  27044. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27045. static readonly EQUAL: number;
  27046. /** 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 */
  27047. static readonly LEQUAL: number;
  27048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27049. static readonly GREATER: number;
  27050. /** 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 */
  27051. static readonly GEQUAL: number;
  27052. /** 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 */
  27053. static readonly NOTEQUAL: number;
  27054. /** Passed to stencilOperation to specify that stencil value must be kept */
  27055. static readonly KEEP: number;
  27056. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27057. static readonly REPLACE: number;
  27058. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27059. static readonly INCR: number;
  27060. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27061. static readonly DECR: number;
  27062. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27063. static readonly INVERT: number;
  27064. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27065. static readonly INCR_WRAP: number;
  27066. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27067. static readonly DECR_WRAP: number;
  27068. /** Texture is not repeating outside of 0..1 UVs */
  27069. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27070. /** Texture is repeating outside of 0..1 UVs */
  27071. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27072. /** Texture is repeating and mirrored */
  27073. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27074. /** ALPHA */
  27075. static readonly TEXTUREFORMAT_ALPHA: number;
  27076. /** LUMINANCE */
  27077. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27078. /** LUMINANCE_ALPHA */
  27079. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27080. /** RGB */
  27081. static readonly TEXTUREFORMAT_RGB: number;
  27082. /** RGBA */
  27083. static readonly TEXTUREFORMAT_RGBA: number;
  27084. /** RED */
  27085. static readonly TEXTUREFORMAT_RED: number;
  27086. /** RED (2nd reference) */
  27087. static readonly TEXTUREFORMAT_R: number;
  27088. /** RG */
  27089. static readonly TEXTUREFORMAT_RG: number;
  27090. /** RED_INTEGER */
  27091. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27092. /** RED_INTEGER (2nd reference) */
  27093. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27094. /** RG_INTEGER */
  27095. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27096. /** RGB_INTEGER */
  27097. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27098. /** RGBA_INTEGER */
  27099. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27100. /** UNSIGNED_BYTE */
  27101. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27102. /** UNSIGNED_BYTE (2nd reference) */
  27103. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27104. /** FLOAT */
  27105. static readonly TEXTURETYPE_FLOAT: number;
  27106. /** HALF_FLOAT */
  27107. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27108. /** BYTE */
  27109. static readonly TEXTURETYPE_BYTE: number;
  27110. /** SHORT */
  27111. static readonly TEXTURETYPE_SHORT: number;
  27112. /** UNSIGNED_SHORT */
  27113. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27114. /** INT */
  27115. static readonly TEXTURETYPE_INT: number;
  27116. /** UNSIGNED_INT */
  27117. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27118. /** UNSIGNED_SHORT_4_4_4_4 */
  27119. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27120. /** UNSIGNED_SHORT_5_5_5_1 */
  27121. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27122. /** UNSIGNED_SHORT_5_6_5 */
  27123. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27124. /** UNSIGNED_INT_2_10_10_10_REV */
  27125. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27126. /** UNSIGNED_INT_24_8 */
  27127. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27128. /** UNSIGNED_INT_10F_11F_11F_REV */
  27129. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27130. /** UNSIGNED_INT_5_9_9_9_REV */
  27131. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27132. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27133. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27134. /** nearest is mag = nearest and min = nearest and mip = linear */
  27135. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27136. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27137. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27138. /** Trilinear is mag = linear and min = linear and mip = linear */
  27139. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27140. /** nearest is mag = nearest and min = nearest and mip = linear */
  27141. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27142. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27143. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27144. /** Trilinear is mag = linear and min = linear and mip = linear */
  27145. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27146. /** mag = nearest and min = nearest and mip = nearest */
  27147. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27148. /** mag = nearest and min = linear and mip = nearest */
  27149. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27150. /** mag = nearest and min = linear and mip = linear */
  27151. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27152. /** mag = nearest and min = linear and mip = none */
  27153. static readonly TEXTURE_NEAREST_LINEAR: number;
  27154. /** mag = nearest and min = nearest and mip = none */
  27155. static readonly TEXTURE_NEAREST_NEAREST: number;
  27156. /** mag = linear and min = nearest and mip = nearest */
  27157. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27158. /** mag = linear and min = nearest and mip = linear */
  27159. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27160. /** mag = linear and min = linear and mip = none */
  27161. static readonly TEXTURE_LINEAR_LINEAR: number;
  27162. /** mag = linear and min = nearest and mip = none */
  27163. static readonly TEXTURE_LINEAR_NEAREST: number;
  27164. /** Explicit coordinates mode */
  27165. static readonly TEXTURE_EXPLICIT_MODE: number;
  27166. /** Spherical coordinates mode */
  27167. static readonly TEXTURE_SPHERICAL_MODE: number;
  27168. /** Planar coordinates mode */
  27169. static readonly TEXTURE_PLANAR_MODE: number;
  27170. /** Cubic coordinates mode */
  27171. static readonly TEXTURE_CUBIC_MODE: number;
  27172. /** Projection coordinates mode */
  27173. static readonly TEXTURE_PROJECTION_MODE: number;
  27174. /** Skybox coordinates mode */
  27175. static readonly TEXTURE_SKYBOX_MODE: number;
  27176. /** Inverse Cubic coordinates mode */
  27177. static readonly TEXTURE_INVCUBIC_MODE: number;
  27178. /** Equirectangular coordinates mode */
  27179. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27180. /** Equirectangular Fixed coordinates mode */
  27181. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27182. /** Equirectangular Fixed Mirrored coordinates mode */
  27183. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27184. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27185. static readonly SCALEMODE_FLOOR: number;
  27186. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27187. static readonly SCALEMODE_NEAREST: number;
  27188. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27189. static readonly SCALEMODE_CEILING: number;
  27190. /**
  27191. * Returns the current version of the framework
  27192. */
  27193. static readonly Version: string;
  27194. /**
  27195. * Returns a string describing the current engine
  27196. */
  27197. readonly description: string;
  27198. /**
  27199. * Gets or sets the epsilon value used by collision engine
  27200. */
  27201. static CollisionsEpsilon: number;
  27202. /**
  27203. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27204. */
  27205. static ShadersRepository: string;
  27206. /**
  27207. * Method called to create the default loading screen.
  27208. * This can be overriden in your own app.
  27209. * @param canvas The rendering canvas element
  27210. * @returns The loading screen
  27211. */
  27212. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27213. /**
  27214. * Method called to create the default rescale post process on each engine.
  27215. */
  27216. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27217. /**
  27218. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27219. */
  27220. forcePOTTextures: boolean;
  27221. /**
  27222. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27223. */
  27224. isFullscreen: boolean;
  27225. /**
  27226. * Gets a boolean indicating if the pointer is currently locked
  27227. */
  27228. isPointerLock: boolean;
  27229. /**
  27230. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27231. */
  27232. cullBackFaces: boolean;
  27233. /**
  27234. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27235. */
  27236. renderEvenInBackground: boolean;
  27237. /**
  27238. * Gets or sets a boolean indicating that cache can be kept between frames
  27239. */
  27240. preventCacheWipeBetweenFrames: boolean;
  27241. /**
  27242. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27243. **/
  27244. enableOfflineSupport: boolean;
  27245. /**
  27246. * 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)
  27247. **/
  27248. disableManifestCheck: boolean;
  27249. /**
  27250. * Gets the list of created scenes
  27251. */
  27252. scenes: Scene[];
  27253. /**
  27254. * Event raised when a new scene is created
  27255. */
  27256. onNewSceneAddedObservable: Observable<Scene>;
  27257. /**
  27258. * Gets the list of created postprocesses
  27259. */
  27260. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27261. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27262. validateShaderPrograms: boolean;
  27263. /**
  27264. * Observable event triggered each time the rendering canvas is resized
  27265. */
  27266. onResizeObservable: Observable<Engine>;
  27267. /**
  27268. * Observable event triggered each time the canvas loses focus
  27269. */
  27270. onCanvasBlurObservable: Observable<Engine>;
  27271. /**
  27272. * Observable event triggered each time the canvas gains focus
  27273. */
  27274. onCanvasFocusObservable: Observable<Engine>;
  27275. /**
  27276. * Observable event triggered each time the canvas receives pointerout event
  27277. */
  27278. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27279. /**
  27280. * Observable event triggered before each texture is initialized
  27281. */
  27282. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27283. private _vrDisplay;
  27284. private _vrSupported;
  27285. private _oldSize;
  27286. private _oldHardwareScaleFactor;
  27287. private _vrExclusivePointerMode;
  27288. private _webVRInitPromise;
  27289. /**
  27290. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27291. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27292. */
  27293. readonly isInVRExclusivePointerMode: boolean;
  27294. /**
  27295. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27296. */
  27297. disableUniformBuffers: boolean;
  27298. /** @hidden */
  27299. _uniformBuffers: UniformBuffer[];
  27300. /**
  27301. * Gets a boolean indicating that the engine supports uniform buffers
  27302. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27303. */
  27304. readonly supportsUniformBuffers: boolean;
  27305. /**
  27306. * Observable raised when the engine begins a new frame
  27307. */
  27308. onBeginFrameObservable: Observable<Engine>;
  27309. /**
  27310. * If set, will be used to request the next animation frame for the render loop
  27311. */
  27312. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27313. /**
  27314. * Observable raised when the engine ends the current frame
  27315. */
  27316. onEndFrameObservable: Observable<Engine>;
  27317. /**
  27318. * Observable raised when the engine is about to compile a shader
  27319. */
  27320. onBeforeShaderCompilationObservable: Observable<Engine>;
  27321. /**
  27322. * Observable raised when the engine has jsut compiled a shader
  27323. */
  27324. onAfterShaderCompilationObservable: Observable<Engine>;
  27325. /** @hidden */
  27326. _gl: WebGLRenderingContext;
  27327. private _renderingCanvas;
  27328. private _windowIsBackground;
  27329. private _webGLVersion;
  27330. /**
  27331. * Gets a boolean indicating that only power of 2 textures are supported
  27332. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27333. */
  27334. readonly needPOTTextures: boolean;
  27335. /** @hidden */
  27336. _badOS: boolean;
  27337. /** @hidden */
  27338. _badDesktopOS: boolean;
  27339. /**
  27340. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27341. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27342. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27343. */
  27344. disableTextureBindingOptimization: boolean;
  27345. /**
  27346. * Gets the audio engine
  27347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27348. * @ignorenaming
  27349. */
  27350. static audioEngine: IAudioEngine;
  27351. /**
  27352. * Default AudioEngine factory responsible of creating the Audio Engine.
  27353. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27354. */
  27355. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27356. /**
  27357. * Default offline support factory responsible of creating a tool used to store data locally.
  27358. * By default, this will create a Database object if the workload has been embedded.
  27359. */
  27360. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27361. private _onFocus;
  27362. private _onBlur;
  27363. private _onCanvasPointerOut;
  27364. private _onCanvasBlur;
  27365. private _onCanvasFocus;
  27366. private _onFullscreenChange;
  27367. private _onPointerLockChange;
  27368. private _onVRDisplayPointerRestricted;
  27369. private _onVRDisplayPointerUnrestricted;
  27370. private _onVrDisplayConnect;
  27371. private _onVrDisplayDisconnect;
  27372. private _onVrDisplayPresentChange;
  27373. /**
  27374. * Observable signaled when VR display mode changes
  27375. */
  27376. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27377. /**
  27378. * Observable signaled when VR request present is complete
  27379. */
  27380. onVRRequestPresentComplete: Observable<boolean>;
  27381. /**
  27382. * Observable signaled when VR request present starts
  27383. */
  27384. onVRRequestPresentStart: Observable<Engine>;
  27385. private _hardwareScalingLevel;
  27386. /** @hidden */
  27387. protected _caps: EngineCapabilities;
  27388. private _pointerLockRequested;
  27389. private _isStencilEnable;
  27390. private _colorWrite;
  27391. private _loadingScreen;
  27392. /** @hidden */
  27393. _drawCalls: PerfCounter;
  27394. /** @hidden */
  27395. _textureCollisions: PerfCounter;
  27396. private _glVersion;
  27397. private _glRenderer;
  27398. private _glVendor;
  27399. private _videoTextureSupported;
  27400. private _renderingQueueLaunched;
  27401. private _activeRenderLoops;
  27402. private _deterministicLockstep;
  27403. private _lockstepMaxSteps;
  27404. /**
  27405. * Observable signaled when a context lost event is raised
  27406. */
  27407. onContextLostObservable: Observable<Engine>;
  27408. /**
  27409. * Observable signaled when a context restored event is raised
  27410. */
  27411. onContextRestoredObservable: Observable<Engine>;
  27412. private _onContextLost;
  27413. private _onContextRestored;
  27414. private _contextWasLost;
  27415. private _doNotHandleContextLost;
  27416. /**
  27417. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27419. */
  27420. doNotHandleContextLost: boolean;
  27421. private _performanceMonitor;
  27422. private _fps;
  27423. private _deltaTime;
  27424. /**
  27425. * Turn this value on if you want to pause FPS computation when in background
  27426. */
  27427. disablePerformanceMonitorInBackground: boolean;
  27428. /**
  27429. * Gets the performance monitor attached to this engine
  27430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27431. */
  27432. readonly performanceMonitor: PerformanceMonitor;
  27433. /** @hidden */
  27434. protected _depthCullingState: _DepthCullingState;
  27435. /** @hidden */
  27436. protected _stencilState: _StencilState;
  27437. /** @hidden */
  27438. protected _alphaState: _AlphaState;
  27439. /** @hidden */
  27440. protected _alphaMode: number;
  27441. protected _internalTexturesCache: InternalTexture[];
  27442. /** @hidden */
  27443. protected _activeChannel: number;
  27444. private _currentTextureChannel;
  27445. /** @hidden */
  27446. protected _boundTexturesCache: {
  27447. [key: string]: Nullable<InternalTexture>;
  27448. };
  27449. /** @hidden */
  27450. protected _currentEffect: Nullable<Effect>;
  27451. /** @hidden */
  27452. protected _currentProgram: Nullable<WebGLProgram>;
  27453. private _compiledEffects;
  27454. private _vertexAttribArraysEnabled;
  27455. /** @hidden */
  27456. protected _cachedViewport: Nullable<Viewport>;
  27457. private _cachedVertexArrayObject;
  27458. /** @hidden */
  27459. protected _cachedVertexBuffers: any;
  27460. /** @hidden */
  27461. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27462. /** @hidden */
  27463. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27464. /** @hidden */
  27465. protected _currentRenderTarget: Nullable<InternalTexture>;
  27466. private _uintIndicesCurrentlySet;
  27467. private _currentBoundBuffer;
  27468. /** @hidden */
  27469. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27470. private _currentBufferPointers;
  27471. private _currentInstanceLocations;
  27472. private _currentInstanceBuffers;
  27473. private _textureUnits;
  27474. private _firstBoundInternalTextureTracker;
  27475. private _lastBoundInternalTextureTracker;
  27476. private _workingCanvas;
  27477. private _workingContext;
  27478. private _rescalePostProcess;
  27479. private _dummyFramebuffer;
  27480. private _externalData;
  27481. private _bindedRenderFunction;
  27482. private _vaoRecordInProgress;
  27483. private _mustWipeVertexAttributes;
  27484. private _emptyTexture;
  27485. private _emptyCubeTexture;
  27486. private _emptyTexture3D;
  27487. /** @hidden */
  27488. _frameHandler: number;
  27489. private _nextFreeTextureSlots;
  27490. private _maxSimultaneousTextures;
  27491. private _activeRequests;
  27492. private _texturesSupported;
  27493. private _textureFormatInUse;
  27494. /**
  27495. * Gets the list of texture formats supported
  27496. */
  27497. readonly texturesSupported: Array<string>;
  27498. /**
  27499. * Gets the list of texture formats in use
  27500. */
  27501. readonly textureFormatInUse: Nullable<string>;
  27502. /**
  27503. * Gets the current viewport
  27504. */
  27505. readonly currentViewport: Nullable<Viewport>;
  27506. /**
  27507. * Gets the default empty texture
  27508. */
  27509. readonly emptyTexture: InternalTexture;
  27510. /**
  27511. * Gets the default empty 3D texture
  27512. */
  27513. readonly emptyTexture3D: InternalTexture;
  27514. /**
  27515. * Gets the default empty cube texture
  27516. */
  27517. readonly emptyCubeTexture: InternalTexture;
  27518. /**
  27519. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27520. */
  27521. readonly premultipliedAlpha: boolean;
  27522. /**
  27523. * Creates a new engine
  27524. * @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
  27525. * @param antialias defines enable antialiasing (default: false)
  27526. * @param options defines further options to be sent to the getContext() function
  27527. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27528. */
  27529. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27530. private _disableTouchAction;
  27531. private _rebuildInternalTextures;
  27532. private _rebuildEffects;
  27533. /**
  27534. * Gets a boolean indicating if all created effects are ready
  27535. * @returns true if all effects are ready
  27536. */
  27537. areAllEffectsReady(): boolean;
  27538. private _rebuildBuffers;
  27539. private _initGLContext;
  27540. /**
  27541. * Gets version of the current webGL context
  27542. */
  27543. readonly webGLVersion: number;
  27544. /**
  27545. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27546. */
  27547. readonly isStencilEnable: boolean;
  27548. private _prepareWorkingCanvas;
  27549. /**
  27550. * Reset the texture cache to empty state
  27551. */
  27552. resetTextureCache(): void;
  27553. /**
  27554. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27556. * @returns true if engine is in deterministic lock step mode
  27557. */
  27558. isDeterministicLockStep(): boolean;
  27559. /**
  27560. * Gets the max steps when engine is running in deterministic lock step
  27561. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27562. * @returns the max steps
  27563. */
  27564. getLockstepMaxSteps(): number;
  27565. /**
  27566. * Gets an object containing information about the current webGL context
  27567. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27568. */
  27569. getGlInfo(): {
  27570. vendor: string;
  27571. renderer: string;
  27572. version: string;
  27573. };
  27574. /**
  27575. * Gets current aspect ratio
  27576. * @param camera defines the camera to use to get the aspect ratio
  27577. * @param useScreen defines if screen size must be used (or the current render target if any)
  27578. * @returns a number defining the aspect ratio
  27579. */
  27580. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27581. /**
  27582. * Gets current screen aspect ratio
  27583. * @returns a number defining the aspect ratio
  27584. */
  27585. getScreenAspectRatio(): number;
  27586. /**
  27587. * Gets the current render width
  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 width
  27590. */
  27591. getRenderWidth(useScreen?: boolean): number;
  27592. /**
  27593. * Gets the current render height
  27594. * @param useScreen defines if screen size must be used (or the current render target if any)
  27595. * @returns a number defining the current render height
  27596. */
  27597. getRenderHeight(useScreen?: boolean): number;
  27598. /**
  27599. * Gets the HTML canvas attached with the current webGL context
  27600. * @returns a HTML canvas
  27601. */
  27602. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27603. /**
  27604. * Gets the client rect of the HTML canvas attached with the current webGL context
  27605. * @returns a client rectanglee
  27606. */
  27607. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27608. /**
  27609. * Defines the hardware scaling level.
  27610. * By default the hardware scaling level is computed from the window device ratio.
  27611. * 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.
  27612. * @param level defines the level to use
  27613. */
  27614. setHardwareScalingLevel(level: number): void;
  27615. /**
  27616. * Gets the current hardware scaling level.
  27617. * By default the hardware scaling level is computed from the window device ratio.
  27618. * 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.
  27619. * @returns a number indicating the current hardware scaling level
  27620. */
  27621. getHardwareScalingLevel(): number;
  27622. /**
  27623. * Gets the list of loaded textures
  27624. * @returns an array containing all loaded textures
  27625. */
  27626. getLoadedTexturesCache(): InternalTexture[];
  27627. /**
  27628. * Gets the object containing all engine capabilities
  27629. * @returns the EngineCapabilities object
  27630. */
  27631. getCaps(): EngineCapabilities;
  27632. /**
  27633. * Gets the current depth function
  27634. * @returns a number defining the depth function
  27635. */
  27636. getDepthFunction(): Nullable<number>;
  27637. /**
  27638. * Sets the current depth function
  27639. * @param depthFunc defines the function to use
  27640. */
  27641. setDepthFunction(depthFunc: number): void;
  27642. /**
  27643. * Sets the current depth function to GREATER
  27644. */
  27645. setDepthFunctionToGreater(): void;
  27646. /**
  27647. * Sets the current depth function to GEQUAL
  27648. */
  27649. setDepthFunctionToGreaterOrEqual(): void;
  27650. /**
  27651. * Sets the current depth function to LESS
  27652. */
  27653. setDepthFunctionToLess(): void;
  27654. /**
  27655. * Sets the current depth function to LEQUAL
  27656. */
  27657. setDepthFunctionToLessOrEqual(): void;
  27658. /**
  27659. * Gets a boolean indicating if stencil buffer is enabled
  27660. * @returns the current stencil buffer state
  27661. */
  27662. getStencilBuffer(): boolean;
  27663. /**
  27664. * Enable or disable the stencil buffer
  27665. * @param enable defines if the stencil buffer must be enabled or disabled
  27666. */
  27667. setStencilBuffer(enable: boolean): void;
  27668. /**
  27669. * Gets the current stencil mask
  27670. * @returns a number defining the new stencil mask to use
  27671. */
  27672. getStencilMask(): number;
  27673. /**
  27674. * Sets the current stencil mask
  27675. * @param mask defines the new stencil mask to use
  27676. */
  27677. setStencilMask(mask: number): void;
  27678. /**
  27679. * Gets the current stencil function
  27680. * @returns a number defining the stencil function to use
  27681. */
  27682. getStencilFunction(): number;
  27683. /**
  27684. * Gets the current stencil reference value
  27685. * @returns a number defining the stencil reference value to use
  27686. */
  27687. getStencilFunctionReference(): number;
  27688. /**
  27689. * Gets the current stencil mask
  27690. * @returns a number defining the stencil mask to use
  27691. */
  27692. getStencilFunctionMask(): number;
  27693. /**
  27694. * Sets the current stencil function
  27695. * @param stencilFunc defines the new stencil function to use
  27696. */
  27697. setStencilFunction(stencilFunc: number): void;
  27698. /**
  27699. * Sets the current stencil reference
  27700. * @param reference defines the new stencil reference to use
  27701. */
  27702. setStencilFunctionReference(reference: number): void;
  27703. /**
  27704. * Sets the current stencil mask
  27705. * @param mask defines the new stencil mask to use
  27706. */
  27707. setStencilFunctionMask(mask: number): void;
  27708. /**
  27709. * Gets the current stencil operation when stencil fails
  27710. * @returns a number defining stencil operation to use when stencil fails
  27711. */
  27712. getStencilOperationFail(): number;
  27713. /**
  27714. * Gets the current stencil operation when depth fails
  27715. * @returns a number defining stencil operation to use when depth fails
  27716. */
  27717. getStencilOperationDepthFail(): number;
  27718. /**
  27719. * Gets the current stencil operation when stencil passes
  27720. * @returns a number defining stencil operation to use when stencil passes
  27721. */
  27722. getStencilOperationPass(): number;
  27723. /**
  27724. * Sets the stencil operation to use when stencil fails
  27725. * @param operation defines the stencil operation to use when stencil fails
  27726. */
  27727. setStencilOperationFail(operation: number): void;
  27728. /**
  27729. * Sets the stencil operation to use when depth fails
  27730. * @param operation defines the stencil operation to use when depth fails
  27731. */
  27732. setStencilOperationDepthFail(operation: number): void;
  27733. /**
  27734. * Sets the stencil operation to use when stencil passes
  27735. * @param operation defines the stencil operation to use when stencil passes
  27736. */
  27737. setStencilOperationPass(operation: number): void;
  27738. /**
  27739. * Sets a boolean indicating if the dithering state is enabled or disabled
  27740. * @param value defines the dithering state
  27741. */
  27742. setDitheringState(value: boolean): void;
  27743. /**
  27744. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27745. * @param value defines the rasterizer state
  27746. */
  27747. setRasterizerState(value: boolean): void;
  27748. /**
  27749. * stop executing a render loop function and remove it from the execution array
  27750. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27751. */
  27752. stopRenderLoop(renderFunction?: () => void): void;
  27753. /** @hidden */
  27754. _renderLoop(): void;
  27755. /**
  27756. * Register and execute a render loop. The engine can have more than one render function
  27757. * @param renderFunction defines the function to continuously execute
  27758. */
  27759. runRenderLoop(renderFunction: () => void): void;
  27760. /**
  27761. * Toggle full screen mode
  27762. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27763. */
  27764. switchFullscreen(requestPointerLock: boolean): void;
  27765. /**
  27766. * Enters full screen mode
  27767. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27768. */
  27769. enterFullscreen(requestPointerLock: boolean): void;
  27770. /**
  27771. * Exits full screen mode
  27772. */
  27773. exitFullscreen(): void;
  27774. /**
  27775. * Clear the current render buffer or the current render target (if any is set up)
  27776. * @param color defines the color to use
  27777. * @param backBuffer defines if the back buffer must be cleared
  27778. * @param depth defines if the depth buffer must be cleared
  27779. * @param stencil defines if the stencil buffer must be cleared
  27780. */
  27781. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27782. /**
  27783. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27784. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27785. * @param y defines the y-coordinate of the corner of the clear rectangle
  27786. * @param width defines the width of the clear rectangle
  27787. * @param height defines the height of the clear rectangle
  27788. * @param clearColor defines the clear color
  27789. */
  27790. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27791. /**
  27792. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27793. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27794. * @param y defines the y-coordinate of the corner of the clear rectangle
  27795. * @param width defines the width of the clear rectangle
  27796. * @param height defines the height of the clear rectangle
  27797. */
  27798. enableScissor(x: number, y: number, width: number, height: number): void;
  27799. /**
  27800. * Disable previously set scissor test rectangle
  27801. */
  27802. disableScissor(): void;
  27803. private _viewportCached;
  27804. /** @hidden */
  27805. _viewport(x: number, y: number, width: number, height: number): void;
  27806. /**
  27807. * Set the WebGL's viewport
  27808. * @param viewport defines the viewport element to be used
  27809. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27810. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27811. */
  27812. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27813. /**
  27814. * Directly set the WebGL Viewport
  27815. * @param x defines the x coordinate of the viewport (in screen space)
  27816. * @param y defines the y coordinate of the viewport (in screen space)
  27817. * @param width defines the width of the viewport (in screen space)
  27818. * @param height defines the height of the viewport (in screen space)
  27819. * @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
  27820. */
  27821. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27822. /**
  27823. * Begin a new frame
  27824. */
  27825. beginFrame(): void;
  27826. /**
  27827. * Enf the current frame
  27828. */
  27829. endFrame(): void;
  27830. /**
  27831. * Resize the view according to the canvas' size
  27832. */
  27833. resize(): void;
  27834. /**
  27835. * Force a specific size of the canvas
  27836. * @param width defines the new canvas' width
  27837. * @param height defines the new canvas' height
  27838. */
  27839. setSize(width: number, height: number): void;
  27840. /**
  27841. * Gets a boolean indicating if a webVR device was detected
  27842. * @returns true if a webVR device was detected
  27843. */
  27844. isVRDevicePresent(): boolean;
  27845. /**
  27846. * Gets the current webVR device
  27847. * @returns the current webVR device (or null)
  27848. */
  27849. getVRDevice(): any;
  27850. /**
  27851. * Initializes a webVR display and starts listening to display change events
  27852. * The onVRDisplayChangedObservable will be notified upon these changes
  27853. * @returns The onVRDisplayChangedObservable
  27854. */
  27855. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27856. /**
  27857. * Initializes a webVR display and starts listening to display change events
  27858. * The onVRDisplayChangedObservable will be notified upon these changes
  27859. * @returns A promise containing a VRDisplay and if vr is supported
  27860. */
  27861. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27862. /**
  27863. * Call this function to switch to 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. enableVR(): void;
  27868. /**
  27869. * Call this function to leave webVR mode
  27870. * Will do nothing if webVR is not supported or if there is no webVR device
  27871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27872. */
  27873. disableVR(): void;
  27874. private _onVRFullScreenTriggered;
  27875. private _getVRDisplaysAsync;
  27876. /**
  27877. * Binds the frame buffer to the specified texture.
  27878. * @param texture The texture to render to or null for the default canvas
  27879. * @param faceIndex The face of the texture to render to in case of cube texture
  27880. * @param requiredWidth The width of the target to render to
  27881. * @param requiredHeight The height of the target to render to
  27882. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27883. * @param depthStencilTexture The depth stencil texture to use to render
  27884. * @param lodLevel defines le lod level to bind to the frame buffer
  27885. */
  27886. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27887. private bindUnboundFramebuffer;
  27888. /**
  27889. * Unbind the current render target texture from the webGL context
  27890. * @param texture defines the render target texture to unbind
  27891. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27892. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27893. */
  27894. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27895. /**
  27896. * Unbind a list of render target textures from the webGL context
  27897. * This is used only when drawBuffer extension or webGL2 are active
  27898. * @param textures defines the render target textures to unbind
  27899. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27900. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27901. */
  27902. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27903. /**
  27904. * Force the mipmap generation for the given render target texture
  27905. * @param texture defines the render target texture to use
  27906. */
  27907. generateMipMapsForCubemap(texture: InternalTexture): void;
  27908. /**
  27909. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27910. */
  27911. flushFramebuffer(): void;
  27912. /**
  27913. * Unbind the current render target and bind the default framebuffer
  27914. */
  27915. restoreDefaultFramebuffer(): void;
  27916. /**
  27917. * Create an uniform buffer
  27918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27919. * @param elements defines the content of the uniform buffer
  27920. * @returns the webGL uniform buffer
  27921. */
  27922. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27923. /**
  27924. * Create a dynamic uniform buffer
  27925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27926. * @param elements defines the content of the uniform buffer
  27927. * @returns the webGL uniform buffer
  27928. */
  27929. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27930. /**
  27931. * Update an existing uniform buffer
  27932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27933. * @param uniformBuffer defines the target uniform buffer
  27934. * @param elements defines the content to update
  27935. * @param offset defines the offset in the uniform buffer where update should start
  27936. * @param count defines the size of the data to update
  27937. */
  27938. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27939. private _resetVertexBufferBinding;
  27940. /**
  27941. * Creates a vertex buffer
  27942. * @param data the data for the vertex buffer
  27943. * @returns the new WebGL static buffer
  27944. */
  27945. createVertexBuffer(data: DataArray): WebGLBuffer;
  27946. /**
  27947. * Creates a dynamic vertex buffer
  27948. * @param data the data for the dynamic vertex buffer
  27949. * @returns the new WebGL dynamic buffer
  27950. */
  27951. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27952. /**
  27953. * Update a dynamic index buffer
  27954. * @param indexBuffer defines the target index buffer
  27955. * @param indices defines the data to update
  27956. * @param offset defines the offset in the target index buffer where update should start
  27957. */
  27958. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27959. /**
  27960. * Updates a dynamic vertex buffer.
  27961. * @param vertexBuffer the vertex buffer to update
  27962. * @param data the data used to update the vertex buffer
  27963. * @param byteOffset the byte offset of the data
  27964. * @param byteLength the byte length of the data
  27965. */
  27966. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27967. private _resetIndexBufferBinding;
  27968. /**
  27969. * Creates a new index buffer
  27970. * @param indices defines the content of the index buffer
  27971. * @param updatable defines if the index buffer must be updatable
  27972. * @returns a new webGL buffer
  27973. */
  27974. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27975. /**
  27976. * Bind a webGL buffer to the webGL context
  27977. * @param buffer defines the buffer to bind
  27978. */
  27979. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27980. /**
  27981. * Bind an uniform buffer to the current webGL context
  27982. * @param buffer defines the buffer to bind
  27983. */
  27984. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27985. /**
  27986. * Bind a buffer to the current webGL context at a given location
  27987. * @param buffer defines the buffer to bind
  27988. * @param location defines the index where to bind the buffer
  27989. */
  27990. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27991. /**
  27992. * Bind a specific block at a given index in a specific shader program
  27993. * @param shaderProgram defines the shader program
  27994. * @param blockName defines the block name
  27995. * @param index defines the index where to bind the block
  27996. */
  27997. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27998. private bindIndexBuffer;
  27999. private bindBuffer;
  28000. /**
  28001. * update the bound buffer with the given data
  28002. * @param data defines the data to update
  28003. */
  28004. updateArrayBuffer(data: Float32Array): void;
  28005. private _vertexAttribPointer;
  28006. private _bindIndexBufferWithCache;
  28007. private _bindVertexBuffersAttributes;
  28008. /**
  28009. * Records a vertex array object
  28010. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28011. * @param vertexBuffers defines the list of vertex buffers to store
  28012. * @param indexBuffer defines the index buffer to store
  28013. * @param effect defines the effect to store
  28014. * @returns the new vertex array object
  28015. */
  28016. recordVertexArrayObject(vertexBuffers: {
  28017. [key: string]: VertexBuffer;
  28018. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28019. /**
  28020. * Bind a specific vertex array object
  28021. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28022. * @param vertexArrayObject defines the vertex array object to bind
  28023. * @param indexBuffer defines the index buffer to bind
  28024. */
  28025. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28026. /**
  28027. * Bind webGl buffers directly to the webGL context
  28028. * @param vertexBuffer defines the vertex buffer to bind
  28029. * @param indexBuffer defines the index buffer to bind
  28030. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28031. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28032. * @param effect defines the effect associated with the vertex buffer
  28033. */
  28034. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28035. private _unbindVertexArrayObject;
  28036. /**
  28037. * Bind a list of vertex buffers to the webGL context
  28038. * @param vertexBuffers defines the list of vertex buffers to bind
  28039. * @param indexBuffer defines the index buffer to bind
  28040. * @param effect defines the effect associated with the vertex buffers
  28041. */
  28042. bindBuffers(vertexBuffers: {
  28043. [key: string]: Nullable<VertexBuffer>;
  28044. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28045. /**
  28046. * Unbind all instance attributes
  28047. */
  28048. unbindInstanceAttributes(): void;
  28049. /**
  28050. * Release and free the memory of a vertex array object
  28051. * @param vao defines the vertex array object to delete
  28052. */
  28053. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28054. /** @hidden */
  28055. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28056. /**
  28057. * Creates a webGL buffer to use with instanciation
  28058. * @param capacity defines the size of the buffer
  28059. * @returns the webGL buffer
  28060. */
  28061. createInstancesBuffer(capacity: number): WebGLBuffer;
  28062. /**
  28063. * Delete a webGL buffer used with instanciation
  28064. * @param buffer defines the webGL buffer to delete
  28065. */
  28066. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28067. /**
  28068. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28069. * @param instancesBuffer defines the webGL buffer to update and bind
  28070. * @param data defines the data to store in the buffer
  28071. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28072. */
  28073. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28074. /**
  28075. * Apply all cached states (depth, culling, stencil and alpha)
  28076. */
  28077. applyStates(): void;
  28078. /**
  28079. * Send a draw order
  28080. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28081. * @param indexStart defines the starting index
  28082. * @param indexCount defines the number of index to draw
  28083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28084. */
  28085. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28086. /**
  28087. * Draw a list of points
  28088. * @param verticesStart defines the index of first vertex to draw
  28089. * @param verticesCount defines the count of vertices to draw
  28090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28091. */
  28092. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28093. /**
  28094. * Draw a list of unindexed primitives
  28095. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28096. * @param verticesStart defines the index of first vertex to draw
  28097. * @param verticesCount defines the count of vertices to draw
  28098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28099. */
  28100. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28101. /**
  28102. * Draw a list of indexed primitives
  28103. * @param fillMode defines the primitive to use
  28104. * @param indexStart defines the starting index
  28105. * @param indexCount defines the number of index to draw
  28106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28107. */
  28108. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28109. /**
  28110. * Draw a list of unindexed primitives
  28111. * @param fillMode defines the primitive to use
  28112. * @param verticesStart defines the index of first vertex to draw
  28113. * @param verticesCount defines the count of vertices to draw
  28114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28115. */
  28116. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28117. private _drawMode;
  28118. /** @hidden */
  28119. _releaseEffect(effect: Effect): void;
  28120. /** @hidden */
  28121. _deleteProgram(program: WebGLProgram): void;
  28122. /**
  28123. * Create a new effect (used to store vertex/fragment shaders)
  28124. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28125. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28126. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28127. * @param samplers defines an array of string used to represent textures
  28128. * @param defines defines the string containing the defines to use to compile the shaders
  28129. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28130. * @param onCompiled defines a function to call when the effect creation is successful
  28131. * @param onError defines a function to call when the effect creation has failed
  28132. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28133. * @returns the new Effect
  28134. */
  28135. 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;
  28136. private _compileShader;
  28137. private _compileRawShader;
  28138. /**
  28139. * Directly creates a webGL program
  28140. * @param vertexCode defines the vertex shader code to use
  28141. * @param fragmentCode defines the fragment shader code to use
  28142. * @param context defines the webGL context to use (if not set, the current one will be used)
  28143. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28144. * @returns the new webGL program
  28145. */
  28146. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28147. /**
  28148. * Creates a webGL program
  28149. * @param vertexCode defines the vertex shader code to use
  28150. * @param fragmentCode defines the fragment shader code to use
  28151. * @param defines defines the string containing the defines to use to compile the shaders
  28152. * @param context defines the webGL context to use (if not set, the current one will be used)
  28153. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28154. * @returns the new webGL program
  28155. */
  28156. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28157. private _createShaderProgram;
  28158. private _finalizeProgram;
  28159. /** @hidden */
  28160. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28161. /** @hidden */
  28162. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28163. /**
  28164. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28165. * @param shaderProgram defines the webGL program to use
  28166. * @param uniformsNames defines the list of uniform names
  28167. * @returns an array of webGL uniform locations
  28168. */
  28169. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28170. /**
  28171. * Gets the lsit of active attributes for a given webGL program
  28172. * @param shaderProgram defines the webGL program to use
  28173. * @param attributesNames defines the list of attribute names to get
  28174. * @returns an array of indices indicating the offset of each attribute
  28175. */
  28176. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28177. /**
  28178. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28179. * @param effect defines the effect to activate
  28180. */
  28181. enableEffect(effect: Nullable<Effect>): void;
  28182. /**
  28183. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28188. /**
  28189. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28194. /**
  28195. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28200. /**
  28201. * Set the value of an uniform to an array of int32 (stored as vec4)
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param array defines the array of int32 to store
  28204. */
  28205. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28206. /**
  28207. * Set the value of an uniform to an array of float32
  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. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28212. /**
  28213. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28218. /**
  28219. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28224. /**
  28225. * Set the value of an uniform to an array of float32 (stored as vec4)
  28226. * @param uniform defines the webGL uniform location where to store the value
  28227. * @param array defines the array of float32 to store
  28228. */
  28229. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28230. /**
  28231. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28236. /**
  28237. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28242. /**
  28243. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28248. /**
  28249. * Set the value of an uniform to an array of number (stored as vec4)
  28250. * @param uniform defines the webGL uniform location where to store the value
  28251. * @param array defines the array of number to store
  28252. */
  28253. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28254. /**
  28255. * Set the value of an uniform to an array of float32 (stored as matrices)
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param matrices defines the array of float32 to store
  28258. */
  28259. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28260. /**
  28261. * Set the value of an uniform to a matrix
  28262. * @param uniform defines the webGL uniform location where to store the value
  28263. * @param matrix defines the matrix to store
  28264. */
  28265. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28266. /**
  28267. * Set the value of an uniform to a matrix (3x3)
  28268. * @param uniform defines the webGL uniform location where to store the value
  28269. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28270. */
  28271. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28272. /**
  28273. * Set the value of an uniform to a matrix (2x2)
  28274. * @param uniform defines the webGL uniform location where to store the value
  28275. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28276. */
  28277. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28278. /**
  28279. * Set the value of an uniform to a number (int)
  28280. * @param uniform defines the webGL uniform location where to store the value
  28281. * @param value defines the int number to store
  28282. */
  28283. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28284. /**
  28285. * Set the value of an uniform to a number (float)
  28286. * @param uniform defines the webGL uniform location where to store the value
  28287. * @param value defines the float number to store
  28288. */
  28289. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28290. /**
  28291. * Set the value of an uniform to a vec2
  28292. * @param uniform defines the webGL uniform location where to store the value
  28293. * @param x defines the 1st component of the value
  28294. * @param y defines the 2nd component of the value
  28295. */
  28296. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28297. /**
  28298. * Set the value of an uniform to a vec3
  28299. * @param uniform defines the webGL uniform location where to store the value
  28300. * @param x defines the 1st component of the value
  28301. * @param y defines the 2nd component of the value
  28302. * @param z defines the 3rd component of the value
  28303. */
  28304. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28305. /**
  28306. * Set the value of an uniform to a boolean
  28307. * @param uniform defines the webGL uniform location where to store the value
  28308. * @param bool defines the boolean to store
  28309. */
  28310. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28311. /**
  28312. * Set the value of an uniform to a vec4
  28313. * @param uniform defines the webGL uniform location where to store the value
  28314. * @param x defines the 1st component of the value
  28315. * @param y defines the 2nd component of the value
  28316. * @param z defines the 3rd component of the value
  28317. * @param w defines the 4th component of the value
  28318. */
  28319. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28320. /**
  28321. * Set the value of an uniform to a Color3
  28322. * @param uniform defines the webGL uniform location where to store the value
  28323. * @param color3 defines the color to store
  28324. */
  28325. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28326. /**
  28327. * Set the value of an uniform to a Color3 and an alpha value
  28328. * @param uniform defines the webGL uniform location where to store the value
  28329. * @param color3 defines the color to store
  28330. * @param alpha defines the alpha component to store
  28331. */
  28332. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28333. /**
  28334. * Sets a Color4 on a uniform variable
  28335. * @param uniform defines the uniform location
  28336. * @param color4 defines the value to be set
  28337. */
  28338. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28339. /**
  28340. * Set various states to the webGL context
  28341. * @param culling defines backface culling state
  28342. * @param zOffset defines the value to apply to zOffset (0 by default)
  28343. * @param force defines if states must be applied even if cache is up to date
  28344. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28345. */
  28346. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28347. /**
  28348. * Set the z offset to apply to current rendering
  28349. * @param value defines the offset to apply
  28350. */
  28351. setZOffset(value: number): void;
  28352. /**
  28353. * Gets the current value of the zOffset
  28354. * @returns the current zOffset state
  28355. */
  28356. getZOffset(): number;
  28357. /**
  28358. * Enable or disable depth buffering
  28359. * @param enable defines the state to set
  28360. */
  28361. setDepthBuffer(enable: boolean): void;
  28362. /**
  28363. * Gets a boolean indicating if depth writing is enabled
  28364. * @returns the current depth writing state
  28365. */
  28366. getDepthWrite(): boolean;
  28367. /**
  28368. * Enable or disable depth writing
  28369. * @param enable defines the state to set
  28370. */
  28371. setDepthWrite(enable: boolean): void;
  28372. /**
  28373. * Enable or disable color writing
  28374. * @param enable defines the state to set
  28375. */
  28376. setColorWrite(enable: boolean): void;
  28377. /**
  28378. * Gets a boolean indicating if color writing is enabled
  28379. * @returns the current color writing state
  28380. */
  28381. getColorWrite(): boolean;
  28382. /**
  28383. * Sets alpha constants used by some alpha blending modes
  28384. * @param r defines the red component
  28385. * @param g defines the green component
  28386. * @param b defines the blue component
  28387. * @param a defines the alpha component
  28388. */
  28389. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28390. /**
  28391. * Sets the current alpha mode
  28392. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28393. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28394. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28395. */
  28396. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28397. /**
  28398. * Gets the current alpha mode
  28399. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28400. * @returns the current alpha mode
  28401. */
  28402. getAlphaMode(): number;
  28403. /**
  28404. * Clears the list of texture accessible through engine.
  28405. * This can help preventing texture load conflict due to name collision.
  28406. */
  28407. clearInternalTexturesCache(): void;
  28408. /**
  28409. * Force the entire cache to be cleared
  28410. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28411. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28412. */
  28413. wipeCaches(bruteForce?: boolean): void;
  28414. /**
  28415. * Set the compressed texture format to use, based on the formats you have, and the formats
  28416. * supported by the hardware / browser.
  28417. *
  28418. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28419. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28420. * to API arguments needed to compressed textures. This puts the burden on the container
  28421. * generator to house the arcane code for determining these for current & future formats.
  28422. *
  28423. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28424. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28425. *
  28426. * Note: The result of this call is not taken into account when a texture is base64.
  28427. *
  28428. * @param formatsAvailable defines the list of those format families you have created
  28429. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28430. *
  28431. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28432. * @returns The extension selected.
  28433. */
  28434. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28435. private _getSamplingParameters;
  28436. private _partialLoadImg;
  28437. private _cascadeLoadImgs;
  28438. /** @hidden */
  28439. _createTexture(): WebGLTexture;
  28440. /**
  28441. * Usually called from Texture.ts.
  28442. * Passed information to create a WebGLTexture
  28443. * @param urlArg defines a value which contains one of the following:
  28444. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28445. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28446. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28447. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28448. * @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)
  28449. * @param scene needed for loading to the correct scene
  28450. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28451. * @param onLoad optional callback to be called upon successful completion
  28452. * @param onError optional callback to be called upon failure
  28453. * @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
  28454. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28455. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28456. * @param forcedExtension defines the extension to use to pick the right loader
  28457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28458. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28459. */
  28460. 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;
  28461. private _rescaleTexture;
  28462. /**
  28463. * Update a raw texture
  28464. * @param texture defines the texture to update
  28465. * @param data defines the data to store in the texture
  28466. * @param format defines the format of the data
  28467. * @param invertY defines if data must be stored with Y axis inverted
  28468. * @param compression defines the compression used (null by default)
  28469. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28470. */
  28471. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28472. /**
  28473. * Creates a raw texture
  28474. * @param data defines the data to store in the texture
  28475. * @param width defines the width of the texture
  28476. * @param height defines the height of the texture
  28477. * @param format defines the format of the data
  28478. * @param generateMipMaps defines if the engine should generate the mip levels
  28479. * @param invertY defines if data must be stored with Y axis inverted
  28480. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28481. * @param compression defines the compression used (null by default)
  28482. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28483. * @returns the raw texture inside an InternalTexture
  28484. */
  28485. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28486. private _unpackFlipYCached;
  28487. /**
  28488. * In case you are sharing the context with other applications, it might
  28489. * be interested to not cache the unpack flip y state to ensure a consistent
  28490. * value would be set.
  28491. */
  28492. enableUnpackFlipYCached: boolean;
  28493. /** @hidden */
  28494. _unpackFlipY(value: boolean): void;
  28495. /** @hidden */
  28496. _getUnpackAlignement(): number;
  28497. /**
  28498. * Creates a dynamic texture
  28499. * @param width defines the width of the texture
  28500. * @param height defines the height of the texture
  28501. * @param generateMipMaps defines if the engine should generate the mip levels
  28502. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28503. * @returns the dynamic texture inside an InternalTexture
  28504. */
  28505. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28506. /**
  28507. * Update the sampling mode of a given texture
  28508. * @param samplingMode defines the required sampling mode
  28509. * @param texture defines the texture to update
  28510. */
  28511. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28512. /**
  28513. * Update the content of a dynamic texture
  28514. * @param texture defines the texture to update
  28515. * @param canvas defines the canvas containing the source
  28516. * @param invertY defines if data must be stored with Y axis inverted
  28517. * @param premulAlpha defines if alpha is stored as premultiplied
  28518. * @param format defines the format of the data
  28519. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28520. */
  28521. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28522. /**
  28523. * Update a video texture
  28524. * @param texture defines the texture to update
  28525. * @param video defines the video element to use
  28526. * @param invertY defines if data must be stored with Y axis inverted
  28527. */
  28528. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28529. /**
  28530. * Updates a depth texture Comparison Mode and Function.
  28531. * If the comparison Function is equal to 0, the mode will be set to none.
  28532. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28533. * @param texture The texture to set the comparison function for
  28534. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28535. */
  28536. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28537. private _setupDepthStencilTexture;
  28538. /**
  28539. * Creates a depth stencil texture.
  28540. * This is only available in WebGL 2 or with the depth texture extension available.
  28541. * @param size The size of face edge in the texture.
  28542. * @param options The options defining the texture.
  28543. * @returns The texture
  28544. */
  28545. createDepthStencilTexture(size: number | {
  28546. width: number;
  28547. height: number;
  28548. }, options: DepthTextureCreationOptions): InternalTexture;
  28549. /**
  28550. * Creates a depth stencil texture.
  28551. * This is only available in WebGL 2 or with the depth texture extension available.
  28552. * @param size The size of face edge in the texture.
  28553. * @param options The options defining the texture.
  28554. * @returns The texture
  28555. */
  28556. private _createDepthStencilTexture;
  28557. /**
  28558. * Creates a depth stencil cube texture.
  28559. * This is only available in WebGL 2.
  28560. * @param size The size of face edge in the cube texture.
  28561. * @param options The options defining the cube texture.
  28562. * @returns The cube texture
  28563. */
  28564. private _createDepthStencilCubeTexture;
  28565. /**
  28566. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28567. * @param renderTarget The render target to set the frame buffer for
  28568. */
  28569. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28570. /**
  28571. * Creates a new render target texture
  28572. * @param size defines the size of the texture
  28573. * @param options defines the options used to create the texture
  28574. * @returns a new render target texture stored in an InternalTexture
  28575. */
  28576. createRenderTargetTexture(size: number | {
  28577. width: number;
  28578. height: number;
  28579. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28580. /**
  28581. * Create a multi render target texture
  28582. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28583. * @param size defines the size of the texture
  28584. * @param options defines the creation options
  28585. * @returns the cube texture as an InternalTexture
  28586. */
  28587. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28588. private _setupFramebufferDepthAttachments;
  28589. /**
  28590. * Updates the sample count of a render target texture
  28591. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28592. * @param texture defines the texture to update
  28593. * @param samples defines the sample count to set
  28594. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28595. */
  28596. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28597. /**
  28598. * Update the sample count for a given multiple render target texture
  28599. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28600. * @param textures defines the textures to update
  28601. * @param samples defines the sample count to set
  28602. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28603. */
  28604. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28605. /** @hidden */
  28606. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28607. /** @hidden */
  28608. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28609. /** @hidden */
  28610. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28611. /** @hidden */
  28612. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28613. /**
  28614. * Creates a new render target cube texture
  28615. * @param size defines the size of the texture
  28616. * @param options defines the options used to create the texture
  28617. * @returns a new render target cube texture stored in an InternalTexture
  28618. */
  28619. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28620. /**
  28621. * Creates a cube texture
  28622. * @param rootUrl defines the url where the files to load is located
  28623. * @param scene defines the current scene
  28624. * @param files defines the list of files to load (1 per face)
  28625. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28626. * @param onLoad defines an optional callback raised when the texture is loaded
  28627. * @param onError defines an optional callback raised if there is an issue to load the texture
  28628. * @param format defines the format of the data
  28629. * @param forcedExtension defines the extension to use to pick the right loader
  28630. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28631. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28632. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28633. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28634. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28635. * @returns the cube texture as an InternalTexture
  28636. */
  28637. 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;
  28638. /**
  28639. * @hidden
  28640. */
  28641. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28642. /**
  28643. * Update a raw cube texture
  28644. * @param texture defines the texture to udpdate
  28645. * @param data defines the data to store
  28646. * @param format defines the data format
  28647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28648. * @param invertY defines if data must be stored with Y axis inverted
  28649. * @param compression defines the compression used (null by default)
  28650. * @param level defines which level of the texture to update
  28651. */
  28652. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28653. /**
  28654. * Creates a new raw cube texture
  28655. * @param data defines the array of data to use to create each face
  28656. * @param size defines the size of the textures
  28657. * @param format defines the format of the data
  28658. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28659. * @param generateMipMaps defines if the engine should generate the mip levels
  28660. * @param invertY defines if data must be stored with Y axis inverted
  28661. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28662. * @param compression defines the compression used (null by default)
  28663. * @returns the cube texture as an InternalTexture
  28664. */
  28665. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28666. /**
  28667. * Creates a new raw cube texture from a specified url
  28668. * @param url defines the url where the data is located
  28669. * @param scene defines the current scene
  28670. * @param size defines the size of the textures
  28671. * @param format defines the format of the data
  28672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28673. * @param noMipmap defines if the engine should avoid generating the mip levels
  28674. * @param callback defines a callback used to extract texture data from loaded data
  28675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28676. * @param onLoad defines a callback called when texture is loaded
  28677. * @param onError defines a callback called if there is an error
  28678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28679. * @param invertY defines if data must be stored with Y axis inverted
  28680. * @returns the cube texture as an InternalTexture
  28681. */
  28682. 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;
  28683. /**
  28684. * Update a raw 3D texture
  28685. * @param texture defines the texture to update
  28686. * @param data defines the data to store
  28687. * @param format defines the data format
  28688. * @param invertY defines if data must be stored with Y axis inverted
  28689. * @param compression defines the used compression (can be null)
  28690. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28691. */
  28692. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28693. /**
  28694. * Creates a new raw 3D texture
  28695. * @param data defines the data used to create the texture
  28696. * @param width defines the width of the texture
  28697. * @param height defines the height of the texture
  28698. * @param depth defines the depth of the texture
  28699. * @param format defines the format of the texture
  28700. * @param generateMipMaps defines if the engine must generate mip levels
  28701. * @param invertY defines if data must be stored with Y axis inverted
  28702. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28703. * @param compression defines the compressed used (can be null)
  28704. * @param textureType defines the compressed used (can be null)
  28705. * @returns a new raw 3D texture (stored in an InternalTexture)
  28706. */
  28707. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28708. private _prepareWebGLTextureContinuation;
  28709. private _prepareWebGLTexture;
  28710. private _convertRGBtoRGBATextureData;
  28711. /** @hidden */
  28712. _releaseFramebufferObjects(texture: InternalTexture): void;
  28713. /** @hidden */
  28714. _releaseTexture(texture: InternalTexture): void;
  28715. private setProgram;
  28716. private _boundUniforms;
  28717. /**
  28718. * Binds an effect to the webGL context
  28719. * @param effect defines the effect to bind
  28720. */
  28721. bindSamplers(effect: Effect): void;
  28722. private _moveBoundTextureOnTop;
  28723. private _getCorrectTextureChannel;
  28724. private _linkTrackers;
  28725. private _removeDesignatedSlot;
  28726. private _activateCurrentTexture;
  28727. /** @hidden */
  28728. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28729. /** @hidden */
  28730. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28731. /**
  28732. * Sets a texture to the webGL context from a postprocess
  28733. * @param channel defines the channel to use
  28734. * @param postProcess defines the source postprocess
  28735. */
  28736. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28737. /**
  28738. * Binds the output of the passed in post process to the texture channel specified
  28739. * @param channel The channel the texture should be bound to
  28740. * @param postProcess The post process which's output should be bound
  28741. */
  28742. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28743. /**
  28744. * Unbind all textures from the webGL context
  28745. */
  28746. unbindAllTextures(): void;
  28747. /**
  28748. * Sets a texture to the according uniform.
  28749. * @param channel The texture channel
  28750. * @param uniform The uniform to set
  28751. * @param texture The texture to apply
  28752. */
  28753. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28754. /**
  28755. * Sets a depth stencil texture from a render target to the according uniform.
  28756. * @param channel The texture channel
  28757. * @param uniform The uniform to set
  28758. * @param texture The render target texture containing the depth stencil texture to apply
  28759. */
  28760. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28761. private _bindSamplerUniformToChannel;
  28762. private _getTextureWrapMode;
  28763. private _setTexture;
  28764. /**
  28765. * Sets an array of texture to the webGL context
  28766. * @param channel defines the channel where the texture array must be set
  28767. * @param uniform defines the associated uniform location
  28768. * @param textures defines the array of textures to bind
  28769. */
  28770. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28771. /** @hidden */
  28772. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28773. private _setTextureParameterFloat;
  28774. private _setTextureParameterInteger;
  28775. /**
  28776. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28777. * @param x defines the x coordinate of the rectangle where pixels must be read
  28778. * @param y defines the y coordinate of the rectangle where pixels must be read
  28779. * @param width defines the width of the rectangle where pixels must be read
  28780. * @param height defines the height of the rectangle where pixels must be read
  28781. * @returns a Uint8Array containing RGBA colors
  28782. */
  28783. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28784. /**
  28785. * Add an externaly attached data from its key.
  28786. * This method call will fail and return false, if such key already exists.
  28787. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28788. * @param key the unique key that identifies the data
  28789. * @param data the data object to associate to the key for this Engine instance
  28790. * @return true if no such key were already present and the data was added successfully, false otherwise
  28791. */
  28792. addExternalData<T>(key: string, data: T): boolean;
  28793. /**
  28794. * Get an externaly attached data from its key
  28795. * @param key the unique key that identifies the data
  28796. * @return the associated data, if present (can be null), or undefined if not present
  28797. */
  28798. getExternalData<T>(key: string): T;
  28799. /**
  28800. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28801. * @param key the unique key that identifies the data
  28802. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28803. * @return the associated data, can be null if the factory returned null.
  28804. */
  28805. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28806. /**
  28807. * Remove an externaly attached data from the Engine instance
  28808. * @param key the unique key that identifies the data
  28809. * @return true if the data was successfully removed, false if it doesn't exist
  28810. */
  28811. removeExternalData(key: string): boolean;
  28812. /**
  28813. * Unbind all vertex attributes from the webGL context
  28814. */
  28815. unbindAllAttributes(): void;
  28816. /**
  28817. * 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
  28818. */
  28819. releaseEffects(): void;
  28820. /**
  28821. * Dispose and release all associated resources
  28822. */
  28823. dispose(): void;
  28824. /**
  28825. * Display the loading screen
  28826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28827. */
  28828. displayLoadingUI(): void;
  28829. /**
  28830. * Hide the loading screen
  28831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28832. */
  28833. hideLoadingUI(): void;
  28834. /**
  28835. * Gets the current loading screen object
  28836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28837. */
  28838. /**
  28839. * Sets the current loading screen object
  28840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28841. */
  28842. loadingScreen: ILoadingScreen;
  28843. /**
  28844. * Sets the current loading screen text
  28845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28846. */
  28847. loadingUIText: string;
  28848. /**
  28849. * Sets the current loading screen background color
  28850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28851. */
  28852. loadingUIBackgroundColor: string;
  28853. /**
  28854. * Attach a new callback raised when context lost event is fired
  28855. * @param callback defines the callback to call
  28856. */
  28857. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28858. /**
  28859. * Attach a new callback raised when context restored event is fired
  28860. * @param callback defines the callback to call
  28861. */
  28862. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28863. /**
  28864. * Gets the source code of the vertex 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 vertex shader associated with the program
  28867. */
  28868. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28869. /**
  28870. * Gets the source code of the fragment shader associated with a specific webGL program
  28871. * @param program defines the program to use
  28872. * @returns a string containing the source code of the fragment shader associated with the program
  28873. */
  28874. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28875. /**
  28876. * Get the current error code of the webGL context
  28877. * @returns the error code
  28878. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28879. */
  28880. getError(): number;
  28881. /**
  28882. * Gets the current framerate
  28883. * @returns a number representing the framerate
  28884. */
  28885. getFps(): number;
  28886. /**
  28887. * Gets the time spent between current and previous frame
  28888. * @returns a number representing the delta time in ms
  28889. */
  28890. getDeltaTime(): number;
  28891. private _measureFps;
  28892. /** @hidden */
  28893. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28894. private _canRenderToFloatFramebuffer;
  28895. private _canRenderToHalfFloatFramebuffer;
  28896. private _canRenderToFramebuffer;
  28897. /** @hidden */
  28898. _getWebGLTextureType(type: number): number;
  28899. private _getInternalFormat;
  28900. /** @hidden */
  28901. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28902. /** @hidden */
  28903. _getRGBAMultiSampleBufferFormat(type: number): number;
  28904. /** @hidden */
  28905. _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;
  28906. /** @hidden */
  28907. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28908. private _partialLoadFile;
  28909. private _cascadeLoadFiles;
  28910. /**
  28911. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28912. * @returns true if the engine can be created
  28913. * @ignorenaming
  28914. */
  28915. static isSupported(): boolean;
  28916. }
  28917. }
  28918. declare module "babylonjs/Materials/effect" {
  28919. import { Observable } from "babylonjs/Misc/observable";
  28920. import { Nullable } from "babylonjs/types";
  28921. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28922. import { Engine } from "babylonjs/Engines/engine";
  28923. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28925. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28928. /**
  28929. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28930. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28931. */
  28932. export class EffectFallbacks {
  28933. private _defines;
  28934. private _currentRank;
  28935. private _maxRank;
  28936. private _mesh;
  28937. /**
  28938. * Removes the fallback from the bound mesh.
  28939. */
  28940. unBindMesh(): void;
  28941. /**
  28942. * Adds a fallback on the specified property.
  28943. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28944. * @param define The name of the define in the shader
  28945. */
  28946. addFallback(rank: number, define: string): void;
  28947. /**
  28948. * Sets the mesh to use CPU skinning when needing to fallback.
  28949. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28950. * @param mesh The mesh to use the fallbacks.
  28951. */
  28952. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28953. /**
  28954. * Checks to see if more fallbacks are still availible.
  28955. */
  28956. readonly isMoreFallbacks: boolean;
  28957. /**
  28958. * Removes the defines that shoould be removed when falling back.
  28959. * @param currentDefines defines the current define statements for the shader.
  28960. * @param effect defines the current effect we try to compile
  28961. * @returns The resulting defines with defines of the current rank removed.
  28962. */
  28963. reduce(currentDefines: string, effect: Effect): string;
  28964. }
  28965. /**
  28966. * Options to be used when creating an effect.
  28967. */
  28968. export class EffectCreationOptions {
  28969. /**
  28970. * Atrributes that will be used in the shader.
  28971. */
  28972. attributes: string[];
  28973. /**
  28974. * Uniform varible names that will be set in the shader.
  28975. */
  28976. uniformsNames: string[];
  28977. /**
  28978. * Uniform buffer varible names that will be set in the shader.
  28979. */
  28980. uniformBuffersNames: string[];
  28981. /**
  28982. * Sampler texture variable names that will be set in the shader.
  28983. */
  28984. samplers: string[];
  28985. /**
  28986. * Define statements that will be set in the shader.
  28987. */
  28988. defines: any;
  28989. /**
  28990. * Possible fallbacks for this effect to improve performance when needed.
  28991. */
  28992. fallbacks: Nullable<EffectFallbacks>;
  28993. /**
  28994. * Callback that will be called when the shader is compiled.
  28995. */
  28996. onCompiled: Nullable<(effect: Effect) => void>;
  28997. /**
  28998. * Callback that will be called if an error occurs during shader compilation.
  28999. */
  29000. onError: Nullable<(effect: Effect, errors: string) => void>;
  29001. /**
  29002. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29003. */
  29004. indexParameters: any;
  29005. /**
  29006. * Max number of lights that can be used in the shader.
  29007. */
  29008. maxSimultaneousLights: number;
  29009. /**
  29010. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29011. */
  29012. transformFeedbackVaryings: Nullable<string[]>;
  29013. }
  29014. /**
  29015. * Effect containing vertex and fragment shader that can be executed on an object.
  29016. */
  29017. export class Effect {
  29018. /**
  29019. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29020. */
  29021. static ShadersRepository: string;
  29022. /**
  29023. * Name of the effect.
  29024. */
  29025. name: any;
  29026. /**
  29027. * String container all the define statements that should be set on the shader.
  29028. */
  29029. defines: string;
  29030. /**
  29031. * Callback that will be called when the shader is compiled.
  29032. */
  29033. onCompiled: Nullable<(effect: Effect) => void>;
  29034. /**
  29035. * Callback that will be called if an error occurs during shader compilation.
  29036. */
  29037. onError: Nullable<(effect: Effect, errors: string) => void>;
  29038. /**
  29039. * Callback that will be called when effect is bound.
  29040. */
  29041. onBind: Nullable<(effect: Effect) => void>;
  29042. /**
  29043. * Unique ID of the effect.
  29044. */
  29045. uniqueId: number;
  29046. /**
  29047. * Observable that will be called when the shader is compiled.
  29048. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29049. */
  29050. onCompileObservable: Observable<Effect>;
  29051. /**
  29052. * Observable that will be called if an error occurs during shader compilation.
  29053. */
  29054. onErrorObservable: Observable<Effect>;
  29055. /** @hidden */
  29056. _onBindObservable: Nullable<Observable<Effect>>;
  29057. /**
  29058. * Observable that will be called when effect is bound.
  29059. */
  29060. readonly onBindObservable: Observable<Effect>;
  29061. /** @hidden */
  29062. _bonesComputationForcedToCPU: boolean;
  29063. private static _uniqueIdSeed;
  29064. private _engine;
  29065. private _uniformBuffersNames;
  29066. private _uniformsNames;
  29067. private _samplers;
  29068. private _isReady;
  29069. private _compilationError;
  29070. private _attributesNames;
  29071. private _attributes;
  29072. private _uniforms;
  29073. /**
  29074. * Key for the effect.
  29075. * @hidden
  29076. */
  29077. _key: string;
  29078. private _indexParameters;
  29079. private _fallbacks;
  29080. private _vertexSourceCode;
  29081. private _fragmentSourceCode;
  29082. private _vertexSourceCodeOverride;
  29083. private _fragmentSourceCodeOverride;
  29084. private _transformFeedbackVaryings;
  29085. /**
  29086. * Compiled shader to webGL program.
  29087. * @hidden
  29088. */
  29089. _program: WebGLProgram;
  29090. private _valueCache;
  29091. private static _baseCache;
  29092. /**
  29093. * Instantiates an effect.
  29094. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29095. * @param baseName Name of the effect.
  29096. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29097. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29098. * @param samplers List of sampler variables that will be passed to the shader.
  29099. * @param engine Engine to be used to render the effect
  29100. * @param defines Define statements to be added to the shader.
  29101. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29102. * @param onCompiled Callback that will be called when the shader is compiled.
  29103. * @param onError Callback that will be called if an error occurs during shader compilation.
  29104. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29105. */
  29106. 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);
  29107. /**
  29108. * Unique key for this effect
  29109. */
  29110. readonly key: string;
  29111. /**
  29112. * If the effect has been compiled and prepared.
  29113. * @returns if the effect is compiled and prepared.
  29114. */
  29115. isReady(): boolean;
  29116. /**
  29117. * The engine the effect was initialized with.
  29118. * @returns the engine.
  29119. */
  29120. getEngine(): Engine;
  29121. /**
  29122. * The compiled webGL program for the effect
  29123. * @returns the webGL program.
  29124. */
  29125. getProgram(): WebGLProgram;
  29126. /**
  29127. * The set of names of attribute variables for the shader.
  29128. * @returns An array of attribute names.
  29129. */
  29130. getAttributesNames(): string[];
  29131. /**
  29132. * Returns the attribute at the given index.
  29133. * @param index The index of the attribute.
  29134. * @returns The location of the attribute.
  29135. */
  29136. getAttributeLocation(index: number): number;
  29137. /**
  29138. * Returns the attribute based on the name of the variable.
  29139. * @param name of the attribute to look up.
  29140. * @returns the attribute location.
  29141. */
  29142. getAttributeLocationByName(name: string): number;
  29143. /**
  29144. * The number of attributes.
  29145. * @returns the numnber of attributes.
  29146. */
  29147. getAttributesCount(): number;
  29148. /**
  29149. * Gets the index of a uniform variable.
  29150. * @param uniformName of the uniform to look up.
  29151. * @returns the index.
  29152. */
  29153. getUniformIndex(uniformName: string): number;
  29154. /**
  29155. * Returns the attribute based on the name of the variable.
  29156. * @param uniformName of the uniform to look up.
  29157. * @returns the location of the uniform.
  29158. */
  29159. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29160. /**
  29161. * Returns an array of sampler variable names
  29162. * @returns The array of sampler variable neames.
  29163. */
  29164. getSamplers(): string[];
  29165. /**
  29166. * The error from the last compilation.
  29167. * @returns the error string.
  29168. */
  29169. getCompilationError(): string;
  29170. /**
  29171. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29172. * @param func The callback to be used.
  29173. */
  29174. executeWhenCompiled(func: (effect: Effect) => void): void;
  29175. private _checkIsReady;
  29176. /** @hidden */
  29177. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29178. /** @hidden */
  29179. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29180. /** @hidden */
  29181. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29182. private _processShaderConversion;
  29183. private _processIncludes;
  29184. private _processPrecision;
  29185. /**
  29186. * Recompiles the webGL program
  29187. * @param vertexSourceCode The source code for the vertex shader.
  29188. * @param fragmentSourceCode The source code for the fragment shader.
  29189. * @param onCompiled Callback called when completed.
  29190. * @param onError Callback called on error.
  29191. * @hidden
  29192. */
  29193. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29194. /**
  29195. * Gets the uniform locations of the the specified variable names
  29196. * @param names THe names of the variables to lookup.
  29197. * @returns Array of locations in the same order as variable names.
  29198. */
  29199. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29200. /**
  29201. * Prepares the effect
  29202. * @hidden
  29203. */
  29204. _prepareEffect(): void;
  29205. /**
  29206. * Checks if the effect is supported. (Must be called after compilation)
  29207. */
  29208. readonly isSupported: boolean;
  29209. /**
  29210. * Binds a texture to the engine to be used as output of the shader.
  29211. * @param channel Name of the output variable.
  29212. * @param texture Texture to bind.
  29213. * @hidden
  29214. */
  29215. _bindTexture(channel: string, texture: InternalTexture): void;
  29216. /**
  29217. * Sets a texture 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. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29222. /**
  29223. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29224. * @param channel Name of the sampler variable.
  29225. * @param texture Texture to set.
  29226. */
  29227. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29228. /**
  29229. * Sets an array of textures on the engine to be used in the shader.
  29230. * @param channel Name of the variable.
  29231. * @param textures Textures to set.
  29232. */
  29233. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29234. /**
  29235. * 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)
  29236. * @param channel Name of the sampler variable.
  29237. * @param postProcess Post process to get the input texture from.
  29238. */
  29239. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29240. /**
  29241. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29242. * 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)
  29243. * @param channel Name of the sampler variable.
  29244. * @param postProcess Post process to get the output texture from.
  29245. */
  29246. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29247. /** @hidden */
  29248. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29249. /** @hidden */
  29250. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29251. /** @hidden */
  29252. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29253. /** @hidden */
  29254. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29255. /**
  29256. * Binds a buffer to a uniform.
  29257. * @param buffer Buffer to bind.
  29258. * @param name Name of the uniform variable to bind to.
  29259. */
  29260. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29261. /**
  29262. * Binds block to a uniform.
  29263. * @param blockName Name of the block to bind.
  29264. * @param index Index to bind.
  29265. */
  29266. bindUniformBlock(blockName: string, index: number): void;
  29267. /**
  29268. * Sets an interger value on a uniform variable.
  29269. * @param uniformName Name of the variable.
  29270. * @param value Value to be set.
  29271. * @returns this effect.
  29272. */
  29273. setInt(uniformName: string, value: number): Effect;
  29274. /**
  29275. * Sets an int array on a uniform variable.
  29276. * @param uniformName Name of the variable.
  29277. * @param array array to be set.
  29278. * @returns this effect.
  29279. */
  29280. setIntArray(uniformName: string, array: Int32Array): Effect;
  29281. /**
  29282. * 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)
  29283. * @param uniformName Name of the variable.
  29284. * @param array array to be set.
  29285. * @returns this effect.
  29286. */
  29287. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29288. /**
  29289. * 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)
  29290. * @param uniformName Name of the variable.
  29291. * @param array array to be set.
  29292. * @returns this effect.
  29293. */
  29294. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29295. /**
  29296. * 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)
  29297. * @param uniformName Name of the variable.
  29298. * @param array array to be set.
  29299. * @returns this effect.
  29300. */
  29301. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29302. /**
  29303. * Sets an float array on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param array array to be set.
  29306. * @returns this effect.
  29307. */
  29308. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29309. /**
  29310. * 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)
  29311. * @param uniformName Name of the variable.
  29312. * @param array array to be set.
  29313. * @returns this effect.
  29314. */
  29315. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29316. /**
  29317. * 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)
  29318. * @param uniformName Name of the variable.
  29319. * @param array array to be set.
  29320. * @returns this effect.
  29321. */
  29322. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29323. /**
  29324. * 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)
  29325. * @param uniformName Name of the variable.
  29326. * @param array array to be set.
  29327. * @returns this effect.
  29328. */
  29329. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29330. /**
  29331. * Sets an array on a uniform variable.
  29332. * @param uniformName Name of the variable.
  29333. * @param array array to be set.
  29334. * @returns this effect.
  29335. */
  29336. setArray(uniformName: string, array: number[]): Effect;
  29337. /**
  29338. * 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)
  29339. * @param uniformName Name of the variable.
  29340. * @param array array to be set.
  29341. * @returns this effect.
  29342. */
  29343. setArray2(uniformName: string, array: number[]): Effect;
  29344. /**
  29345. * 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)
  29346. * @param uniformName Name of the variable.
  29347. * @param array array to be set.
  29348. * @returns this effect.
  29349. */
  29350. setArray3(uniformName: string, array: number[]): Effect;
  29351. /**
  29352. * 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)
  29353. * @param uniformName Name of the variable.
  29354. * @param array array to be set.
  29355. * @returns this effect.
  29356. */
  29357. setArray4(uniformName: string, array: number[]): Effect;
  29358. /**
  29359. * Sets matrices on a uniform variable.
  29360. * @param uniformName Name of the variable.
  29361. * @param matrices matrices to be set.
  29362. * @returns this effect.
  29363. */
  29364. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29365. /**
  29366. * Sets matrix on a uniform variable.
  29367. * @param uniformName Name of the variable.
  29368. * @param matrix matrix to be set.
  29369. * @returns this effect.
  29370. */
  29371. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29372. /**
  29373. * 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)
  29374. * @param uniformName Name of the variable.
  29375. * @param matrix matrix to be set.
  29376. * @returns this effect.
  29377. */
  29378. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29379. /**
  29380. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29381. * @param uniformName Name of the variable.
  29382. * @param matrix matrix to be set.
  29383. * @returns this effect.
  29384. */
  29385. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29386. /**
  29387. * Sets a float on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param value value to be set.
  29390. * @returns this effect.
  29391. */
  29392. setFloat(uniformName: string, value: number): Effect;
  29393. /**
  29394. * Sets a boolean on a uniform variable.
  29395. * @param uniformName Name of the variable.
  29396. * @param bool value to be set.
  29397. * @returns this effect.
  29398. */
  29399. setBool(uniformName: string, bool: boolean): Effect;
  29400. /**
  29401. * Sets a Vector2 on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param vector2 vector2 to be set.
  29404. * @returns this effect.
  29405. */
  29406. setVector2(uniformName: string, vector2: Vector2): Effect;
  29407. /**
  29408. * Sets a float2 on a uniform variable.
  29409. * @param uniformName Name of the variable.
  29410. * @param x First float in float2.
  29411. * @param y Second float in float2.
  29412. * @returns this effect.
  29413. */
  29414. setFloat2(uniformName: string, x: number, y: number): Effect;
  29415. /**
  29416. * Sets a Vector3 on a uniform variable.
  29417. * @param uniformName Name of the variable.
  29418. * @param vector3 Value to be set.
  29419. * @returns this effect.
  29420. */
  29421. setVector3(uniformName: string, vector3: Vector3): Effect;
  29422. /**
  29423. * Sets a float3 on a uniform variable.
  29424. * @param uniformName Name of the variable.
  29425. * @param x First float in float3.
  29426. * @param y Second float in float3.
  29427. * @param z Third float in float3.
  29428. * @returns this effect.
  29429. */
  29430. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29431. /**
  29432. * Sets a Vector4 on a uniform variable.
  29433. * @param uniformName Name of the variable.
  29434. * @param vector4 Value to be set.
  29435. * @returns this effect.
  29436. */
  29437. setVector4(uniformName: string, vector4: Vector4): Effect;
  29438. /**
  29439. * Sets a float4 on a uniform variable.
  29440. * @param uniformName Name of the variable.
  29441. * @param x First float in float4.
  29442. * @param y Second float in float4.
  29443. * @param z Third float in float4.
  29444. * @param w Fourth float in float4.
  29445. * @returns this effect.
  29446. */
  29447. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29448. /**
  29449. * Sets a Color3 on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param color3 Value to be set.
  29452. * @returns this effect.
  29453. */
  29454. setColor3(uniformName: string, color3: Color3): Effect;
  29455. /**
  29456. * Sets a Color4 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param color3 Value to be set.
  29459. * @param alpha Alpha value to be set.
  29460. * @returns this effect.
  29461. */
  29462. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29463. /**
  29464. * Sets a Color4 on a uniform variable
  29465. * @param uniformName defines the name of the variable
  29466. * @param color4 defines the value to be set
  29467. * @returns this effect.
  29468. */
  29469. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29470. /**
  29471. * This function will add a new shader to the shader store
  29472. * @param name the name of the shader
  29473. * @param pixelShader optional pixel shader content
  29474. * @param vertexShader optional vertex shader content
  29475. */
  29476. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29477. /**
  29478. * Store of each shader (The can be looked up using effect.key)
  29479. */
  29480. static ShadersStore: {
  29481. [key: string]: string;
  29482. };
  29483. /**
  29484. * Store of each included file for a shader (The can be looked up using effect.key)
  29485. */
  29486. static IncludesShadersStore: {
  29487. [key: string]: string;
  29488. };
  29489. /**
  29490. * Resets the cache of effects.
  29491. */
  29492. static ResetCache(): void;
  29493. }
  29494. }
  29495. declare module "babylonjs/Materials/colorCurves" {
  29496. import { Effect } from "babylonjs/Materials/effect";
  29497. /**
  29498. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29499. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29500. * 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;
  29501. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29502. */
  29503. export class ColorCurves {
  29504. private _dirty;
  29505. private _tempColor;
  29506. private _globalCurve;
  29507. private _highlightsCurve;
  29508. private _midtonesCurve;
  29509. private _shadowsCurve;
  29510. private _positiveCurve;
  29511. private _negativeCurve;
  29512. private _globalHue;
  29513. private _globalDensity;
  29514. private _globalSaturation;
  29515. private _globalExposure;
  29516. /**
  29517. * Gets the global Hue value.
  29518. * 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).
  29519. */
  29520. /**
  29521. * Sets the global Hue value.
  29522. * 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).
  29523. */
  29524. globalHue: number;
  29525. /**
  29526. * Gets the global Density value.
  29527. * 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.
  29528. * Values less than zero provide a filter of opposite hue.
  29529. */
  29530. /**
  29531. * Sets the global Density value.
  29532. * 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.
  29533. * Values less than zero provide a filter of opposite hue.
  29534. */
  29535. globalDensity: number;
  29536. /**
  29537. * Gets the global Saturation value.
  29538. * 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.
  29539. */
  29540. /**
  29541. * Sets the global Saturation value.
  29542. * 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.
  29543. */
  29544. globalSaturation: number;
  29545. /**
  29546. * Gets the global Exposure value.
  29547. * 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.
  29548. */
  29549. /**
  29550. * Sets the global Exposure value.
  29551. * 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.
  29552. */
  29553. globalExposure: number;
  29554. private _highlightsHue;
  29555. private _highlightsDensity;
  29556. private _highlightsSaturation;
  29557. private _highlightsExposure;
  29558. /**
  29559. * Gets the highlights Hue value.
  29560. * 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).
  29561. */
  29562. /**
  29563. * Sets the highlights Hue value.
  29564. * 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).
  29565. */
  29566. highlightsHue: number;
  29567. /**
  29568. * Gets the highlights Density value.
  29569. * 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.
  29570. * Values less than zero provide a filter of opposite hue.
  29571. */
  29572. /**
  29573. * Sets the highlights Density value.
  29574. * 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.
  29575. * Values less than zero provide a filter of opposite hue.
  29576. */
  29577. highlightsDensity: number;
  29578. /**
  29579. * Gets the highlights Saturation value.
  29580. * 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.
  29581. */
  29582. /**
  29583. * Sets the highlights Saturation value.
  29584. * 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.
  29585. */
  29586. highlightsSaturation: number;
  29587. /**
  29588. * Gets the highlights Exposure value.
  29589. * 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.
  29590. */
  29591. /**
  29592. * Sets the highlights Exposure value.
  29593. * 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.
  29594. */
  29595. highlightsExposure: number;
  29596. private _midtonesHue;
  29597. private _midtonesDensity;
  29598. private _midtonesSaturation;
  29599. private _midtonesExposure;
  29600. /**
  29601. * Gets the midtones Hue value.
  29602. * 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).
  29603. */
  29604. /**
  29605. * Sets the midtones Hue value.
  29606. * 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).
  29607. */
  29608. midtonesHue: number;
  29609. /**
  29610. * Gets the midtones Density value.
  29611. * 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.
  29612. * Values less than zero provide a filter of opposite hue.
  29613. */
  29614. /**
  29615. * Sets the midtones Density value.
  29616. * 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.
  29617. * Values less than zero provide a filter of opposite hue.
  29618. */
  29619. midtonesDensity: number;
  29620. /**
  29621. * Gets the midtones Saturation value.
  29622. * 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.
  29623. */
  29624. /**
  29625. * Sets the midtones Saturation value.
  29626. * 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.
  29627. */
  29628. midtonesSaturation: number;
  29629. /**
  29630. * Gets the midtones Exposure value.
  29631. * 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.
  29632. */
  29633. /**
  29634. * Sets the midtones Exposure value.
  29635. * 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.
  29636. */
  29637. midtonesExposure: number;
  29638. private _shadowsHue;
  29639. private _shadowsDensity;
  29640. private _shadowsSaturation;
  29641. private _shadowsExposure;
  29642. /**
  29643. * Gets the shadows Hue value.
  29644. * 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).
  29645. */
  29646. /**
  29647. * Sets the shadows Hue value.
  29648. * 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).
  29649. */
  29650. shadowsHue: number;
  29651. /**
  29652. * Gets the shadows Density value.
  29653. * 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.
  29654. * Values less than zero provide a filter of opposite hue.
  29655. */
  29656. /**
  29657. * Sets the shadows Density value.
  29658. * 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.
  29659. * Values less than zero provide a filter of opposite hue.
  29660. */
  29661. shadowsDensity: number;
  29662. /**
  29663. * Gets the shadows Saturation value.
  29664. * 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.
  29665. */
  29666. /**
  29667. * Sets the shadows Saturation value.
  29668. * 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.
  29669. */
  29670. shadowsSaturation: number;
  29671. /**
  29672. * Gets the shadows Exposure value.
  29673. * 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.
  29674. */
  29675. /**
  29676. * Sets the shadows Exposure value.
  29677. * 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.
  29678. */
  29679. shadowsExposure: number;
  29680. /**
  29681. * Returns the class name
  29682. * @returns The class name
  29683. */
  29684. getClassName(): string;
  29685. /**
  29686. * Binds the color curves to the shader.
  29687. * @param colorCurves The color curve to bind
  29688. * @param effect The effect to bind to
  29689. * @param positiveUniform The positive uniform shader parameter
  29690. * @param neutralUniform The neutral uniform shader parameter
  29691. * @param negativeUniform The negative uniform shader parameter
  29692. */
  29693. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29694. /**
  29695. * Prepare the list of uniforms associated with the ColorCurves effects.
  29696. * @param uniformsList The list of uniforms used in the effect
  29697. */
  29698. static PrepareUniforms(uniformsList: string[]): void;
  29699. /**
  29700. * Returns color grading data based on a hue, density, saturation and exposure value.
  29701. * @param filterHue The hue of the color filter.
  29702. * @param filterDensity The density of the color filter.
  29703. * @param saturation The saturation.
  29704. * @param exposure The exposure.
  29705. * @param result The result data container.
  29706. */
  29707. private getColorGradingDataToRef;
  29708. /**
  29709. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29710. * @param value The input slider value in range [-100,100].
  29711. * @returns Adjusted value.
  29712. */
  29713. private static applyColorGradingSliderNonlinear;
  29714. /**
  29715. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29716. * @param hue The hue (H) input.
  29717. * @param saturation The saturation (S) input.
  29718. * @param brightness The brightness (B) input.
  29719. * @result An RGBA color represented as Vector4.
  29720. */
  29721. private static fromHSBToRef;
  29722. /**
  29723. * Returns a value clamped between min and max
  29724. * @param value The value to clamp
  29725. * @param min The minimum of value
  29726. * @param max The maximum of value
  29727. * @returns The clamped value.
  29728. */
  29729. private static clamp;
  29730. /**
  29731. * Clones the current color curve instance.
  29732. * @return The cloned curves
  29733. */
  29734. clone(): ColorCurves;
  29735. /**
  29736. * Serializes the current color curve instance to a json representation.
  29737. * @return a JSON representation
  29738. */
  29739. serialize(): any;
  29740. /**
  29741. * Parses the color curve from a json representation.
  29742. * @param source the JSON source to parse
  29743. * @return The parsed curves
  29744. */
  29745. static Parse(source: any): ColorCurves;
  29746. }
  29747. }
  29748. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29749. import { Observable } from "babylonjs/Misc/observable";
  29750. import { Nullable } from "babylonjs/types";
  29751. import { Color4 } from "babylonjs/Maths/math";
  29752. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29753. import { Effect } from "babylonjs/Materials/effect";
  29754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29755. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29756. /**
  29757. * Interface to follow in your material defines to integrate easily the
  29758. * Image proccessing functions.
  29759. * @hidden
  29760. */
  29761. export interface IImageProcessingConfigurationDefines {
  29762. IMAGEPROCESSING: boolean;
  29763. VIGNETTE: boolean;
  29764. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29765. VIGNETTEBLENDMODEOPAQUE: boolean;
  29766. TONEMAPPING: boolean;
  29767. TONEMAPPING_ACES: boolean;
  29768. CONTRAST: boolean;
  29769. EXPOSURE: boolean;
  29770. COLORCURVES: boolean;
  29771. COLORGRADING: boolean;
  29772. COLORGRADING3D: boolean;
  29773. SAMPLER3DGREENDEPTH: boolean;
  29774. SAMPLER3DBGRMAP: boolean;
  29775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29776. }
  29777. /**
  29778. * @hidden
  29779. */
  29780. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29781. IMAGEPROCESSING: boolean;
  29782. VIGNETTE: boolean;
  29783. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29784. VIGNETTEBLENDMODEOPAQUE: boolean;
  29785. TONEMAPPING: boolean;
  29786. TONEMAPPING_ACES: boolean;
  29787. CONTRAST: boolean;
  29788. COLORCURVES: boolean;
  29789. COLORGRADING: boolean;
  29790. COLORGRADING3D: boolean;
  29791. SAMPLER3DGREENDEPTH: boolean;
  29792. SAMPLER3DBGRMAP: boolean;
  29793. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29794. EXPOSURE: boolean;
  29795. constructor();
  29796. }
  29797. /**
  29798. * This groups together the common properties used for image processing either in direct forward pass
  29799. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29800. * or not.
  29801. */
  29802. export class ImageProcessingConfiguration {
  29803. /**
  29804. * Default tone mapping applied in BabylonJS.
  29805. */
  29806. static readonly TONEMAPPING_STANDARD: number;
  29807. /**
  29808. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29809. * to other engines rendering to increase portability.
  29810. */
  29811. static readonly TONEMAPPING_ACES: number;
  29812. /**
  29813. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29814. */
  29815. colorCurves: Nullable<ColorCurves>;
  29816. private _colorCurvesEnabled;
  29817. /**
  29818. * Gets wether the color curves effect is enabled.
  29819. */
  29820. /**
  29821. * Sets wether the color curves effect is enabled.
  29822. */
  29823. colorCurvesEnabled: boolean;
  29824. private _colorGradingTexture;
  29825. /**
  29826. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29827. */
  29828. /**
  29829. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29830. */
  29831. colorGradingTexture: Nullable<BaseTexture>;
  29832. private _colorGradingEnabled;
  29833. /**
  29834. * Gets wether the color grading effect is enabled.
  29835. */
  29836. /**
  29837. * Sets wether the color grading effect is enabled.
  29838. */
  29839. colorGradingEnabled: boolean;
  29840. private _colorGradingWithGreenDepth;
  29841. /**
  29842. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29843. */
  29844. /**
  29845. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29846. */
  29847. colorGradingWithGreenDepth: boolean;
  29848. private _colorGradingBGR;
  29849. /**
  29850. * Gets wether the color grading texture contains BGR values.
  29851. */
  29852. /**
  29853. * Sets wether the color grading texture contains BGR values.
  29854. */
  29855. colorGradingBGR: boolean;
  29856. /** @hidden */
  29857. _exposure: number;
  29858. /**
  29859. * Gets the Exposure used in the effect.
  29860. */
  29861. /**
  29862. * Sets the Exposure used in the effect.
  29863. */
  29864. exposure: number;
  29865. private _toneMappingEnabled;
  29866. /**
  29867. * Gets wether the tone mapping effect is enabled.
  29868. */
  29869. /**
  29870. * Sets wether the tone mapping effect is enabled.
  29871. */
  29872. toneMappingEnabled: boolean;
  29873. private _toneMappingType;
  29874. /**
  29875. * Gets the type of tone mapping effect.
  29876. */
  29877. /**
  29878. * Sets the type of tone mapping effect used in BabylonJS.
  29879. */
  29880. toneMappingType: number;
  29881. protected _contrast: number;
  29882. /**
  29883. * Gets the contrast used in the effect.
  29884. */
  29885. /**
  29886. * Sets the contrast used in the effect.
  29887. */
  29888. contrast: number;
  29889. /**
  29890. * Vignette stretch size.
  29891. */
  29892. vignetteStretch: number;
  29893. /**
  29894. * Vignette centre X Offset.
  29895. */
  29896. vignetteCentreX: number;
  29897. /**
  29898. * Vignette centre Y Offset.
  29899. */
  29900. vignetteCentreY: number;
  29901. /**
  29902. * Vignette weight or intensity of the vignette effect.
  29903. */
  29904. vignetteWeight: number;
  29905. /**
  29906. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29907. * if vignetteEnabled is set to true.
  29908. */
  29909. vignetteColor: Color4;
  29910. /**
  29911. * Camera field of view used by the Vignette effect.
  29912. */
  29913. vignetteCameraFov: number;
  29914. private _vignetteBlendMode;
  29915. /**
  29916. * Gets the vignette blend mode allowing different kind of effect.
  29917. */
  29918. /**
  29919. * Sets the vignette blend mode allowing different kind of effect.
  29920. */
  29921. vignetteBlendMode: number;
  29922. private _vignetteEnabled;
  29923. /**
  29924. * Gets wether the vignette effect is enabled.
  29925. */
  29926. /**
  29927. * Sets wether the vignette effect is enabled.
  29928. */
  29929. vignetteEnabled: boolean;
  29930. private _applyByPostProcess;
  29931. /**
  29932. * Gets wether the image processing is applied through a post process or not.
  29933. */
  29934. /**
  29935. * Sets wether the image processing is applied through a post process or not.
  29936. */
  29937. applyByPostProcess: boolean;
  29938. private _isEnabled;
  29939. /**
  29940. * Gets wether the image processing is enabled or not.
  29941. */
  29942. /**
  29943. * Sets wether the image processing is enabled or not.
  29944. */
  29945. isEnabled: boolean;
  29946. /**
  29947. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29948. */
  29949. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29950. /**
  29951. * Method called each time the image processing information changes requires to recompile the effect.
  29952. */
  29953. protected _updateParameters(): void;
  29954. /**
  29955. * Gets the current class name.
  29956. * @return "ImageProcessingConfiguration"
  29957. */
  29958. getClassName(): string;
  29959. /**
  29960. * Prepare the list of uniforms associated with the Image Processing effects.
  29961. * @param uniforms The list of uniforms used in the effect
  29962. * @param defines the list of defines currently in use
  29963. */
  29964. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29965. /**
  29966. * Prepare the list of samplers associated with the Image Processing effects.
  29967. * @param samplersList The list of uniforms used in the effect
  29968. * @param defines the list of defines currently in use
  29969. */
  29970. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29971. /**
  29972. * Prepare the list of defines associated to the shader.
  29973. * @param defines the list of defines to complete
  29974. * @param forPostProcess Define if we are currently in post process mode or not
  29975. */
  29976. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29977. /**
  29978. * Returns true if all the image processing information are ready.
  29979. * @returns True if ready, otherwise, false
  29980. */
  29981. isReady(): boolean;
  29982. /**
  29983. * Binds the image processing to the shader.
  29984. * @param effect The effect to bind to
  29985. * @param aspectRatio Define the current aspect ratio of the effect
  29986. */
  29987. bind(effect: Effect, aspectRatio?: number): void;
  29988. /**
  29989. * Clones the current image processing instance.
  29990. * @return The cloned image processing
  29991. */
  29992. clone(): ImageProcessingConfiguration;
  29993. /**
  29994. * Serializes the current image processing instance to a json representation.
  29995. * @return a JSON representation
  29996. */
  29997. serialize(): any;
  29998. /**
  29999. * Parses the image processing from a json representation.
  30000. * @param source the JSON source to parse
  30001. * @return The parsed image processing
  30002. */
  30003. static Parse(source: any): ImageProcessingConfiguration;
  30004. private static _VIGNETTEMODE_MULTIPLY;
  30005. private static _VIGNETTEMODE_OPAQUE;
  30006. /**
  30007. * Used to apply the vignette as a mix with the pixel color.
  30008. */
  30009. static readonly VIGNETTEMODE_MULTIPLY: number;
  30010. /**
  30011. * Used to apply the vignette as a replacement of the pixel color.
  30012. */
  30013. static readonly VIGNETTEMODE_OPAQUE: number;
  30014. }
  30015. }
  30016. declare module "babylonjs/Materials/fresnelParameters" {
  30017. import { Color3 } from "babylonjs/Maths/math";
  30018. /**
  30019. * This represents all the required information to add a fresnel effect on a material:
  30020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30021. */
  30022. export class FresnelParameters {
  30023. private _isEnabled;
  30024. /**
  30025. * Define if the fresnel effect is enable or not.
  30026. */
  30027. isEnabled: boolean;
  30028. /**
  30029. * Define the color used on edges (grazing angle)
  30030. */
  30031. leftColor: Color3;
  30032. /**
  30033. * Define the color used on center
  30034. */
  30035. rightColor: Color3;
  30036. /**
  30037. * Define bias applied to computed fresnel term
  30038. */
  30039. bias: number;
  30040. /**
  30041. * Defined the power exponent applied to fresnel term
  30042. */
  30043. power: number;
  30044. /**
  30045. * Clones the current fresnel and its valuues
  30046. * @returns a clone fresnel configuration
  30047. */
  30048. clone(): FresnelParameters;
  30049. /**
  30050. * Serializes the current fresnel parameters to a JSON representation.
  30051. * @return the JSON serialization
  30052. */
  30053. serialize(): any;
  30054. /**
  30055. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30056. * @param parsedFresnelParameters Define the JSON representation
  30057. * @returns the parsed parameters
  30058. */
  30059. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30060. }
  30061. }
  30062. declare module "babylonjs/Misc/decorators" {
  30063. import { Nullable } from "babylonjs/types";
  30064. import { Scene } from "babylonjs/scene";
  30065. import { IAnimatable } from "babylonjs/Misc/tools";
  30066. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30067. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30068. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30069. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30070. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30071. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30072. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30073. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30074. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30075. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30076. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30077. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30078. /**
  30079. * Decorator used to define property that can be serialized as reference to a camera
  30080. * @param sourceName defines the name of the property to decorate
  30081. */
  30082. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30083. /**
  30084. * Class used to help serialization objects
  30085. */
  30086. export class SerializationHelper {
  30087. /** hidden */
  30088. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30089. /** hidden */
  30090. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30091. /** hidden */
  30092. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30093. /** hidden */
  30094. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30095. /**
  30096. * Appends the serialized animations from the source animations
  30097. * @param source Source containing the animations
  30098. * @param destination Target to store the animations
  30099. */
  30100. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30101. /**
  30102. * Static function used to serialized a specific entity
  30103. * @param entity defines the entity to serialize
  30104. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30105. * @returns a JSON compatible object representing the serialization of the entity
  30106. */
  30107. static Serialize<T>(entity: T, serializationObject?: any): any;
  30108. /**
  30109. * Creates a new entity from a serialization data object
  30110. * @param creationFunction defines a function used to instanciated the new entity
  30111. * @param source defines the source serialization data
  30112. * @param scene defines the hosting scene
  30113. * @param rootUrl defines the root url for resources
  30114. * @returns a new entity
  30115. */
  30116. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30117. /**
  30118. * Clones an object
  30119. * @param creationFunction defines the function used to instanciate the new object
  30120. * @param source defines the source object
  30121. * @returns the cloned object
  30122. */
  30123. static Clone<T>(creationFunction: () => T, source: T): T;
  30124. /**
  30125. * Instanciates a new object based on a source one (some data will be shared between both object)
  30126. * @param creationFunction defines the function used to instanciate the new object
  30127. * @param source defines the source object
  30128. * @returns the new object
  30129. */
  30130. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30131. }
  30132. }
  30133. declare module "babylonjs/Cameras/camera" {
  30134. import { SmartArray } from "babylonjs/Misc/smartArray";
  30135. import { Observable } from "babylonjs/Misc/observable";
  30136. import { Nullable } from "babylonjs/types";
  30137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30138. import { Scene } from "babylonjs/scene";
  30139. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30140. import { Node } from "babylonjs/node";
  30141. import { Mesh } from "babylonjs/Meshes/mesh";
  30142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30143. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30144. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30145. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30146. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30147. import { Ray } from "babylonjs/Culling/ray";
  30148. /**
  30149. * This is the base class of all the camera used in the application.
  30150. * @see http://doc.babylonjs.com/features/cameras
  30151. */
  30152. export class Camera extends Node {
  30153. /** @hidden */
  30154. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30155. /**
  30156. * This is the default projection mode used by the cameras.
  30157. * It helps recreating a feeling of perspective and better appreciate depth.
  30158. * This is the best way to simulate real life cameras.
  30159. */
  30160. static readonly PERSPECTIVE_CAMERA: number;
  30161. /**
  30162. * This helps creating camera with an orthographic mode.
  30163. * 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.
  30164. */
  30165. static readonly ORTHOGRAPHIC_CAMERA: number;
  30166. /**
  30167. * This is the default FOV mode for perspective cameras.
  30168. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30169. */
  30170. static readonly FOVMODE_VERTICAL_FIXED: number;
  30171. /**
  30172. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30173. */
  30174. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30175. /**
  30176. * This specifies ther is no need for a camera rig.
  30177. * Basically only one eye is rendered corresponding to the camera.
  30178. */
  30179. static readonly RIG_MODE_NONE: number;
  30180. /**
  30181. * Simulates a camera Rig with one blue eye and one red eye.
  30182. * This can be use with 3d blue and red glasses.
  30183. */
  30184. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30185. /**
  30186. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30187. */
  30188. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30189. /**
  30190. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30191. */
  30192. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30193. /**
  30194. * Defines that both eyes of the camera will be rendered over under each other.
  30195. */
  30196. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30197. /**
  30198. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30199. */
  30200. static readonly RIG_MODE_VR: number;
  30201. /**
  30202. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30203. */
  30204. static readonly RIG_MODE_WEBVR: number;
  30205. /**
  30206. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30207. */
  30208. static readonly RIG_MODE_CUSTOM: number;
  30209. /**
  30210. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30211. */
  30212. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30213. /**
  30214. * @hidden
  30215. * Might be removed once multiview will be a thing
  30216. */
  30217. static UseAlternateWebVRRendering: boolean;
  30218. /**
  30219. * Define the input manager associated with the camera.
  30220. */
  30221. inputs: CameraInputsManager<Camera>;
  30222. /** @hidden */
  30223. _position: Vector3;
  30224. /**
  30225. * Define the current local position of the camera in the scene
  30226. */
  30227. position: Vector3;
  30228. /**
  30229. * The vector the camera should consider as up.
  30230. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30231. */
  30232. upVector: Vector3;
  30233. /**
  30234. * Define the current limit on the left side for an orthographic camera
  30235. * In scene unit
  30236. */
  30237. orthoLeft: Nullable<number>;
  30238. /**
  30239. * Define the current limit on the right side for an orthographic camera
  30240. * In scene unit
  30241. */
  30242. orthoRight: Nullable<number>;
  30243. /**
  30244. * Define the current limit on the bottom side for an orthographic camera
  30245. * In scene unit
  30246. */
  30247. orthoBottom: Nullable<number>;
  30248. /**
  30249. * Define the current limit on the top side for an orthographic camera
  30250. * In scene unit
  30251. */
  30252. orthoTop: Nullable<number>;
  30253. /**
  30254. * Field Of View is set in Radians. (default is 0.8)
  30255. */
  30256. fov: number;
  30257. /**
  30258. * Define the minimum distance the camera can see from.
  30259. * This is important to note that the depth buffer are not infinite and the closer it starts
  30260. * the more your scene might encounter depth fighting issue.
  30261. */
  30262. minZ: number;
  30263. /**
  30264. * Define the maximum distance the camera can see to.
  30265. * This is important to note that the depth buffer are not infinite and the further it end
  30266. * the more your scene might encounter depth fighting issue.
  30267. */
  30268. maxZ: number;
  30269. /**
  30270. * Define the default inertia of the camera.
  30271. * This helps giving a smooth feeling to the camera movement.
  30272. */
  30273. inertia: number;
  30274. /**
  30275. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30276. */
  30277. mode: number;
  30278. /**
  30279. * Define wether the camera is intermediate.
  30280. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30281. */
  30282. isIntermediate: boolean;
  30283. /**
  30284. * Define the viewport of the camera.
  30285. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30286. */
  30287. viewport: Viewport;
  30288. /**
  30289. * Restricts the camera to viewing objects with the same layerMask.
  30290. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30291. */
  30292. layerMask: number;
  30293. /**
  30294. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30295. */
  30296. fovMode: number;
  30297. /**
  30298. * Rig mode of the camera.
  30299. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30300. * This is normally controlled byt the camera themselves as internal use.
  30301. */
  30302. cameraRigMode: number;
  30303. /**
  30304. * Defines the distance between both "eyes" in case of a RIG
  30305. */
  30306. interaxialDistance: number;
  30307. /**
  30308. * Defines if stereoscopic rendering is done side by side or over under.
  30309. */
  30310. isStereoscopicSideBySide: boolean;
  30311. /**
  30312. * 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
  30313. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30314. * else in the scene.
  30315. */
  30316. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30317. /**
  30318. * When set, the camera will render to this render target instead of the default canvas
  30319. */
  30320. outputRenderTarget: Nullable<RenderTargetTexture>;
  30321. /**
  30322. * Observable triggered when the camera view matrix has changed.
  30323. */
  30324. onViewMatrixChangedObservable: Observable<Camera>;
  30325. /**
  30326. * Observable triggered when the camera Projection matrix has changed.
  30327. */
  30328. onProjectionMatrixChangedObservable: Observable<Camera>;
  30329. /**
  30330. * Observable triggered when the inputs have been processed.
  30331. */
  30332. onAfterCheckInputsObservable: Observable<Camera>;
  30333. /**
  30334. * Observable triggered when reset has been called and applied to the camera.
  30335. */
  30336. onRestoreStateObservable: Observable<Camera>;
  30337. /** @hidden */
  30338. _cameraRigParams: any;
  30339. /** @hidden */
  30340. _rigCameras: Camera[];
  30341. /** @hidden */
  30342. _rigPostProcess: Nullable<PostProcess>;
  30343. protected _webvrViewMatrix: Matrix;
  30344. /** @hidden */
  30345. _skipRendering: boolean;
  30346. /** @hidden */
  30347. _alternateCamera: Camera;
  30348. /** @hidden */
  30349. _projectionMatrix: Matrix;
  30350. /** @hidden */
  30351. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30352. /** @hidden */
  30353. _activeMeshes: SmartArray<AbstractMesh>;
  30354. protected _globalPosition: Vector3;
  30355. /** hidden */
  30356. _computedViewMatrix: Matrix;
  30357. private _doNotComputeProjectionMatrix;
  30358. private _transformMatrix;
  30359. private _frustumPlanes;
  30360. private _refreshFrustumPlanes;
  30361. private _storedFov;
  30362. private _stateStored;
  30363. /**
  30364. * Instantiates a new camera object.
  30365. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30366. * @see http://doc.babylonjs.com/features/cameras
  30367. * @param name Defines the name of the camera in the scene
  30368. * @param position Defines the position of the camera
  30369. * @param scene Defines the scene the camera belongs too
  30370. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30371. */
  30372. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30373. /**
  30374. * Store current camera state (fov, position, etc..)
  30375. * @returns the camera
  30376. */
  30377. storeState(): Camera;
  30378. /**
  30379. * Restores the camera state values if it has been stored. You must call storeState() first
  30380. */
  30381. protected _restoreStateValues(): boolean;
  30382. /**
  30383. * Restored camera state. You must call storeState() first.
  30384. * @returns true if restored and false otherwise
  30385. */
  30386. restoreState(): boolean;
  30387. /**
  30388. * Gets the class name of the camera.
  30389. * @returns the class name
  30390. */
  30391. getClassName(): string;
  30392. /** @hidden */
  30393. readonly _isCamera: boolean;
  30394. /**
  30395. * Gets a string representation of the camera useful for debug purpose.
  30396. * @param fullDetails Defines that a more verboe level of logging is required
  30397. * @returns the string representation
  30398. */
  30399. toString(fullDetails?: boolean): string;
  30400. /**
  30401. * Gets the current world space position of the camera.
  30402. */
  30403. readonly globalPosition: Vector3;
  30404. /**
  30405. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30406. * @returns the active meshe list
  30407. */
  30408. getActiveMeshes(): SmartArray<AbstractMesh>;
  30409. /**
  30410. * Check wether a mesh is part of the current active mesh list of the camera
  30411. * @param mesh Defines the mesh to check
  30412. * @returns true if active, false otherwise
  30413. */
  30414. isActiveMesh(mesh: Mesh): boolean;
  30415. /**
  30416. * Is this camera ready to be used/rendered
  30417. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30418. * @return true if the camera is ready
  30419. */
  30420. isReady(completeCheck?: boolean): boolean;
  30421. /** @hidden */
  30422. _initCache(): void;
  30423. /** @hidden */
  30424. _updateCache(ignoreParentClass?: boolean): void;
  30425. /** @hidden */
  30426. _isSynchronized(): boolean;
  30427. /** @hidden */
  30428. _isSynchronizedViewMatrix(): boolean;
  30429. /** @hidden */
  30430. _isSynchronizedProjectionMatrix(): boolean;
  30431. /**
  30432. * Attach the input controls to a specific dom element to get the input from.
  30433. * @param element Defines the element the controls should be listened from
  30434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30435. */
  30436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30437. /**
  30438. * Detach the current controls from the specified dom element.
  30439. * @param element Defines the element to stop listening the inputs from
  30440. */
  30441. detachControl(element: HTMLElement): void;
  30442. /**
  30443. * Update the camera state according to the different inputs gathered during the frame.
  30444. */
  30445. update(): void;
  30446. /** @hidden */
  30447. _checkInputs(): void;
  30448. /** @hidden */
  30449. readonly rigCameras: Camera[];
  30450. /**
  30451. * Gets the post process used by the rig cameras
  30452. */
  30453. readonly rigPostProcess: Nullable<PostProcess>;
  30454. /**
  30455. * Internal, gets the first post proces.
  30456. * @returns the first post process to be run on this camera.
  30457. */
  30458. _getFirstPostProcess(): Nullable<PostProcess>;
  30459. private _cascadePostProcessesToRigCams;
  30460. /**
  30461. * Attach a post process to the camera.
  30462. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30463. * @param postProcess The post process to attach to the camera
  30464. * @param insertAt The position of the post process in case several of them are in use in the scene
  30465. * @returns the position the post process has been inserted at
  30466. */
  30467. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30468. /**
  30469. * Detach a post process to the camera.
  30470. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30471. * @param postProcess The post process to detach from the camera
  30472. */
  30473. detachPostProcess(postProcess: PostProcess): void;
  30474. /**
  30475. * Gets the current world matrix of the camera
  30476. */
  30477. getWorldMatrix(): Matrix;
  30478. /** @hidden */
  30479. _getViewMatrix(): Matrix;
  30480. /**
  30481. * Gets the current view matrix of the camera.
  30482. * @param force forces the camera to recompute the matrix without looking at the cached state
  30483. * @returns the view matrix
  30484. */
  30485. getViewMatrix(force?: boolean): Matrix;
  30486. /**
  30487. * Freeze the projection matrix.
  30488. * It will prevent the cache check of the camera projection compute and can speed up perf
  30489. * if no parameter of the camera are meant to change
  30490. * @param projection Defines manually a projection if necessary
  30491. */
  30492. freezeProjectionMatrix(projection?: Matrix): void;
  30493. /**
  30494. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30495. */
  30496. unfreezeProjectionMatrix(): void;
  30497. /**
  30498. * Gets the current projection matrix of the camera.
  30499. * @param force forces the camera to recompute the matrix without looking at the cached state
  30500. * @returns the projection matrix
  30501. */
  30502. getProjectionMatrix(force?: boolean): Matrix;
  30503. /**
  30504. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30505. * @returns a Matrix
  30506. */
  30507. getTransformationMatrix(): Matrix;
  30508. private _updateFrustumPlanes;
  30509. /**
  30510. * Checks if a cullable object (mesh...) is in the camera frustum
  30511. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30512. * @param target The object to check
  30513. * @returns true if the object is in frustum otherwise false
  30514. */
  30515. isInFrustum(target: ICullable): boolean;
  30516. /**
  30517. * Checks if a cullable object (mesh...) is in the camera frustum
  30518. * Unlike isInFrustum this cheks the full bounding box
  30519. * @param target The object to check
  30520. * @returns true if the object is in frustum otherwise false
  30521. */
  30522. isCompletelyInFrustum(target: ICullable): boolean;
  30523. /**
  30524. * Gets a ray in the forward direction from the camera.
  30525. * @param length Defines the length of the ray to create
  30526. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30527. * @param origin Defines the start point of the ray which defaults to the camera position
  30528. * @returns the forward ray
  30529. */
  30530. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30531. /**
  30532. * Releases resources associated with this node.
  30533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30535. */
  30536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30537. /** @hidden */
  30538. _isLeftCamera: boolean;
  30539. /**
  30540. * Gets the left camera of a rig setup in case of Rigged Camera
  30541. */
  30542. readonly isLeftCamera: boolean;
  30543. /** @hidden */
  30544. _isRightCamera: boolean;
  30545. /**
  30546. * Gets the right camera of a rig setup in case of Rigged Camera
  30547. */
  30548. readonly isRightCamera: boolean;
  30549. /**
  30550. * Gets the left camera of a rig setup in case of Rigged Camera
  30551. */
  30552. readonly leftCamera: Nullable<FreeCamera>;
  30553. /**
  30554. * Gets the right camera of a rig setup in case of Rigged Camera
  30555. */
  30556. readonly rightCamera: Nullable<FreeCamera>;
  30557. /**
  30558. * Gets the left camera target of a rig setup in case of Rigged Camera
  30559. * @returns the target position
  30560. */
  30561. getLeftTarget(): Nullable<Vector3>;
  30562. /**
  30563. * Gets the right camera target of a rig setup in case of Rigged Camera
  30564. * @returns the target position
  30565. */
  30566. getRightTarget(): Nullable<Vector3>;
  30567. /**
  30568. * @hidden
  30569. */
  30570. setCameraRigMode(mode: number, rigParams: any): void;
  30571. /** @hidden */
  30572. static _setStereoscopicRigMode(camera: Camera): void;
  30573. /** @hidden */
  30574. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30575. /** @hidden */
  30576. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30577. /** @hidden */
  30578. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30579. /** @hidden */
  30580. _getVRProjectionMatrix(): Matrix;
  30581. protected _updateCameraRotationMatrix(): void;
  30582. protected _updateWebVRCameraRotationMatrix(): void;
  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. _getWebVRProjectionMatrix(): Matrix;
  30589. /**
  30590. * This function MUST be overwritten by the different WebVR cameras available.
  30591. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30592. * @hidden
  30593. */
  30594. _getWebVRViewMatrix(): Matrix;
  30595. /** @hidden */
  30596. setCameraRigParameter(name: string, value: any): void;
  30597. /**
  30598. * needs to be overridden by children so sub has required properties to be copied
  30599. * @hidden
  30600. */
  30601. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30602. /**
  30603. * May need to be overridden by children
  30604. * @hidden
  30605. */
  30606. _updateRigCameras(): void;
  30607. /** @hidden */
  30608. _setupInputs(): void;
  30609. /**
  30610. * Serialiaze the camera setup to a json represention
  30611. * @returns the JSON representation
  30612. */
  30613. serialize(): any;
  30614. /**
  30615. * Clones the current camera.
  30616. * @param name The cloned camera name
  30617. * @returns the cloned camera
  30618. */
  30619. clone(name: string): Camera;
  30620. /**
  30621. * Gets the direction of the camera relative to a given local axis.
  30622. * @param localAxis Defines the reference axis to provide a relative direction.
  30623. * @return the direction
  30624. */
  30625. getDirection(localAxis: Vector3): Vector3;
  30626. /**
  30627. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30628. * @param localAxis Defines the reference axis to provide a relative direction.
  30629. * @param result Defines the vector to store the result in
  30630. */
  30631. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30632. /**
  30633. * Gets a camera constructor for a given camera type
  30634. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30635. * @param name The name of the camera the result will be able to instantiate
  30636. * @param scene The scene the result will construct the camera in
  30637. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30638. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30639. * @returns a factory method to construc the camera
  30640. */
  30641. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30642. /**
  30643. * Compute the world matrix of the camera.
  30644. * @returns the camera workd matrix
  30645. */
  30646. computeWorldMatrix(): Matrix;
  30647. /**
  30648. * Parse a JSON and creates the camera from the parsed information
  30649. * @param parsedCamera The JSON to parse
  30650. * @param scene The scene to instantiate the camera in
  30651. * @returns the newly constructed camera
  30652. */
  30653. static Parse(parsedCamera: any, scene: Scene): Camera;
  30654. }
  30655. }
  30656. declare module "babylonjs/Misc/tools" {
  30657. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30658. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30659. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30660. import { Observable } from "babylonjs/Misc/observable";
  30661. import { DomManagement } from "babylonjs/Misc/domManagement";
  30662. import { Camera } from "babylonjs/Cameras/camera";
  30663. import { Engine } from "babylonjs/Engines/engine";
  30664. import { Animation } from "babylonjs/Animations/animation";
  30665. /**
  30666. * Interface for any object that can request an animation frame
  30667. */
  30668. export interface ICustomAnimationFrameRequester {
  30669. /**
  30670. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30671. */
  30672. renderFunction?: Function;
  30673. /**
  30674. * Called to request the next frame to render to
  30675. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30676. */
  30677. requestAnimationFrame: Function;
  30678. /**
  30679. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30680. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30681. */
  30682. requestID?: number;
  30683. }
  30684. /**
  30685. * Interface containing an array of animations
  30686. */
  30687. export interface IAnimatable {
  30688. /**
  30689. * Array of animations
  30690. */
  30691. animations: Array<Animation>;
  30692. }
  30693. /** Interface used by value gradients (color, factor, ...) */
  30694. export interface IValueGradient {
  30695. /**
  30696. * Gets or sets the gradient value (between 0 and 1)
  30697. */
  30698. gradient: number;
  30699. }
  30700. /** Class used to store color4 gradient */
  30701. export class ColorGradient implements IValueGradient {
  30702. /**
  30703. * Gets or sets the gradient value (between 0 and 1)
  30704. */
  30705. gradient: number;
  30706. /**
  30707. * Gets or sets first associated color
  30708. */
  30709. color1: Color4;
  30710. /**
  30711. * Gets or sets second associated color
  30712. */
  30713. color2?: Color4;
  30714. /**
  30715. * Will get a color picked randomly between color1 and color2.
  30716. * If color2 is undefined then color1 will be used
  30717. * @param result defines the target Color4 to store the result in
  30718. */
  30719. getColorToRef(result: Color4): void;
  30720. }
  30721. /** Class used to store color 3 gradient */
  30722. export class Color3Gradient implements IValueGradient {
  30723. /**
  30724. * Gets or sets the gradient value (between 0 and 1)
  30725. */
  30726. gradient: number;
  30727. /**
  30728. * Gets or sets the associated color
  30729. */
  30730. color: Color3;
  30731. }
  30732. /** Class used to store factor gradient */
  30733. export class FactorGradient implements IValueGradient {
  30734. /**
  30735. * Gets or sets the gradient value (between 0 and 1)
  30736. */
  30737. gradient: number;
  30738. /**
  30739. * Gets or sets first associated factor
  30740. */
  30741. factor1: number;
  30742. /**
  30743. * Gets or sets second associated factor
  30744. */
  30745. factor2?: number;
  30746. /**
  30747. * Will get a number picked randomly between factor1 and factor2.
  30748. * If factor2 is undefined then factor1 will be used
  30749. * @returns the picked number
  30750. */
  30751. getFactor(): number;
  30752. }
  30753. /**
  30754. * @ignore
  30755. * Application error to support additional information when loading a file
  30756. */
  30757. export class LoadFileError extends Error {
  30758. /** defines the optional XHR request */
  30759. request?: XMLHttpRequest | undefined;
  30760. private static _setPrototypeOf;
  30761. /**
  30762. * Creates a new LoadFileError
  30763. * @param message defines the message of the error
  30764. * @param request defines the optional XHR request
  30765. */
  30766. constructor(message: string,
  30767. /** defines the optional XHR request */
  30768. request?: XMLHttpRequest | undefined);
  30769. }
  30770. /**
  30771. * Class used to define a retry strategy when error happens while loading assets
  30772. */
  30773. export class RetryStrategy {
  30774. /**
  30775. * Function used to defines an exponential back off strategy
  30776. * @param maxRetries defines the maximum number of retries (3 by default)
  30777. * @param baseInterval defines the interval between retries
  30778. * @returns the strategy function to use
  30779. */
  30780. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30781. }
  30782. /**
  30783. * File request interface
  30784. */
  30785. export interface IFileRequest {
  30786. /**
  30787. * Raised when the request is complete (success or error).
  30788. */
  30789. onCompleteObservable: Observable<IFileRequest>;
  30790. /**
  30791. * Aborts the request for a file.
  30792. */
  30793. abort: () => void;
  30794. }
  30795. /**
  30796. * Class containing a set of static utilities functions
  30797. */
  30798. export class Tools {
  30799. /**
  30800. * Gets or sets the base URL to use to load assets
  30801. */
  30802. static BaseUrl: string;
  30803. /**
  30804. * Enable/Disable Custom HTTP Request Headers globally.
  30805. * default = false
  30806. * @see CustomRequestHeaders
  30807. */
  30808. static UseCustomRequestHeaders: boolean;
  30809. /**
  30810. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30811. * i.e. when loading files, where the server/service expects an Authorization header.
  30812. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30813. */
  30814. static CustomRequestHeaders: {
  30815. [key: string]: string;
  30816. };
  30817. /**
  30818. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30819. */
  30820. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30821. /**
  30822. * Default behaviour for cors in the application.
  30823. * It can be a string if the expected behavior is identical in the entire app.
  30824. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30825. */
  30826. static CorsBehavior: string | ((url: string | string[]) => string);
  30827. /**
  30828. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30829. * @ignorenaming
  30830. */
  30831. static UseFallbackTexture: boolean;
  30832. /**
  30833. * Use this object to register external classes like custom textures or material
  30834. * to allow the laoders to instantiate them
  30835. */
  30836. static RegisteredExternalClasses: {
  30837. [key: string]: Object;
  30838. };
  30839. /**
  30840. * Texture content used if a texture cannot loaded
  30841. * @ignorenaming
  30842. */
  30843. static fallbackTexture: string;
  30844. /**
  30845. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30846. * @param u defines the coordinate on X axis
  30847. * @param v defines the coordinate on Y axis
  30848. * @param width defines the width of the source data
  30849. * @param height defines the height of the source data
  30850. * @param pixels defines the source byte array
  30851. * @param color defines the output color
  30852. */
  30853. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30854. /**
  30855. * Interpolates between a and b via alpha
  30856. * @param a The lower value (returned when alpha = 0)
  30857. * @param b The upper value (returned when alpha = 1)
  30858. * @param alpha The interpolation-factor
  30859. * @return The mixed value
  30860. */
  30861. static Mix(a: number, b: number, alpha: number): number;
  30862. /**
  30863. * Tries to instantiate a new object from a given class name
  30864. * @param className defines the class name to instantiate
  30865. * @returns the new object or null if the system was not able to do the instantiation
  30866. */
  30867. static Instantiate(className: string): any;
  30868. /**
  30869. * Provides a slice function that will work even on IE
  30870. * @param data defines the array to slice
  30871. * @param start defines the start of the data (optional)
  30872. * @param end defines the end of the data (optional)
  30873. * @returns the new sliced array
  30874. */
  30875. static Slice<T>(data: T, start?: number, end?: number): T;
  30876. /**
  30877. * Polyfill for setImmediate
  30878. * @param action defines the action to execute after the current execution block
  30879. */
  30880. static SetImmediate(action: () => void): void;
  30881. /**
  30882. * Function indicating if a number is an exponent of 2
  30883. * @param value defines the value to test
  30884. * @returns true if the value is an exponent of 2
  30885. */
  30886. static IsExponentOfTwo(value: number): boolean;
  30887. private static _tmpFloatArray;
  30888. /**
  30889. * Returns the nearest 32-bit single precision float representation of a Number
  30890. * @param value A Number. If the parameter is of a different type, it will get converted
  30891. * to a number or to NaN if it cannot be converted
  30892. * @returns number
  30893. */
  30894. static FloatRound(value: number): number;
  30895. /**
  30896. * Find the next highest power of two.
  30897. * @param x Number to start search from.
  30898. * @return Next highest power of two.
  30899. */
  30900. static CeilingPOT(x: number): number;
  30901. /**
  30902. * Find the next lowest power of two.
  30903. * @param x Number to start search from.
  30904. * @return Next lowest power of two.
  30905. */
  30906. static FloorPOT(x: number): number;
  30907. /**
  30908. * Find the nearest power of two.
  30909. * @param x Number to start search from.
  30910. * @return Next nearest power of two.
  30911. */
  30912. static NearestPOT(x: number): number;
  30913. /**
  30914. * Get the closest exponent of two
  30915. * @param value defines the value to approximate
  30916. * @param max defines the maximum value to return
  30917. * @param mode defines how to define the closest value
  30918. * @returns closest exponent of two of the given value
  30919. */
  30920. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30921. /**
  30922. * Extracts the filename from a path
  30923. * @param path defines the path to use
  30924. * @returns the filename
  30925. */
  30926. static GetFilename(path: string): string;
  30927. /**
  30928. * Extracts the "folder" part of a path (everything before the filename).
  30929. * @param uri The URI to extract the info from
  30930. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30931. * @returns The "folder" part of the path
  30932. */
  30933. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30934. /**
  30935. * Extracts text content from a DOM element hierarchy
  30936. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30937. */
  30938. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30939. /**
  30940. * Convert an angle in radians to degrees
  30941. * @param angle defines the angle to convert
  30942. * @returns the angle in degrees
  30943. */
  30944. static ToDegrees(angle: number): number;
  30945. /**
  30946. * Convert an angle in degrees to radians
  30947. * @param angle defines the angle to convert
  30948. * @returns the angle in radians
  30949. */
  30950. static ToRadians(angle: number): number;
  30951. /**
  30952. * Encode a buffer to a base64 string
  30953. * @param buffer defines the buffer to encode
  30954. * @returns the encoded string
  30955. */
  30956. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30957. /**
  30958. * Extracts minimum and maximum values from a list of indexed positions
  30959. * @param positions defines the positions to use
  30960. * @param indices defines the indices to the positions
  30961. * @param indexStart defines the start index
  30962. * @param indexCount defines the end index
  30963. * @param bias defines bias value to add to the result
  30964. * @return minimum and maximum values
  30965. */
  30966. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30967. minimum: Vector3;
  30968. maximum: Vector3;
  30969. };
  30970. /**
  30971. * Extracts minimum and maximum values from a list of positions
  30972. * @param positions defines the positions to use
  30973. * @param start defines the start index in the positions array
  30974. * @param count defines the number of positions to handle
  30975. * @param bias defines bias value to add to the result
  30976. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30977. * @return minimum and maximum values
  30978. */
  30979. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30980. minimum: Vector3;
  30981. maximum: Vector3;
  30982. };
  30983. /**
  30984. * Returns an array if obj is not an array
  30985. * @param obj defines the object to evaluate as an array
  30986. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30987. * @returns either obj directly if obj is an array or a new array containing obj
  30988. */
  30989. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30990. /**
  30991. * Gets the pointer prefix to use
  30992. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30993. */
  30994. static GetPointerPrefix(): string;
  30995. /**
  30996. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30997. * @param func - the function to be called
  30998. * @param requester - the object that will request the next frame. Falls back to window.
  30999. * @returns frame number
  31000. */
  31001. static QueueNewFrame(func: () => void, requester?: any): number;
  31002. /**
  31003. * Ask the browser to promote the current element to fullscreen rendering mode
  31004. * @param element defines the DOM element to promote
  31005. */
  31006. static RequestFullscreen(element: HTMLElement): void;
  31007. /**
  31008. * Asks the browser to exit fullscreen mode
  31009. */
  31010. static ExitFullscreen(): void;
  31011. /**
  31012. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31013. * @param url define the url we are trying
  31014. * @param element define the dom element where to configure the cors policy
  31015. */
  31016. static SetCorsBehavior(url: string | string[], element: {
  31017. crossOrigin: string | null;
  31018. }): void;
  31019. /**
  31020. * Removes unwanted characters from an url
  31021. * @param url defines the url to clean
  31022. * @returns the cleaned url
  31023. */
  31024. static CleanUrl(url: string): string;
  31025. /**
  31026. * Gets or sets a function used to pre-process url before using them to load assets
  31027. */
  31028. static PreprocessUrl: (url: string) => string;
  31029. /**
  31030. * Loads an image as an HTMLImageElement.
  31031. * @param input url string, ArrayBuffer, or Blob to load
  31032. * @param onLoad callback called when the image successfully loads
  31033. * @param onError callback called when the image fails to load
  31034. * @param offlineProvider offline provider for caching
  31035. * @returns the HTMLImageElement of the loaded image
  31036. */
  31037. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31038. /**
  31039. * Loads a file
  31040. * @param url url string, ArrayBuffer, or Blob to load
  31041. * @param onSuccess callback called when the file successfully loads
  31042. * @param onProgress callback called while file is loading (if the server supports this mode)
  31043. * @param offlineProvider defines the offline provider for caching
  31044. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31045. * @param onError callback called when the file fails to load
  31046. * @returns a file request object
  31047. */
  31048. 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;
  31049. /**
  31050. * Load a script (identified by an url). When the url returns, the
  31051. * content of this file is added into a new script element, attached to the DOM (body element)
  31052. * @param scriptUrl defines the url of the script to laod
  31053. * @param onSuccess defines the callback called when the script is loaded
  31054. * @param onError defines the callback to call if an error occurs
  31055. */
  31056. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31057. /**
  31058. * Loads a file from a blob
  31059. * @param fileToLoad defines the blob to use
  31060. * @param callback defines the callback to call when data is loaded
  31061. * @param progressCallback defines the callback to call during loading process
  31062. * @returns a file request object
  31063. */
  31064. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31065. /**
  31066. * Loads a file
  31067. * @param fileToLoad defines the file to load
  31068. * @param callback defines the callback to call when data is loaded
  31069. * @param progressCallBack defines the callback to call during loading process
  31070. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31071. * @returns a file request object
  31072. */
  31073. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31074. /**
  31075. * Creates a data url from a given string content
  31076. * @param content defines the content to convert
  31077. * @returns the new data url link
  31078. */
  31079. static FileAsURL(content: string): string;
  31080. /**
  31081. * Format the given number to a specific decimal format
  31082. * @param value defines the number to format
  31083. * @param decimals defines the number of decimals to use
  31084. * @returns the formatted string
  31085. */
  31086. static Format(value: number, decimals?: number): string;
  31087. /**
  31088. * Checks if a given vector is inside a specific range
  31089. * @param v defines the vector to test
  31090. * @param min defines the minimum range
  31091. * @param max defines the maximum range
  31092. */
  31093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31094. /**
  31095. * Tries to copy an object by duplicating every property
  31096. * @param source defines the source object
  31097. * @param destination defines the target object
  31098. * @param doNotCopyList defines a list of properties to avoid
  31099. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31100. */
  31101. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31102. /**
  31103. * Gets a boolean indicating if the given object has no own property
  31104. * @param obj defines the object to test
  31105. * @returns true if object has no own property
  31106. */
  31107. static IsEmpty(obj: any): boolean;
  31108. /**
  31109. * Function used to register events at window level
  31110. * @param events defines the events to register
  31111. */
  31112. static RegisterTopRootEvents(events: {
  31113. name: string;
  31114. handler: Nullable<(e: FocusEvent) => any>;
  31115. }[]): void;
  31116. /**
  31117. * Function used to unregister events from window level
  31118. * @param events defines the events to unregister
  31119. */
  31120. static UnregisterTopRootEvents(events: {
  31121. name: string;
  31122. handler: Nullable<(e: FocusEvent) => any>;
  31123. }[]): void;
  31124. /**
  31125. * @ignore
  31126. */
  31127. static _ScreenshotCanvas: HTMLCanvasElement;
  31128. /**
  31129. * Dumps the current bound framebuffer
  31130. * @param width defines the rendering width
  31131. * @param height defines the rendering height
  31132. * @param engine defines the hosting engine
  31133. * @param successCallback defines the callback triggered once the data are available
  31134. * @param mimeType defines the mime type of the result
  31135. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31136. */
  31137. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31138. /**
  31139. * Converts the canvas data to blob.
  31140. * This acts as a polyfill for browsers not supporting the to blob function.
  31141. * @param canvas Defines the canvas to extract the data from
  31142. * @param successCallback Defines the callback triggered once the data are available
  31143. * @param mimeType Defines the mime type of the result
  31144. */
  31145. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31146. /**
  31147. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31148. * @param successCallback defines the callback triggered once the data are available
  31149. * @param mimeType defines the mime type of the result
  31150. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31151. */
  31152. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31153. /**
  31154. * Downloads a blob in the browser
  31155. * @param blob defines the blob to download
  31156. * @param fileName defines the name of the downloaded file
  31157. */
  31158. static Download(blob: Blob, fileName: string): void;
  31159. /**
  31160. * Captures a screenshot of the current rendering
  31161. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31162. * @param engine defines the rendering engine
  31163. * @param camera defines the source camera
  31164. * @param size This parameter can be set to a single number or to an object with the
  31165. * following (optional) properties: precision, width, height. If a single number is passed,
  31166. * it will be used for both width and height. If an object is passed, the screenshot size
  31167. * will be derived from the parameters. The precision property is a multiplier allowing
  31168. * rendering at a higher or lower resolution
  31169. * @param successCallback defines the callback receives a single parameter which contains the
  31170. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31171. * src parameter of an <img> to display it
  31172. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31173. * Check your browser for supported MIME types
  31174. */
  31175. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31176. /**
  31177. * Generates an image screenshot from the specified camera.
  31178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31179. * @param engine The engine to use for rendering
  31180. * @param camera The camera to use for rendering
  31181. * @param size This parameter can be set to a single number or to an object with the
  31182. * following (optional) properties: precision, width, height. If a single number is passed,
  31183. * it will be used for both width and height. If an object is passed, the screenshot size
  31184. * will be derived from the parameters. The precision property is a multiplier allowing
  31185. * rendering at a higher or lower resolution
  31186. * @param successCallback The callback receives a single parameter which contains the
  31187. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31188. * src parameter of an <img> to display it
  31189. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31190. * Check your browser for supported MIME types
  31191. * @param samples Texture samples (default: 1)
  31192. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31193. * @param fileName A name for for the downloaded file.
  31194. */
  31195. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31196. /**
  31197. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31198. * Be aware Math.random() could cause collisions, but:
  31199. * "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"
  31200. * @returns a pseudo random id
  31201. */
  31202. static RandomId(): string;
  31203. /**
  31204. * Test if the given uri is a base64 string
  31205. * @param uri The uri to test
  31206. * @return True if the uri is a base64 string or false otherwise
  31207. */
  31208. static IsBase64(uri: string): boolean;
  31209. /**
  31210. * Decode the given base64 uri.
  31211. * @param uri The uri to decode
  31212. * @return The decoded base64 data.
  31213. */
  31214. static DecodeBase64(uri: string): ArrayBuffer;
  31215. /**
  31216. * No log
  31217. */
  31218. static readonly NoneLogLevel: number;
  31219. /**
  31220. * Only message logs
  31221. */
  31222. static readonly MessageLogLevel: number;
  31223. /**
  31224. * Only warning logs
  31225. */
  31226. static readonly WarningLogLevel: number;
  31227. /**
  31228. * Only error logs
  31229. */
  31230. static readonly ErrorLogLevel: number;
  31231. /**
  31232. * All logs
  31233. */
  31234. static readonly AllLogLevel: number;
  31235. /**
  31236. * Gets a value indicating the number of loading errors
  31237. * @ignorenaming
  31238. */
  31239. static readonly errorsCount: number;
  31240. /**
  31241. * Callback called when a new log is added
  31242. */
  31243. static OnNewCacheEntry: (entry: string) => void;
  31244. /**
  31245. * Log a message to the console
  31246. * @param message defines the message to log
  31247. */
  31248. static Log(message: string): void;
  31249. /**
  31250. * Write a warning message to the console
  31251. * @param message defines the message to log
  31252. */
  31253. static Warn(message: string): void;
  31254. /**
  31255. * Write an error message to the console
  31256. * @param message defines the message to log
  31257. */
  31258. static Error(message: string): void;
  31259. /**
  31260. * Gets current log cache (list of logs)
  31261. */
  31262. static readonly LogCache: string;
  31263. /**
  31264. * Clears the log cache
  31265. */
  31266. static ClearLogCache(): void;
  31267. /**
  31268. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31269. */
  31270. static LogLevels: number;
  31271. /**
  31272. * Checks if the loaded document was accessed via `file:`-Protocol.
  31273. * @returns boolean
  31274. */
  31275. static IsFileURL(): boolean;
  31276. /**
  31277. * Checks if the window object exists
  31278. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31279. */
  31280. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31281. /**
  31282. * No performance log
  31283. */
  31284. static readonly PerformanceNoneLogLevel: number;
  31285. /**
  31286. * Use user marks to log performance
  31287. */
  31288. static readonly PerformanceUserMarkLogLevel: number;
  31289. /**
  31290. * Log performance to the console
  31291. */
  31292. static readonly PerformanceConsoleLogLevel: number;
  31293. private static _performance;
  31294. /**
  31295. * Sets the current performance log level
  31296. */
  31297. static PerformanceLogLevel: number;
  31298. private static _StartPerformanceCounterDisabled;
  31299. private static _EndPerformanceCounterDisabled;
  31300. private static _StartUserMark;
  31301. private static _EndUserMark;
  31302. private static _StartPerformanceConsole;
  31303. private static _EndPerformanceConsole;
  31304. /**
  31305. * Injects the @see CustomRequestHeaders into the given request
  31306. * @param request the request that should be used for injection
  31307. */
  31308. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31309. /**
  31310. * Starts a performance counter
  31311. */
  31312. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31313. /**
  31314. * Ends a specific performance coutner
  31315. */
  31316. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31317. /**
  31318. * Gets either window.performance.now() if supported or Date.now() else
  31319. */
  31320. static readonly Now: number;
  31321. /**
  31322. * This method will return the name of the class used to create the instance of the given object.
  31323. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31324. * @param object the object to get the class name from
  31325. * @param isType defines if the object is actually a type
  31326. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31327. */
  31328. static GetClassName(object: any, isType?: boolean): string;
  31329. /**
  31330. * Gets the first element of an array satisfying a given predicate
  31331. * @param array defines the array to browse
  31332. * @param predicate defines the predicate to use
  31333. * @returns null if not found or the element
  31334. */
  31335. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31336. /**
  31337. * This method will return the name of the full name of the class, including its owning module (if any).
  31338. * 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).
  31339. * @param object the object to get the class name from
  31340. * @param isType defines if the object is actually a type
  31341. * @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.
  31342. * @ignorenaming
  31343. */
  31344. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31345. /**
  31346. * Returns a promise that resolves after the given amount of time.
  31347. * @param delay Number of milliseconds to delay
  31348. * @returns Promise that resolves after the given amount of time
  31349. */
  31350. static DelayAsync(delay: number): Promise<void>;
  31351. /**
  31352. * Gets the current gradient from an array of IValueGradient
  31353. * @param ratio defines the current ratio to get
  31354. * @param gradients defines the array of IValueGradient
  31355. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31356. */
  31357. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31358. }
  31359. /**
  31360. * This class is used to track a performance counter which is number based.
  31361. * The user has access to many properties which give statistics of different nature.
  31362. *
  31363. * The implementer can track two kinds of Performance Counter: time and count.
  31364. * 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.
  31365. * 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.
  31366. */
  31367. export class PerfCounter {
  31368. /**
  31369. * Gets or sets a global boolean to turn on and off all the counters
  31370. */
  31371. static Enabled: boolean;
  31372. /**
  31373. * Returns the smallest value ever
  31374. */
  31375. readonly min: number;
  31376. /**
  31377. * Returns the biggest value ever
  31378. */
  31379. readonly max: number;
  31380. /**
  31381. * Returns the average value since the performance counter is running
  31382. */
  31383. readonly average: number;
  31384. /**
  31385. * Returns the average value of the last second the counter was monitored
  31386. */
  31387. readonly lastSecAverage: number;
  31388. /**
  31389. * Returns the current value
  31390. */
  31391. readonly current: number;
  31392. /**
  31393. * Gets the accumulated total
  31394. */
  31395. readonly total: number;
  31396. /**
  31397. * Gets the total value count
  31398. */
  31399. readonly count: number;
  31400. /**
  31401. * Creates a new counter
  31402. */
  31403. constructor();
  31404. /**
  31405. * Call this method to start monitoring a new frame.
  31406. * 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.
  31407. */
  31408. fetchNewFrame(): void;
  31409. /**
  31410. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31411. * @param newCount the count value to add to the monitored count
  31412. * @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.
  31413. */
  31414. addCount(newCount: number, fetchResult: boolean): void;
  31415. /**
  31416. * Start monitoring this performance counter
  31417. */
  31418. beginMonitoring(): void;
  31419. /**
  31420. * Compute the time lapsed since the previous beginMonitoring() call.
  31421. * @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
  31422. */
  31423. endMonitoring(newFrame?: boolean): void;
  31424. private _fetchResult;
  31425. private _startMonitoringTime;
  31426. private _min;
  31427. private _max;
  31428. private _average;
  31429. private _current;
  31430. private _totalValueCount;
  31431. private _totalAccumulated;
  31432. private _lastSecAverage;
  31433. private _lastSecAccumulated;
  31434. private _lastSecTime;
  31435. private _lastSecValueCount;
  31436. }
  31437. /**
  31438. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31439. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31440. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31441. * @param name The name of the class, case should be preserved
  31442. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31443. */
  31444. export function className(name: string, module?: string): (target: Object) => void;
  31445. /**
  31446. * An implementation of a loop for asynchronous functions.
  31447. */
  31448. export class AsyncLoop {
  31449. /**
  31450. * Defines the number of iterations for the loop
  31451. */
  31452. iterations: number;
  31453. /**
  31454. * Defines the current index of the loop.
  31455. */
  31456. index: number;
  31457. private _done;
  31458. private _fn;
  31459. private _successCallback;
  31460. /**
  31461. * Constructor.
  31462. * @param iterations the number of iterations.
  31463. * @param func the function to run each iteration
  31464. * @param successCallback the callback that will be called upon succesful execution
  31465. * @param offset starting offset.
  31466. */
  31467. constructor(
  31468. /**
  31469. * Defines the number of iterations for the loop
  31470. */
  31471. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31472. /**
  31473. * Execute the next iteration. Must be called after the last iteration was finished.
  31474. */
  31475. executeNext(): void;
  31476. /**
  31477. * Break the loop and run the success callback.
  31478. */
  31479. breakLoop(): void;
  31480. /**
  31481. * Create and run an async loop.
  31482. * @param iterations the number of iterations.
  31483. * @param fn the function to run each iteration
  31484. * @param successCallback the callback that will be called upon succesful execution
  31485. * @param offset starting offset.
  31486. * @returns the created async loop object
  31487. */
  31488. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31489. /**
  31490. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31491. * @param iterations total number of iterations
  31492. * @param syncedIterations number of synchronous iterations in each async iteration.
  31493. * @param fn the function to call each iteration.
  31494. * @param callback a success call back that will be called when iterating stops.
  31495. * @param breakFunction a break condition (optional)
  31496. * @param timeout timeout settings for the setTimeout function. default - 0.
  31497. * @returns the created async loop object
  31498. */
  31499. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31500. }
  31501. }
  31502. declare module "babylonjs/Collisions/collisionCoordinator" {
  31503. import { Nullable } from "babylonjs/types";
  31504. import { Scene } from "babylonjs/scene";
  31505. import { Vector3 } from "babylonjs/Maths/math";
  31506. import { Collider } from "babylonjs/Collisions/collider";
  31507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31508. /** @hidden */
  31509. export interface ICollisionCoordinator {
  31510. createCollider(): Collider;
  31511. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31512. init(scene: Scene): void;
  31513. }
  31514. /** @hidden */
  31515. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31516. private _scene;
  31517. private _scaledPosition;
  31518. private _scaledVelocity;
  31519. private _finalPosition;
  31520. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31521. createCollider(): Collider;
  31522. init(scene: Scene): void;
  31523. private _collideWithWorld;
  31524. }
  31525. }
  31526. declare module "babylonjs/Animations/animationGroup" {
  31527. import { Animatable } from "babylonjs/Animations/animatable";
  31528. import { Animation } from "babylonjs/Animations/animation";
  31529. import { Scene, IDisposable } from "babylonjs/scene";
  31530. import { Observable } from "babylonjs/Misc/observable";
  31531. import { Nullable } from "babylonjs/types";
  31532. /**
  31533. * This class defines the direct association between an animation and a target
  31534. */
  31535. export class TargetedAnimation {
  31536. /**
  31537. * Animation to perform
  31538. */
  31539. animation: Animation;
  31540. /**
  31541. * Target to animate
  31542. */
  31543. target: any;
  31544. }
  31545. /**
  31546. * Use this class to create coordinated animations on multiple targets
  31547. */
  31548. export class AnimationGroup implements IDisposable {
  31549. /** The name of the animation group */
  31550. name: string;
  31551. private _scene;
  31552. private _targetedAnimations;
  31553. private _animatables;
  31554. private _from;
  31555. private _to;
  31556. private _isStarted;
  31557. private _isPaused;
  31558. private _speedRatio;
  31559. /**
  31560. * Gets or sets the unique id of the node
  31561. */
  31562. uniqueId: number;
  31563. /**
  31564. * This observable will notify when one animation have ended
  31565. */
  31566. onAnimationEndObservable: Observable<TargetedAnimation>;
  31567. /**
  31568. * Observer raised when one animation loops
  31569. */
  31570. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31571. /**
  31572. * This observable will notify when all animations have ended.
  31573. */
  31574. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31575. /**
  31576. * This observable will notify when all animations have paused.
  31577. */
  31578. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31579. /**
  31580. * This observable will notify when all animations are playing.
  31581. */
  31582. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31583. /**
  31584. * Gets the first frame
  31585. */
  31586. readonly from: number;
  31587. /**
  31588. * Gets the last frame
  31589. */
  31590. readonly to: number;
  31591. /**
  31592. * Define if the animations are started
  31593. */
  31594. readonly isStarted: boolean;
  31595. /**
  31596. * Gets a value indicating that the current group is playing
  31597. */
  31598. readonly isPlaying: boolean;
  31599. /**
  31600. * Gets or sets the speed ratio to use for all animations
  31601. */
  31602. /**
  31603. * Gets or sets the speed ratio to use for all animations
  31604. */
  31605. speedRatio: number;
  31606. /**
  31607. * Gets the targeted animations for this animation group
  31608. */
  31609. readonly targetedAnimations: Array<TargetedAnimation>;
  31610. /**
  31611. * returning the list of animatables controlled by this animation group.
  31612. */
  31613. readonly animatables: Array<Animatable>;
  31614. /**
  31615. * Instantiates a new Animation Group.
  31616. * This helps managing several animations at once.
  31617. * @see http://doc.babylonjs.com/how_to/group
  31618. * @param name Defines the name of the group
  31619. * @param scene Defines the scene the group belongs to
  31620. */
  31621. constructor(
  31622. /** The name of the animation group */
  31623. name: string, scene?: Nullable<Scene>);
  31624. /**
  31625. * Add an animation (with its target) in the group
  31626. * @param animation defines the animation we want to add
  31627. * @param target defines the target of the animation
  31628. * @returns the TargetedAnimation object
  31629. */
  31630. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31631. /**
  31632. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31633. * It can add constant keys at begin or end
  31634. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31635. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31636. * @returns the animation group
  31637. */
  31638. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31639. /**
  31640. * Start all animations on given targets
  31641. * @param loop defines if animations must loop
  31642. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31643. * @param from defines the from key (optional)
  31644. * @param to defines the to key (optional)
  31645. * @returns the current animation group
  31646. */
  31647. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31648. /**
  31649. * Pause all animations
  31650. * @returns the animation group
  31651. */
  31652. pause(): AnimationGroup;
  31653. /**
  31654. * Play all animations to initial state
  31655. * This function will start() the animations if they were not started or will restart() them if they were paused
  31656. * @param loop defines if animations must loop
  31657. * @returns the animation group
  31658. */
  31659. play(loop?: boolean): AnimationGroup;
  31660. /**
  31661. * Reset all animations to initial state
  31662. * @returns the animation group
  31663. */
  31664. reset(): AnimationGroup;
  31665. /**
  31666. * Restart animations from key 0
  31667. * @returns the animation group
  31668. */
  31669. restart(): AnimationGroup;
  31670. /**
  31671. * Stop all animations
  31672. * @returns the animation group
  31673. */
  31674. stop(): AnimationGroup;
  31675. /**
  31676. * Set animation weight for all animatables
  31677. * @param weight defines the weight to use
  31678. * @return the animationGroup
  31679. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31680. */
  31681. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31682. /**
  31683. * Synchronize and normalize all animatables with a source animatable
  31684. * @param root defines the root animatable to synchronize with
  31685. * @return the animationGroup
  31686. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31687. */
  31688. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31689. /**
  31690. * Goes to a specific frame in this animation group
  31691. * @param frame the frame number to go to
  31692. * @return the animationGroup
  31693. */
  31694. goToFrame(frame: number): AnimationGroup;
  31695. /**
  31696. * Dispose all associated resources
  31697. */
  31698. dispose(): void;
  31699. private _checkAnimationGroupEnded;
  31700. /**
  31701. * Clone the current animation group and returns a copy
  31702. * @param newName defines the name of the new group
  31703. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31704. * @returns the new aniamtion group
  31705. */
  31706. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31707. /**
  31708. * Returns a new AnimationGroup object parsed from the source provided.
  31709. * @param parsedAnimationGroup defines the source
  31710. * @param scene defines the scene that will receive the animationGroup
  31711. * @returns a new AnimationGroup
  31712. */
  31713. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31714. /**
  31715. * Returns the string "AnimationGroup"
  31716. * @returns "AnimationGroup"
  31717. */
  31718. getClassName(): string;
  31719. /**
  31720. * Creates a detailled string about the object
  31721. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31722. * @returns a string representing the object
  31723. */
  31724. toString(fullDetails?: boolean): string;
  31725. }
  31726. }
  31727. declare module "babylonjs/scene" {
  31728. import { Nullable } from "babylonjs/types";
  31729. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31730. import { Observable } from "babylonjs/Misc/observable";
  31731. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31732. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31733. import { Geometry } from "babylonjs/Meshes/geometry";
  31734. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31735. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31737. import { Mesh } from "babylonjs/Meshes/mesh";
  31738. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31739. import { Bone } from "babylonjs/Bones/bone";
  31740. import { Skeleton } from "babylonjs/Bones/skeleton";
  31741. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31742. import { Camera } from "babylonjs/Cameras/camera";
  31743. import { AbstractScene } from "babylonjs/abstractScene";
  31744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31746. import { Material } from "babylonjs/Materials/material";
  31747. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31748. import { Effect } from "babylonjs/Materials/effect";
  31749. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31750. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31751. import { Light } from "babylonjs/Lights/light";
  31752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31753. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31754. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31755. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31757. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31758. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31759. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31760. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31761. import { Engine } from "babylonjs/Engines/engine";
  31762. import { Node } from "babylonjs/node";
  31763. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31764. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31765. import { Ray } from "babylonjs/Culling/ray";
  31766. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31767. import { Animation } from "babylonjs/Animations/animation";
  31768. import { Animatable } from "babylonjs/Animations/animatable";
  31769. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31770. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31771. import { Collider } from "babylonjs/Collisions/collider";
  31772. /**
  31773. * Define an interface for all classes that will hold resources
  31774. */
  31775. export interface IDisposable {
  31776. /**
  31777. * Releases all held resources
  31778. */
  31779. dispose(): void;
  31780. }
  31781. /** Interface defining initialization parameters for Scene class */
  31782. export interface SceneOptions {
  31783. /**
  31784. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31785. * It will improve performance when the number of geometries becomes important.
  31786. */
  31787. useGeometryUniqueIdsMap?: boolean;
  31788. /**
  31789. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31791. */
  31792. useMaterialMeshMap?: boolean;
  31793. /**
  31794. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31795. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31796. */
  31797. useClonedMeshhMap?: boolean;
  31798. }
  31799. /**
  31800. * Represents a scene to be rendered by the engine.
  31801. * @see http://doc.babylonjs.com/features/scene
  31802. */
  31803. export class Scene extends AbstractScene implements IAnimatable {
  31804. private static _uniqueIdCounter;
  31805. /** The fog is deactivated */
  31806. static readonly FOGMODE_NONE: number;
  31807. /** The fog density is following an exponential function */
  31808. static readonly FOGMODE_EXP: number;
  31809. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31810. static readonly FOGMODE_EXP2: number;
  31811. /** The fog density is following a linear function. */
  31812. static readonly FOGMODE_LINEAR: number;
  31813. /**
  31814. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31816. */
  31817. static MinDeltaTime: number;
  31818. /**
  31819. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31821. */
  31822. static MaxDeltaTime: number;
  31823. /**
  31824. * Factory used to create the default material.
  31825. * @param name The name of the material to create
  31826. * @param scene The scene to create the material for
  31827. * @returns The default material
  31828. */
  31829. static DefaultMaterialFactory(scene: Scene): Material;
  31830. /**
  31831. * Factory used to create the a collision coordinator.
  31832. * @returns The collision coordinator
  31833. */
  31834. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31835. /** @hidden */
  31836. readonly _isScene: boolean;
  31837. /**
  31838. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31839. */
  31840. autoClear: boolean;
  31841. /**
  31842. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31843. */
  31844. autoClearDepthAndStencil: boolean;
  31845. /**
  31846. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31847. */
  31848. clearColor: Color4;
  31849. /**
  31850. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31851. */
  31852. ambientColor: Color3;
  31853. /** @hidden */
  31854. _environmentBRDFTexture: BaseTexture;
  31855. /** @hidden */
  31856. protected _environmentTexture: Nullable<BaseTexture>;
  31857. /**
  31858. * Texture used in all pbr material as the reflection texture.
  31859. * As in the majority of the scene they are the same (exception for multi room and so on),
  31860. * this is easier to reference from here than from all the materials.
  31861. */
  31862. /**
  31863. * Texture used in all pbr material as the reflection texture.
  31864. * As in the majority of the scene they are the same (exception for multi room and so on),
  31865. * this is easier to set here than in all the materials.
  31866. */
  31867. environmentTexture: Nullable<BaseTexture>;
  31868. /** @hidden */
  31869. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31870. /**
  31871. * Default image processing configuration used either in the rendering
  31872. * Forward main pass or through the imageProcessingPostProcess if present.
  31873. * As in the majority of the scene they are the same (exception for multi camera),
  31874. * this is easier to reference from here than from all the materials and post process.
  31875. *
  31876. * No setter as we it is a shared configuration, you can set the values instead.
  31877. */
  31878. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31879. private _forceWireframe;
  31880. /**
  31881. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31882. */
  31883. forceWireframe: boolean;
  31884. private _forcePointsCloud;
  31885. /**
  31886. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31887. */
  31888. forcePointsCloud: boolean;
  31889. /**
  31890. * Gets or sets the active clipplane 1
  31891. */
  31892. clipPlane: Nullable<Plane>;
  31893. /**
  31894. * Gets or sets the active clipplane 2
  31895. */
  31896. clipPlane2: Nullable<Plane>;
  31897. /**
  31898. * Gets or sets the active clipplane 3
  31899. */
  31900. clipPlane3: Nullable<Plane>;
  31901. /**
  31902. * Gets or sets the active clipplane 4
  31903. */
  31904. clipPlane4: Nullable<Plane>;
  31905. /**
  31906. * Gets or sets a boolean indicating if animations are enabled
  31907. */
  31908. animationsEnabled: boolean;
  31909. private _animationPropertiesOverride;
  31910. /**
  31911. * Gets or sets the animation properties override
  31912. */
  31913. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31914. /**
  31915. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31916. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31917. */
  31918. useConstantAnimationDeltaTime: boolean;
  31919. /**
  31920. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31921. * Please note that it requires to run a ray cast through the scene on every frame
  31922. */
  31923. constantlyUpdateMeshUnderPointer: boolean;
  31924. /**
  31925. * Defines the HTML cursor to use when hovering over interactive elements
  31926. */
  31927. hoverCursor: string;
  31928. /**
  31929. * Defines the HTML default cursor to use (empty by default)
  31930. */
  31931. defaultCursor: string;
  31932. /**
  31933. * This is used to call preventDefault() on pointer down
  31934. * in order to block unwanted artifacts like system double clicks
  31935. */
  31936. preventDefaultOnPointerDown: boolean;
  31937. /**
  31938. * This is used to call preventDefault() on pointer up
  31939. * in order to block unwanted artifacts like system double clicks
  31940. */
  31941. preventDefaultOnPointerUp: boolean;
  31942. /**
  31943. * Gets or sets user defined metadata
  31944. */
  31945. metadata: any;
  31946. /**
  31947. * For internal use only. Please do not use.
  31948. */
  31949. reservedDataStore: any;
  31950. /**
  31951. * Gets the name of the plugin used to load this scene (null by default)
  31952. */
  31953. loadingPluginName: string;
  31954. /**
  31955. * Use this array to add regular expressions used to disable offline support for specific urls
  31956. */
  31957. disableOfflineSupportExceptionRules: RegExp[];
  31958. /**
  31959. * An event triggered when the scene is disposed.
  31960. */
  31961. onDisposeObservable: Observable<Scene>;
  31962. private _onDisposeObserver;
  31963. /** Sets a function to be executed when this scene is disposed. */
  31964. onDispose: () => void;
  31965. /**
  31966. * An event triggered before rendering the scene (right after animations and physics)
  31967. */
  31968. onBeforeRenderObservable: Observable<Scene>;
  31969. private _onBeforeRenderObserver;
  31970. /** Sets a function to be executed before rendering this scene */
  31971. beforeRender: Nullable<() => void>;
  31972. /**
  31973. * An event triggered after rendering the scene
  31974. */
  31975. onAfterRenderObservable: Observable<Scene>;
  31976. private _onAfterRenderObserver;
  31977. /** Sets a function to be executed after rendering this scene */
  31978. afterRender: Nullable<() => void>;
  31979. /**
  31980. * An event triggered before animating the scene
  31981. */
  31982. onBeforeAnimationsObservable: Observable<Scene>;
  31983. /**
  31984. * An event triggered after animations processing
  31985. */
  31986. onAfterAnimationsObservable: Observable<Scene>;
  31987. /**
  31988. * An event triggered before draw calls are ready to be sent
  31989. */
  31990. onBeforeDrawPhaseObservable: Observable<Scene>;
  31991. /**
  31992. * An event triggered after draw calls have been sent
  31993. */
  31994. onAfterDrawPhaseObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered when the scene is ready
  31997. */
  31998. onReadyObservable: Observable<Scene>;
  31999. /**
  32000. * An event triggered before rendering a camera
  32001. */
  32002. onBeforeCameraRenderObservable: Observable<Camera>;
  32003. private _onBeforeCameraRenderObserver;
  32004. /** Sets a function to be executed before rendering a camera*/
  32005. beforeCameraRender: () => void;
  32006. /**
  32007. * An event triggered after rendering a camera
  32008. */
  32009. onAfterCameraRenderObservable: Observable<Camera>;
  32010. private _onAfterCameraRenderObserver;
  32011. /** Sets a function to be executed after rendering a camera*/
  32012. afterCameraRender: () => void;
  32013. /**
  32014. * An event triggered when active meshes evaluation is about to start
  32015. */
  32016. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32017. /**
  32018. * An event triggered when active meshes evaluation is done
  32019. */
  32020. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32021. /**
  32022. * An event triggered when particles rendering is about to start
  32023. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32024. */
  32025. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32026. /**
  32027. * An event triggered when particles rendering is done
  32028. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32029. */
  32030. onAfterParticlesRenderingObservable: Observable<Scene>;
  32031. /**
  32032. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32033. */
  32034. onDataLoadedObservable: Observable<Scene>;
  32035. /**
  32036. * An event triggered when a camera is created
  32037. */
  32038. onNewCameraAddedObservable: Observable<Camera>;
  32039. /**
  32040. * An event triggered when a camera is removed
  32041. */
  32042. onCameraRemovedObservable: Observable<Camera>;
  32043. /**
  32044. * An event triggered when a light is created
  32045. */
  32046. onNewLightAddedObservable: Observable<Light>;
  32047. /**
  32048. * An event triggered when a light is removed
  32049. */
  32050. onLightRemovedObservable: Observable<Light>;
  32051. /**
  32052. * An event triggered when a geometry is created
  32053. */
  32054. onNewGeometryAddedObservable: Observable<Geometry>;
  32055. /**
  32056. * An event triggered when a geometry is removed
  32057. */
  32058. onGeometryRemovedObservable: Observable<Geometry>;
  32059. /**
  32060. * An event triggered when a transform node is created
  32061. */
  32062. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32063. /**
  32064. * An event triggered when a transform node is removed
  32065. */
  32066. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32067. /**
  32068. * An event triggered when a mesh is created
  32069. */
  32070. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32071. /**
  32072. * An event triggered when a mesh is removed
  32073. */
  32074. onMeshRemovedObservable: Observable<AbstractMesh>;
  32075. /**
  32076. * An event triggered when a material is created
  32077. */
  32078. onNewMaterialAddedObservable: Observable<Material>;
  32079. /**
  32080. * An event triggered when a material is removed
  32081. */
  32082. onMaterialRemovedObservable: Observable<Material>;
  32083. /**
  32084. * An event triggered when a texture is created
  32085. */
  32086. onNewTextureAddedObservable: Observable<BaseTexture>;
  32087. /**
  32088. * An event triggered when a texture is removed
  32089. */
  32090. onTextureRemovedObservable: Observable<BaseTexture>;
  32091. /**
  32092. * An event triggered when render targets are about to be rendered
  32093. * Can happen multiple times per frame.
  32094. */
  32095. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32096. /**
  32097. * An event triggered when render targets were rendered.
  32098. * Can happen multiple times per frame.
  32099. */
  32100. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32101. /**
  32102. * An event triggered before calculating deterministic simulation step
  32103. */
  32104. onBeforeStepObservable: Observable<Scene>;
  32105. /**
  32106. * An event triggered after calculating deterministic simulation step
  32107. */
  32108. onAfterStepObservable: Observable<Scene>;
  32109. /**
  32110. * An event triggered when the activeCamera property is updated
  32111. */
  32112. onActiveCameraChanged: Observable<Scene>;
  32113. /**
  32114. * This Observable will be triggered before 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. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32119. /**
  32120. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32121. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32122. * 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)
  32123. */
  32124. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32125. /**
  32126. * This Observable will when a mesh has been imported into the scene.
  32127. */
  32128. onMeshImportedObservable: Observable<AbstractMesh>;
  32129. /**
  32130. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32131. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32132. */
  32133. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32134. /** @hidden */
  32135. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32136. /**
  32137. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32138. */
  32139. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32140. /**
  32141. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32142. */
  32143. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32144. /**
  32145. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32146. */
  32147. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32148. private _onPointerMove;
  32149. private _onPointerDown;
  32150. private _onPointerUp;
  32151. /** Callback called when a pointer move is detected */
  32152. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32153. /** Callback called when a pointer down is detected */
  32154. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32155. /** Callback called when a pointer up is detected */
  32156. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32157. /** Callback called when a pointer pick is detected */
  32158. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32159. /**
  32160. * 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).
  32161. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32162. */
  32163. onPrePointerObservable: Observable<PointerInfoPre>;
  32164. /**
  32165. * Observable event triggered each time an input event is received from the rendering canvas
  32166. */
  32167. onPointerObservable: Observable<PointerInfo>;
  32168. /**
  32169. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32170. */
  32171. readonly unTranslatedPointer: Vector2;
  32172. /** The distance in pixel that you have to move to prevent some events */
  32173. static DragMovementThreshold: number;
  32174. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32175. static LongPressDelay: number;
  32176. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32177. static DoubleClickDelay: number;
  32178. /** If you need to check double click without raising a single click at first click, enable this flag */
  32179. static ExclusiveDoubleClickMode: boolean;
  32180. private _initClickEvent;
  32181. private _initActionManager;
  32182. private _delayedSimpleClick;
  32183. private _delayedSimpleClickTimeout;
  32184. private _previousDelayedSimpleClickTimeout;
  32185. private _meshPickProceed;
  32186. private _previousButtonPressed;
  32187. private _currentPickResult;
  32188. private _previousPickResult;
  32189. private _totalPointersPressed;
  32190. private _doubleClickOccured;
  32191. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32192. cameraToUseForPointers: Nullable<Camera>;
  32193. private _pointerX;
  32194. private _pointerY;
  32195. private _unTranslatedPointerX;
  32196. private _unTranslatedPointerY;
  32197. private _startingPointerPosition;
  32198. private _previousStartingPointerPosition;
  32199. private _startingPointerTime;
  32200. private _previousStartingPointerTime;
  32201. private _pointerCaptures;
  32202. private _timeAccumulator;
  32203. private _currentStepId;
  32204. private _currentInternalStep;
  32205. /** @hidden */
  32206. _mirroredCameraPosition: Nullable<Vector3>;
  32207. /**
  32208. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32209. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32210. */
  32211. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32212. /**
  32213. * Observable event triggered each time an keyboard event is received from the hosting window
  32214. */
  32215. onKeyboardObservable: Observable<KeyboardInfo>;
  32216. private _onKeyDown;
  32217. private _onKeyUp;
  32218. private _onCanvasFocusObserver;
  32219. private _onCanvasBlurObserver;
  32220. private _useRightHandedSystem;
  32221. /**
  32222. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32223. */
  32224. useRightHandedSystem: boolean;
  32225. /**
  32226. * Sets the step Id used by deterministic lock step
  32227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32228. * @param newStepId defines the step Id
  32229. */
  32230. setStepId(newStepId: number): void;
  32231. /**
  32232. * Gets the step Id used by deterministic lock step
  32233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32234. * @returns the step Id
  32235. */
  32236. getStepId(): number;
  32237. /**
  32238. * Gets the internal step used by deterministic lock step
  32239. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32240. * @returns the internal step
  32241. */
  32242. getInternalStep(): number;
  32243. private _fogEnabled;
  32244. /**
  32245. * Gets or sets a boolean indicating if fog is enabled on this scene
  32246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32247. * (Default is true)
  32248. */
  32249. fogEnabled: boolean;
  32250. private _fogMode;
  32251. /**
  32252. * Gets or sets the fog mode to use
  32253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32254. * | mode | value |
  32255. * | --- | --- |
  32256. * | FOGMODE_NONE | 0 |
  32257. * | FOGMODE_EXP | 1 |
  32258. * | FOGMODE_EXP2 | 2 |
  32259. * | FOGMODE_LINEAR | 3 |
  32260. */
  32261. fogMode: number;
  32262. /**
  32263. * Gets or sets the fog color to use
  32264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32265. * (Default is Color3(0.2, 0.2, 0.3))
  32266. */
  32267. fogColor: Color3;
  32268. /**
  32269. * Gets or sets the fog density to use
  32270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32271. * (Default is 0.1)
  32272. */
  32273. fogDensity: number;
  32274. /**
  32275. * Gets or sets the fog start distance to use
  32276. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32277. * (Default is 0)
  32278. */
  32279. fogStart: number;
  32280. /**
  32281. * Gets or sets the fog end distance to use
  32282. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32283. * (Default is 1000)
  32284. */
  32285. fogEnd: number;
  32286. private _shadowsEnabled;
  32287. /**
  32288. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32289. */
  32290. shadowsEnabled: boolean;
  32291. private _lightsEnabled;
  32292. /**
  32293. * Gets or sets a boolean indicating if lights are enabled on this scene
  32294. */
  32295. lightsEnabled: boolean;
  32296. /** All of the active cameras added to this scene. */
  32297. activeCameras: Camera[];
  32298. private _activeCamera;
  32299. /** Gets or sets the current active camera */
  32300. activeCamera: Nullable<Camera>;
  32301. private _defaultMaterial;
  32302. /** The default material used on meshes when no material is affected */
  32303. /** The default material used on meshes when no material is affected */
  32304. defaultMaterial: Material;
  32305. private _texturesEnabled;
  32306. /**
  32307. * Gets or sets a boolean indicating if textures are enabled on this scene
  32308. */
  32309. texturesEnabled: boolean;
  32310. /**
  32311. * Gets or sets a boolean indicating if particles are enabled on this scene
  32312. */
  32313. particlesEnabled: boolean;
  32314. /**
  32315. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32316. */
  32317. spritesEnabled: boolean;
  32318. private _skeletonsEnabled;
  32319. /**
  32320. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32321. */
  32322. skeletonsEnabled: boolean;
  32323. /**
  32324. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32325. */
  32326. lensFlaresEnabled: boolean;
  32327. /**
  32328. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32330. */
  32331. collisionsEnabled: boolean;
  32332. private _collisionCoordinator;
  32333. /** @hidden */
  32334. readonly collisionCoordinator: ICollisionCoordinator;
  32335. /**
  32336. * Defines the gravity applied to this scene (used only for collisions)
  32337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32338. */
  32339. gravity: Vector3;
  32340. /**
  32341. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32342. */
  32343. postProcessesEnabled: boolean;
  32344. /**
  32345. * The list of postprocesses added to the scene
  32346. */
  32347. postProcesses: PostProcess[];
  32348. /**
  32349. * Gets the current postprocess manager
  32350. */
  32351. postProcessManager: PostProcessManager;
  32352. /**
  32353. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32354. */
  32355. renderTargetsEnabled: boolean;
  32356. /**
  32357. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32358. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32359. */
  32360. dumpNextRenderTargets: boolean;
  32361. /**
  32362. * The list of user defined render targets added to the scene
  32363. */
  32364. customRenderTargets: RenderTargetTexture[];
  32365. /**
  32366. * Defines if texture loading must be delayed
  32367. * If true, textures will only be loaded when they need to be rendered
  32368. */
  32369. useDelayedTextureLoading: boolean;
  32370. /**
  32371. * Gets the list of meshes imported to the scene through SceneLoader
  32372. */
  32373. importedMeshesFiles: String[];
  32374. /**
  32375. * Gets or sets a boolean indicating if probes are enabled on this scene
  32376. */
  32377. probesEnabled: boolean;
  32378. /**
  32379. * Gets or sets the current offline provider to use to store scene data
  32380. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32381. */
  32382. offlineProvider: IOfflineProvider;
  32383. /**
  32384. * Gets or sets the action manager associated with the scene
  32385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32386. */
  32387. actionManager: AbstractActionManager;
  32388. private _meshesForIntersections;
  32389. /**
  32390. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32391. */
  32392. proceduralTexturesEnabled: boolean;
  32393. private _engine;
  32394. private _totalVertices;
  32395. /** @hidden */
  32396. _activeIndices: PerfCounter;
  32397. /** @hidden */
  32398. _activeParticles: PerfCounter;
  32399. /** @hidden */
  32400. _activeBones: PerfCounter;
  32401. private _animationRatio;
  32402. /** @hidden */
  32403. _animationTimeLast: number;
  32404. /** @hidden */
  32405. _animationTime: number;
  32406. /**
  32407. * Gets or sets a general scale for animation speed
  32408. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32409. */
  32410. animationTimeScale: number;
  32411. /** @hidden */
  32412. _cachedMaterial: Nullable<Material>;
  32413. /** @hidden */
  32414. _cachedEffect: Nullable<Effect>;
  32415. /** @hidden */
  32416. _cachedVisibility: Nullable<number>;
  32417. private _renderId;
  32418. private _frameId;
  32419. private _executeWhenReadyTimeoutId;
  32420. private _intermediateRendering;
  32421. private _viewUpdateFlag;
  32422. private _projectionUpdateFlag;
  32423. private _alternateViewUpdateFlag;
  32424. private _alternateProjectionUpdateFlag;
  32425. /** @hidden */
  32426. _toBeDisposed: Nullable<IDisposable>[];
  32427. private _activeRequests;
  32428. /** @hidden */
  32429. _pendingData: any[];
  32430. private _isDisposed;
  32431. /**
  32432. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32433. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32434. */
  32435. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32436. private _activeMeshes;
  32437. private _processedMaterials;
  32438. private _renderTargets;
  32439. /** @hidden */
  32440. _activeParticleSystems: SmartArray<IParticleSystem>;
  32441. private _activeSkeletons;
  32442. private _softwareSkinnedMeshes;
  32443. private _renderingManager;
  32444. /** @hidden */
  32445. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32446. private _transformMatrix;
  32447. private _sceneUbo;
  32448. private _alternateSceneUbo;
  32449. private _viewMatrix;
  32450. private _projectionMatrix;
  32451. private _alternateViewMatrix;
  32452. private _alternateProjectionMatrix;
  32453. private _alternateTransformMatrix;
  32454. private _useAlternateCameraConfiguration;
  32455. private _alternateRendering;
  32456. private _wheelEventName;
  32457. /** @hidden */
  32458. _forcedViewPosition: Nullable<Vector3>;
  32459. /** @hidden */
  32460. readonly _isAlternateRenderingEnabled: boolean;
  32461. private _frustumPlanes;
  32462. /**
  32463. * Gets the list of frustum planes (built from the active camera)
  32464. */
  32465. readonly frustumPlanes: Plane[];
  32466. /**
  32467. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32468. * This is useful if there are more lights that the maximum simulteanous authorized
  32469. */
  32470. requireLightSorting: boolean;
  32471. /** @hidden */
  32472. readonly useMaterialMeshMap: boolean;
  32473. /** @hidden */
  32474. readonly useClonedMeshhMap: boolean;
  32475. private _pointerOverMesh;
  32476. private _pickedDownMesh;
  32477. private _pickedUpMesh;
  32478. private _externalData;
  32479. private _uid;
  32480. /**
  32481. * @hidden
  32482. * Backing store of defined scene components.
  32483. */
  32484. _components: ISceneComponent[];
  32485. /**
  32486. * @hidden
  32487. * Backing store of defined scene components.
  32488. */
  32489. _serializableComponents: ISceneSerializableComponent[];
  32490. /**
  32491. * List of components to register on the next registration step.
  32492. */
  32493. private _transientComponents;
  32494. /**
  32495. * Registers the transient components if needed.
  32496. */
  32497. private _registerTransientComponents;
  32498. /**
  32499. * @hidden
  32500. * Add a component to the scene.
  32501. * Note that the ccomponent could be registered on th next frame if this is called after
  32502. * the register component stage.
  32503. * @param component Defines the component to add to the scene
  32504. */
  32505. _addComponent(component: ISceneComponent): void;
  32506. /**
  32507. * @hidden
  32508. * Gets a component from the scene.
  32509. * @param name defines the name of the component to retrieve
  32510. * @returns the component or null if not present
  32511. */
  32512. _getComponent(name: string): Nullable<ISceneComponent>;
  32513. /**
  32514. * @hidden
  32515. * Defines the actions happening before camera updates.
  32516. */
  32517. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32518. /**
  32519. * @hidden
  32520. * Defines the actions happening before clear the canvas.
  32521. */
  32522. _beforeClearStage: Stage<SimpleStageAction>;
  32523. /**
  32524. * @hidden
  32525. * Defines the actions when collecting render targets for the frame.
  32526. */
  32527. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32528. /**
  32529. * @hidden
  32530. * Defines the actions happening for one camera in the frame.
  32531. */
  32532. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32533. /**
  32534. * @hidden
  32535. * Defines the actions happening during the per mesh ready checks.
  32536. */
  32537. _isReadyForMeshStage: Stage<MeshStageAction>;
  32538. /**
  32539. * @hidden
  32540. * Defines the actions happening before evaluate active mesh checks.
  32541. */
  32542. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32543. /**
  32544. * @hidden
  32545. * Defines the actions happening during the evaluate sub mesh checks.
  32546. */
  32547. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32548. /**
  32549. * @hidden
  32550. * Defines the actions happening during the active mesh stage.
  32551. */
  32552. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32553. /**
  32554. * @hidden
  32555. * Defines the actions happening during the per camera render target step.
  32556. */
  32557. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32558. /**
  32559. * @hidden
  32560. * Defines the actions happening just before the active camera is drawing.
  32561. */
  32562. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32563. /**
  32564. * @hidden
  32565. * Defines the actions happening just before a render target is drawing.
  32566. */
  32567. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32568. /**
  32569. * @hidden
  32570. * Defines the actions happening just before a rendering group is drawing.
  32571. */
  32572. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32573. /**
  32574. * @hidden
  32575. * Defines the actions happening just before a mesh is drawing.
  32576. */
  32577. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32578. /**
  32579. * @hidden
  32580. * Defines the actions happening just after a mesh has been drawn.
  32581. */
  32582. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32583. /**
  32584. * @hidden
  32585. * Defines the actions happening just after a rendering group has been drawn.
  32586. */
  32587. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32588. /**
  32589. * @hidden
  32590. * Defines the actions happening just after the active camera has been drawn.
  32591. */
  32592. _afterCameraDrawStage: Stage<CameraStageAction>;
  32593. /**
  32594. * @hidden
  32595. * Defines the actions happening just after a render target has been drawn.
  32596. */
  32597. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32598. /**
  32599. * @hidden
  32600. * Defines the actions happening just after rendering all cameras and computing intersections.
  32601. */
  32602. _afterRenderStage: Stage<SimpleStageAction>;
  32603. /**
  32604. * @hidden
  32605. * Defines the actions happening when a pointer move event happens.
  32606. */
  32607. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32608. /**
  32609. * @hidden
  32610. * Defines the actions happening when a pointer down event happens.
  32611. */
  32612. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32613. /**
  32614. * @hidden
  32615. * Defines the actions happening when a pointer up event happens.
  32616. */
  32617. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32618. /**
  32619. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32620. */
  32621. private geometriesByUniqueId;
  32622. /**
  32623. * Creates a new Scene
  32624. * @param engine defines the engine to use to render this scene
  32625. * @param options defines the scene options
  32626. */
  32627. constructor(engine: Engine, options?: SceneOptions);
  32628. private _defaultMeshCandidates;
  32629. /**
  32630. * @hidden
  32631. */
  32632. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32633. private _defaultSubMeshCandidates;
  32634. /**
  32635. * @hidden
  32636. */
  32637. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32638. /**
  32639. * Sets the default candidate providers for the scene.
  32640. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32641. * and getCollidingSubMeshCandidates to their default function
  32642. */
  32643. setDefaultCandidateProviders(): void;
  32644. /**
  32645. * Gets the mesh that is currently under the pointer
  32646. */
  32647. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32648. /**
  32649. * Gets or sets the current on-screen X position of the pointer
  32650. */
  32651. pointerX: number;
  32652. /**
  32653. * Gets or sets the current on-screen Y position of the pointer
  32654. */
  32655. pointerY: number;
  32656. /**
  32657. * Gets the cached material (ie. the latest rendered one)
  32658. * @returns the cached material
  32659. */
  32660. getCachedMaterial(): Nullable<Material>;
  32661. /**
  32662. * Gets the cached effect (ie. the latest rendered one)
  32663. * @returns the cached effect
  32664. */
  32665. getCachedEffect(): Nullable<Effect>;
  32666. /**
  32667. * Gets the cached visibility state (ie. the latest rendered one)
  32668. * @returns the cached visibility state
  32669. */
  32670. getCachedVisibility(): Nullable<number>;
  32671. /**
  32672. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32673. * @param material defines the current material
  32674. * @param effect defines the current effect
  32675. * @param visibility defines the current visibility state
  32676. * @returns true if one parameter is not cached
  32677. */
  32678. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32679. /**
  32680. * Gets the engine associated with the scene
  32681. * @returns an Engine
  32682. */
  32683. getEngine(): Engine;
  32684. /**
  32685. * Gets the total number of vertices rendered per frame
  32686. * @returns the total number of vertices rendered per frame
  32687. */
  32688. getTotalVertices(): number;
  32689. /**
  32690. * Gets the performance counter for total vertices
  32691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32692. */
  32693. readonly totalVerticesPerfCounter: PerfCounter;
  32694. /**
  32695. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32696. * @returns the total number of active indices rendered per frame
  32697. */
  32698. getActiveIndices(): number;
  32699. /**
  32700. * Gets the performance counter for active indices
  32701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32702. */
  32703. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32704. /**
  32705. * Gets the total number of active particles rendered per frame
  32706. * @returns the total number of active particles rendered per frame
  32707. */
  32708. getActiveParticles(): number;
  32709. /**
  32710. * Gets the performance counter for active particles
  32711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32712. */
  32713. readonly activeParticlesPerfCounter: PerfCounter;
  32714. /**
  32715. * Gets the total number of active bones rendered per frame
  32716. * @returns the total number of active bones rendered per frame
  32717. */
  32718. getActiveBones(): number;
  32719. /**
  32720. * Gets the performance counter for active bones
  32721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32722. */
  32723. readonly activeBonesPerfCounter: PerfCounter;
  32724. /**
  32725. * Gets the array of active meshes
  32726. * @returns an array of AbstractMesh
  32727. */
  32728. getActiveMeshes(): SmartArray<AbstractMesh>;
  32729. /**
  32730. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32731. * @returns a number
  32732. */
  32733. getAnimationRatio(): number;
  32734. /**
  32735. * Gets an unique Id for the current render phase
  32736. * @returns a number
  32737. */
  32738. getRenderId(): number;
  32739. /**
  32740. * Gets an unique Id for the current frame
  32741. * @returns a number
  32742. */
  32743. getFrameId(): number;
  32744. /** Call this function if you want to manually increment the render Id*/
  32745. incrementRenderId(): void;
  32746. private _updatePointerPosition;
  32747. private _createUbo;
  32748. private _createAlternateUbo;
  32749. private _setRayOnPointerInfo;
  32750. /**
  32751. * Use this method to simulate a pointer move on a mesh
  32752. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32753. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32754. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32755. * @returns the current scene
  32756. */
  32757. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32758. private _processPointerMove;
  32759. private _checkPrePointerObservable;
  32760. /**
  32761. * Use this method to simulate a pointer down on a mesh
  32762. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32763. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32764. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32765. * @returns the current scene
  32766. */
  32767. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32768. private _processPointerDown;
  32769. /**
  32770. * Use this method to simulate a pointer up on a mesh
  32771. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32772. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32773. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32774. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32775. * @returns the current scene
  32776. */
  32777. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32778. private _processPointerUp;
  32779. /**
  32780. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32781. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32782. * @returns true if the pointer was captured
  32783. */
  32784. isPointerCaptured(pointerId?: number): boolean;
  32785. /** @hidden */
  32786. _isPointerSwiping(): boolean;
  32787. /**
  32788. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32789. * @param attachUp defines if you want to attach events to pointerup
  32790. * @param attachDown defines if you want to attach events to pointerdown
  32791. * @param attachMove defines if you want to attach events to pointermove
  32792. */
  32793. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32794. /** Detaches all event handlers*/
  32795. detachControl(): void;
  32796. /**
  32797. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32798. * Delay loaded resources are not taking in account
  32799. * @return true if all required resources are ready
  32800. */
  32801. isReady(): boolean;
  32802. /** Resets all cached information relative to material (including effect and visibility) */
  32803. resetCachedMaterial(): void;
  32804. /**
  32805. * Registers a function to be called before every frame render
  32806. * @param func defines the function to register
  32807. */
  32808. registerBeforeRender(func: () => void): void;
  32809. /**
  32810. * Unregisters a function called before every frame render
  32811. * @param func defines the function to unregister
  32812. */
  32813. unregisterBeforeRender(func: () => void): void;
  32814. /**
  32815. * Registers a function to be called after every frame render
  32816. * @param func defines the function to register
  32817. */
  32818. registerAfterRender(func: () => void): void;
  32819. /**
  32820. * Unregisters a function called after every frame render
  32821. * @param func defines the function to unregister
  32822. */
  32823. unregisterAfterRender(func: () => void): void;
  32824. private _executeOnceBeforeRender;
  32825. /**
  32826. * The provided function will run before render once and will be disposed afterwards.
  32827. * A timeout delay can be provided so that the function will be executed in N ms.
  32828. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32829. * @param func The function to be executed.
  32830. * @param timeout optional delay in ms
  32831. */
  32832. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32833. /** @hidden */
  32834. _addPendingData(data: any): void;
  32835. /** @hidden */
  32836. _removePendingData(data: any): void;
  32837. /**
  32838. * Returns the number of items waiting to be loaded
  32839. * @returns the number of items waiting to be loaded
  32840. */
  32841. getWaitingItemsCount(): number;
  32842. /**
  32843. * Returns a boolean indicating if the scene is still loading data
  32844. */
  32845. readonly isLoading: boolean;
  32846. /**
  32847. * Registers a function to be executed when the scene is ready
  32848. * @param {Function} func - the function to be executed
  32849. */
  32850. executeWhenReady(func: () => void): void;
  32851. /**
  32852. * Returns a promise that resolves when the scene is ready
  32853. * @returns A promise that resolves when the scene is ready
  32854. */
  32855. whenReadyAsync(): Promise<void>;
  32856. /** @hidden */
  32857. _checkIsReady(): void;
  32858. /**
  32859. * Gets all animatable attached to the scene
  32860. */
  32861. readonly animatables: Animatable[];
  32862. /**
  32863. * Resets the last animation time frame.
  32864. * Useful to override when animations start running when loading a scene for the first time.
  32865. */
  32866. resetLastAnimationTimeFrame(): void;
  32867. /** @hidden */
  32868. _switchToAlternateCameraConfiguration(active: boolean): void;
  32869. /**
  32870. * Gets the current view matrix
  32871. * @returns a Matrix
  32872. */
  32873. getViewMatrix(): Matrix;
  32874. /**
  32875. * Gets the current projection matrix
  32876. * @returns a Matrix
  32877. */
  32878. getProjectionMatrix(): Matrix;
  32879. /**
  32880. * Gets the current transform matrix
  32881. * @returns a Matrix made of View * Projection
  32882. */
  32883. getTransformMatrix(): Matrix;
  32884. /**
  32885. * Sets the current transform matrix
  32886. * @param view defines the View matrix to use
  32887. * @param projection defines the Projection matrix to use
  32888. */
  32889. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32890. /** @hidden */
  32891. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32892. /**
  32893. * Gets the uniform buffer used to store scene data
  32894. * @returns a UniformBuffer
  32895. */
  32896. getSceneUniformBuffer(): UniformBuffer;
  32897. /**
  32898. * Gets an unique (relatively to the current scene) Id
  32899. * @returns an unique number for the scene
  32900. */
  32901. getUniqueId(): number;
  32902. /**
  32903. * Add a mesh to the list of scene's meshes
  32904. * @param newMesh defines the mesh to add
  32905. * @param recursive if all child meshes should also be added to the scene
  32906. */
  32907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32908. /**
  32909. * Remove a mesh for the list of scene's meshes
  32910. * @param toRemove defines the mesh to remove
  32911. * @param recursive if all child meshes should also be removed from the scene
  32912. * @returns the index where the mesh was in the mesh list
  32913. */
  32914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32915. /**
  32916. * Add a transform node to the list of scene's transform nodes
  32917. * @param newTransformNode defines the transform node to add
  32918. */
  32919. addTransformNode(newTransformNode: TransformNode): void;
  32920. /**
  32921. * Remove a transform node for the list of scene's transform nodes
  32922. * @param toRemove defines the transform node to remove
  32923. * @returns the index where the transform node was in the transform node list
  32924. */
  32925. removeTransformNode(toRemove: TransformNode): number;
  32926. /**
  32927. * Remove a skeleton for the list of scene's skeletons
  32928. * @param toRemove defines the skeleton to remove
  32929. * @returns the index where the skeleton was in the skeleton list
  32930. */
  32931. removeSkeleton(toRemove: Skeleton): number;
  32932. /**
  32933. * Remove a morph target for the list of scene's morph targets
  32934. * @param toRemove defines the morph target to remove
  32935. * @returns the index where the morph target was in the morph target list
  32936. */
  32937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32938. /**
  32939. * Remove a light for the list of scene's lights
  32940. * @param toRemove defines the light to remove
  32941. * @returns the index where the light was in the light list
  32942. */
  32943. removeLight(toRemove: Light): number;
  32944. /**
  32945. * Remove a camera for the list of scene's cameras
  32946. * @param toRemove defines the camera to remove
  32947. * @returns the index where the camera was in the camera list
  32948. */
  32949. removeCamera(toRemove: Camera): number;
  32950. /**
  32951. * Remove a particle system for the list of scene's particle systems
  32952. * @param toRemove defines the particle system to remove
  32953. * @returns the index where the particle system was in the particle system list
  32954. */
  32955. removeParticleSystem(toRemove: IParticleSystem): number;
  32956. /**
  32957. * Remove a animation for the list of scene's animations
  32958. * @param toRemove defines the animation to remove
  32959. * @returns the index where the animation was in the animation list
  32960. */
  32961. removeAnimation(toRemove: Animation): number;
  32962. /**
  32963. * Removes the given animation group from this scene.
  32964. * @param toRemove The animation group to remove
  32965. * @returns The index of the removed animation group
  32966. */
  32967. removeAnimationGroup(toRemove: AnimationGroup): number;
  32968. /**
  32969. * Removes the given multi-material from this scene.
  32970. * @param toRemove The multi-material to remove
  32971. * @returns The index of the removed multi-material
  32972. */
  32973. removeMultiMaterial(toRemove: MultiMaterial): number;
  32974. /**
  32975. * Removes the given material from this scene.
  32976. * @param toRemove The material to remove
  32977. * @returns The index of the removed material
  32978. */
  32979. removeMaterial(toRemove: Material): number;
  32980. /**
  32981. * Removes the given action manager from this scene.
  32982. * @param toRemove The action manager to remove
  32983. * @returns The index of the removed action manager
  32984. */
  32985. removeActionManager(toRemove: AbstractActionManager): number;
  32986. /**
  32987. * Removes the given texture from this scene.
  32988. * @param toRemove The texture to remove
  32989. * @returns The index of the removed texture
  32990. */
  32991. removeTexture(toRemove: BaseTexture): number;
  32992. /**
  32993. * Adds the given light to this scene
  32994. * @param newLight The light to add
  32995. */
  32996. addLight(newLight: Light): void;
  32997. /**
  32998. * Sorts the list list based on light priorities
  32999. */
  33000. sortLightsByPriority(): void;
  33001. /**
  33002. * Adds the given camera to this scene
  33003. * @param newCamera The camera to add
  33004. */
  33005. addCamera(newCamera: Camera): void;
  33006. /**
  33007. * Adds the given skeleton to this scene
  33008. * @param newSkeleton The skeleton to add
  33009. */
  33010. addSkeleton(newSkeleton: Skeleton): void;
  33011. /**
  33012. * Adds the given particle system to this scene
  33013. * @param newParticleSystem The particle system to add
  33014. */
  33015. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33016. /**
  33017. * Adds the given animation to this scene
  33018. * @param newAnimation The animation to add
  33019. */
  33020. addAnimation(newAnimation: Animation): void;
  33021. /**
  33022. * Adds the given animation group to this scene.
  33023. * @param newAnimationGroup The animation group to add
  33024. */
  33025. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33026. /**
  33027. * Adds the given multi-material to this scene
  33028. * @param newMultiMaterial The multi-material to add
  33029. */
  33030. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33031. /**
  33032. * Adds the given material to this scene
  33033. * @param newMaterial The material to add
  33034. */
  33035. addMaterial(newMaterial: Material): void;
  33036. /**
  33037. * Adds the given morph target to this scene
  33038. * @param newMorphTargetManager The morph target to add
  33039. */
  33040. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33041. /**
  33042. * Adds the given geometry to this scene
  33043. * @param newGeometry The geometry to add
  33044. */
  33045. addGeometry(newGeometry: Geometry): void;
  33046. /**
  33047. * Adds the given action manager to this scene
  33048. * @param newActionManager The action manager to add
  33049. */
  33050. addActionManager(newActionManager: AbstractActionManager): void;
  33051. /**
  33052. * Adds the given texture to this scene.
  33053. * @param newTexture The texture to add
  33054. */
  33055. addTexture(newTexture: BaseTexture): void;
  33056. /**
  33057. * Switch active camera
  33058. * @param newCamera defines the new active camera
  33059. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33060. */
  33061. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33062. /**
  33063. * sets the active camera of the scene using its ID
  33064. * @param id defines the camera's ID
  33065. * @return the new active camera or null if none found.
  33066. */
  33067. setActiveCameraByID(id: string): Nullable<Camera>;
  33068. /**
  33069. * sets the active camera of the scene using its name
  33070. * @param name defines the camera's name
  33071. * @returns the new active camera or null if none found.
  33072. */
  33073. setActiveCameraByName(name: string): Nullable<Camera>;
  33074. /**
  33075. * get an animation group using its name
  33076. * @param name defines the material's name
  33077. * @return the animation group or null if none found.
  33078. */
  33079. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33080. /**
  33081. * get a material using its id
  33082. * @param id defines the material's ID
  33083. * @return the material or null if none found.
  33084. */
  33085. getMaterialByID(id: string): Nullable<Material>;
  33086. /**
  33087. * Gets a material using its name
  33088. * @param name defines the material's name
  33089. * @return the material or null if none found.
  33090. */
  33091. getMaterialByName(name: string): Nullable<Material>;
  33092. /**
  33093. * Gets a camera using its id
  33094. * @param id defines the id to look for
  33095. * @returns the camera or null if not found
  33096. */
  33097. getCameraByID(id: string): Nullable<Camera>;
  33098. /**
  33099. * Gets a camera using its unique id
  33100. * @param uniqueId defines the unique id to look for
  33101. * @returns the camera or null if not found
  33102. */
  33103. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33104. /**
  33105. * Gets a camera using its name
  33106. * @param name defines the camera's name
  33107. * @return the camera or null if none found.
  33108. */
  33109. getCameraByName(name: string): Nullable<Camera>;
  33110. /**
  33111. * Gets a bone using its id
  33112. * @param id defines the bone's id
  33113. * @return the bone or null if not found
  33114. */
  33115. getBoneByID(id: string): Nullable<Bone>;
  33116. /**
  33117. * Gets a bone using its id
  33118. * @param name defines the bone's name
  33119. * @return the bone or null if not found
  33120. */
  33121. getBoneByName(name: string): Nullable<Bone>;
  33122. /**
  33123. * Gets a light node using its name
  33124. * @param name defines the the light's name
  33125. * @return the light or null if none found.
  33126. */
  33127. getLightByName(name: string): Nullable<Light>;
  33128. /**
  33129. * Gets a light node using its id
  33130. * @param id defines the light's id
  33131. * @return the light or null if none found.
  33132. */
  33133. getLightByID(id: string): Nullable<Light>;
  33134. /**
  33135. * Gets a light node using its scene-generated unique ID
  33136. * @param uniqueId defines the light's unique id
  33137. * @return the light or null if none found.
  33138. */
  33139. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33140. /**
  33141. * Gets a particle system by id
  33142. * @param id defines the particle system id
  33143. * @return the corresponding system or null if none found
  33144. */
  33145. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33146. /**
  33147. * Gets a geometry using its ID
  33148. * @param id defines the geometry's id
  33149. * @return the geometry or null if none found.
  33150. */
  33151. getGeometryByID(id: string): Nullable<Geometry>;
  33152. private _getGeometryByUniqueID;
  33153. /**
  33154. * Add a new geometry to this scene
  33155. * @param geometry defines the geometry to be added to the scene.
  33156. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33157. * @return a boolean defining if the geometry was added or not
  33158. */
  33159. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33160. /**
  33161. * Removes an existing geometry
  33162. * @param geometry defines the geometry to be removed from the scene
  33163. * @return a boolean defining if the geometry was removed or not
  33164. */
  33165. removeGeometry(geometry: Geometry): boolean;
  33166. /**
  33167. * Gets the list of geometries attached to the scene
  33168. * @returns an array of Geometry
  33169. */
  33170. getGeometries(): Geometry[];
  33171. /**
  33172. * Gets the first added mesh found of a given ID
  33173. * @param id defines the id to search for
  33174. * @return the mesh found or null if not found at all
  33175. */
  33176. getMeshByID(id: string): Nullable<AbstractMesh>;
  33177. /**
  33178. * Gets a list of meshes using their id
  33179. * @param id defines the id to search for
  33180. * @returns a list of meshes
  33181. */
  33182. getMeshesByID(id: string): Array<AbstractMesh>;
  33183. /**
  33184. * Gets the first added transform node found of a given ID
  33185. * @param id defines the id to search for
  33186. * @return the found transform node or null if not found at all.
  33187. */
  33188. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33189. /**
  33190. * Gets a list of transform nodes using their id
  33191. * @param id defines the id to search for
  33192. * @returns a list of transform nodes
  33193. */
  33194. getTransformNodesByID(id: string): Array<TransformNode>;
  33195. /**
  33196. * Gets a mesh with its auto-generated unique id
  33197. * @param uniqueId defines the unique id to search for
  33198. * @return the found mesh or null if not found at all.
  33199. */
  33200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33201. /**
  33202. * Gets a the last added mesh using a given id
  33203. * @param id defines the id to search for
  33204. * @return the found mesh or null if not found at all.
  33205. */
  33206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33207. /**
  33208. * Gets a the last added 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. getLastEntryByID(id: string): Nullable<Node>;
  33213. /**
  33214. * Gets a node (Mesh, Camera, Light) using a given id
  33215. * @param id defines the id to search for
  33216. * @return the found node or null if not found at all
  33217. */
  33218. getNodeByID(id: string): Nullable<Node>;
  33219. /**
  33220. * Gets a node (Mesh, Camera, Light) using a given name
  33221. * @param name defines the name to search for
  33222. * @return the found node or null if not found at all.
  33223. */
  33224. getNodeByName(name: string): Nullable<Node>;
  33225. /**
  33226. * Gets a mesh using a given name
  33227. * @param name defines the name to search for
  33228. * @return the found mesh or null if not found at all.
  33229. */
  33230. getMeshByName(name: string): Nullable<AbstractMesh>;
  33231. /**
  33232. * Gets a transform node using a given name
  33233. * @param name defines the name to search for
  33234. * @return the found transform node or null if not found at all.
  33235. */
  33236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33237. /**
  33238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33239. * @param id defines the id to search for
  33240. * @return the found skeleton or null if not found at all.
  33241. */
  33242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33243. /**
  33244. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33245. * @param id defines the id to search for
  33246. * @return the found skeleton or null if not found at all.
  33247. */
  33248. getSkeletonById(id: string): Nullable<Skeleton>;
  33249. /**
  33250. * Gets a skeleton using a given name
  33251. * @param name defines the name to search for
  33252. * @return the found skeleton or null if not found at all.
  33253. */
  33254. getSkeletonByName(name: string): Nullable<Skeleton>;
  33255. /**
  33256. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33257. * @param id defines the id to search for
  33258. * @return the found morph target manager or null if not found at all.
  33259. */
  33260. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33261. /**
  33262. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33263. * @param id defines the id to search for
  33264. * @return the found morph target or null if not found at all.
  33265. */
  33266. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33267. /**
  33268. * Gets a boolean indicating if the given mesh is active
  33269. * @param mesh defines the mesh to look for
  33270. * @returns true if the mesh is in the active list
  33271. */
  33272. isActiveMesh(mesh: AbstractMesh): boolean;
  33273. /**
  33274. * Return a unique id as a string which can serve as an identifier for the scene
  33275. */
  33276. readonly uid: string;
  33277. /**
  33278. * Add an externaly attached data from its key.
  33279. * This method call will fail and return false, if such key already exists.
  33280. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33281. * @param key the unique key that identifies the data
  33282. * @param data the data object to associate to the key for this Engine instance
  33283. * @return true if no such key were already present and the data was added successfully, false otherwise
  33284. */
  33285. addExternalData<T>(key: string, data: T): boolean;
  33286. /**
  33287. * Get an externaly attached data from its key
  33288. * @param key the unique key that identifies the data
  33289. * @return the associated data, if present (can be null), or undefined if not present
  33290. */
  33291. getExternalData<T>(key: string): Nullable<T>;
  33292. /**
  33293. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33294. * @param key the unique key that identifies the data
  33295. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33296. * @return the associated data, can be null if the factory returned null.
  33297. */
  33298. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33299. /**
  33300. * Remove an externaly attached data from the Engine instance
  33301. * @param key the unique key that identifies the data
  33302. * @return true if the data was successfully removed, false if it doesn't exist
  33303. */
  33304. removeExternalData(key: string): boolean;
  33305. private _evaluateSubMesh;
  33306. /**
  33307. * Clear the processed materials smart array preventing retention point in material dispose.
  33308. */
  33309. freeProcessedMaterials(): void;
  33310. private _preventFreeActiveMeshesAndRenderingGroups;
  33311. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33312. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33313. * when disposing several meshes in a row or a hierarchy of meshes.
  33314. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33315. */
  33316. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33317. /**
  33318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33319. */
  33320. freeActiveMeshes(): void;
  33321. /**
  33322. * Clear the info related to rendering groups preventing retention points during dispose.
  33323. */
  33324. freeRenderingGroups(): void;
  33325. /** @hidden */
  33326. _isInIntermediateRendering(): boolean;
  33327. /**
  33328. * Lambda returning the list of potentially active meshes.
  33329. */
  33330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33331. /**
  33332. * Lambda returning the list of potentially active sub meshes.
  33333. */
  33334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33335. /**
  33336. * Lambda returning the list of potentially intersecting sub meshes.
  33337. */
  33338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33339. /**
  33340. * Lambda returning the list of potentially colliding sub meshes.
  33341. */
  33342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33343. private _activeMeshesFrozen;
  33344. /**
  33345. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33346. * @returns the current scene
  33347. */
  33348. freezeActiveMeshes(): Scene;
  33349. /**
  33350. * Use this function to restart evaluating active meshes on every frame
  33351. * @returns the current scene
  33352. */
  33353. unfreezeActiveMeshes(): Scene;
  33354. private _evaluateActiveMeshes;
  33355. private _activeMesh;
  33356. /**
  33357. * Update the transform matrix to update from the current active camera
  33358. * @param force defines a boolean used to force the update even if cache is up to date
  33359. */
  33360. updateTransformMatrix(force?: boolean): void;
  33361. /**
  33362. * 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)
  33363. * @param alternateCamera defines the camera to use
  33364. */
  33365. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33366. /** @hidden */
  33367. _allowPostProcessClearColor: boolean;
  33368. private _renderForCamera;
  33369. private _processSubCameras;
  33370. private _checkIntersections;
  33371. /** @hidden */
  33372. _advancePhysicsEngineStep(step: number): void;
  33373. /**
  33374. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33375. */
  33376. getDeterministicFrameTime: () => number;
  33377. /** @hidden */
  33378. _animate(): void;
  33379. /**
  33380. * Render the scene
  33381. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33382. */
  33383. render(updateCameras?: boolean): void;
  33384. /**
  33385. * Freeze all materials
  33386. * A frozen material will not be updatable but should be faster to render
  33387. */
  33388. freezeMaterials(): void;
  33389. /**
  33390. * Unfreeze all materials
  33391. * A frozen material will not be updatable but should be faster to render
  33392. */
  33393. unfreezeMaterials(): void;
  33394. /**
  33395. * Releases all held ressources
  33396. */
  33397. dispose(): void;
  33398. /**
  33399. * Gets if the scene is already disposed
  33400. */
  33401. readonly isDisposed: boolean;
  33402. /**
  33403. * Call this function to reduce memory footprint of the scene.
  33404. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33405. */
  33406. clearCachedVertexData(): void;
  33407. /**
  33408. * This function will remove the local cached buffer data from texture.
  33409. * It will save memory but will prevent the texture from being rebuilt
  33410. */
  33411. cleanCachedTextureBuffer(): void;
  33412. /**
  33413. * Get the world extend vectors with an optional filter
  33414. *
  33415. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33416. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33417. */
  33418. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33419. min: Vector3;
  33420. max: Vector3;
  33421. };
  33422. /**
  33423. * Creates a ray that can be used to pick in the scene
  33424. * @param x defines the x coordinate of the origin (on-screen)
  33425. * @param y defines the y coordinate of the origin (on-screen)
  33426. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33427. * @param camera defines the camera to use for the picking
  33428. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33429. * @returns a Ray
  33430. */
  33431. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33432. /**
  33433. * Creates a ray that can be used to pick in the scene
  33434. * @param x defines the x coordinate of the origin (on-screen)
  33435. * @param y defines the y coordinate of the origin (on-screen)
  33436. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33437. * @param result defines the ray where to store the picking ray
  33438. * @param camera defines the camera to use for the picking
  33439. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33440. * @returns the current scene
  33441. */
  33442. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33443. /**
  33444. * Creates a ray that can be used to pick in the scene
  33445. * @param x defines the x coordinate of the origin (on-screen)
  33446. * @param y defines the y coordinate of the origin (on-screen)
  33447. * @param camera defines the camera to use for the picking
  33448. * @returns a Ray
  33449. */
  33450. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33451. /**
  33452. * Creates a ray that can be used to pick in the scene
  33453. * @param x defines the x coordinate of the origin (on-screen)
  33454. * @param y defines the y coordinate of the origin (on-screen)
  33455. * @param result defines the ray where to store the picking ray
  33456. * @param camera defines the camera to use for the picking
  33457. * @returns the current scene
  33458. */
  33459. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33460. /** Launch a ray to try to pick a mesh in the scene
  33461. * @param x position on screen
  33462. * @param y position on screen
  33463. * @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
  33464. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33465. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33467. * @returns a PickingInfo
  33468. */
  33469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33470. /** Use the given ray to pick a mesh in the scene
  33471. * @param ray The ray to use to pick meshes
  33472. * @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
  33473. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33475. * @returns a PickingInfo
  33476. */
  33477. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33478. /**
  33479. * Launch a ray to try to pick a mesh in the scene
  33480. * @param x X position on screen
  33481. * @param y Y position on screen
  33482. * @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
  33483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33485. * @returns an array of PickingInfo
  33486. */
  33487. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33488. /**
  33489. * Launch a ray to try to pick a mesh in the scene
  33490. * @param ray Ray to use
  33491. * @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
  33492. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33493. * @returns an array of PickingInfo
  33494. */
  33495. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33496. /**
  33497. * Force the value of meshUnderPointer
  33498. * @param mesh defines the mesh to use
  33499. */
  33500. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33501. /**
  33502. * Gets the mesh under the pointer
  33503. * @returns a Mesh or null if no mesh is under the pointer
  33504. */
  33505. getPointerOverMesh(): Nullable<AbstractMesh>;
  33506. /** @hidden */
  33507. _rebuildGeometries(): void;
  33508. /** @hidden */
  33509. _rebuildTextures(): void;
  33510. private _getByTags;
  33511. /**
  33512. * Get a list of meshes by tags
  33513. * @param tagsQuery defines the tags query to use
  33514. * @param forEach defines a predicate used to filter results
  33515. * @returns an array of Mesh
  33516. */
  33517. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33518. /**
  33519. * Get a list of cameras by tags
  33520. * @param tagsQuery defines the tags query to use
  33521. * @param forEach defines a predicate used to filter results
  33522. * @returns an array of Camera
  33523. */
  33524. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33525. /**
  33526. * Get a list of lights by tags
  33527. * @param tagsQuery defines the tags query to use
  33528. * @param forEach defines a predicate used to filter results
  33529. * @returns an array of Light
  33530. */
  33531. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33532. /**
  33533. * Get a list of materials by tags
  33534. * @param tagsQuery defines the tags query to use
  33535. * @param forEach defines a predicate used to filter results
  33536. * @returns an array of Material
  33537. */
  33538. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33539. /**
  33540. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33541. * This allowed control for front to back rendering or reversly depending of the special needs.
  33542. *
  33543. * @param renderingGroupId The rendering group id corresponding to its index
  33544. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33545. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33546. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33547. */
  33548. 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;
  33549. /**
  33550. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33551. *
  33552. * @param renderingGroupId The rendering group id corresponding to its index
  33553. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33554. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33555. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33556. */
  33557. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33558. /**
  33559. * Gets the current auto clear configuration for one rendering group of the rendering
  33560. * manager.
  33561. * @param index the rendering group index to get the information for
  33562. * @returns The auto clear setup for the requested rendering group
  33563. */
  33564. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33565. private _blockMaterialDirtyMechanism;
  33566. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33567. blockMaterialDirtyMechanism: boolean;
  33568. /**
  33569. * Will flag all materials as dirty to trigger new shader compilation
  33570. * @param flag defines the flag used to specify which material part must be marked as dirty
  33571. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33572. */
  33573. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33574. /** @hidden */
  33575. _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;
  33576. /** @hidden */
  33577. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33578. }
  33579. }
  33580. declare module "babylonjs/assetContainer" {
  33581. import { AbstractScene } from "babylonjs/abstractScene";
  33582. import { Scene } from "babylonjs/scene";
  33583. import { Mesh } from "babylonjs/Meshes/mesh";
  33584. /**
  33585. * Set of assets to keep when moving a scene into an asset container.
  33586. */
  33587. export class KeepAssets extends AbstractScene {
  33588. }
  33589. /**
  33590. * Container with a set of assets that can be added or removed from a scene.
  33591. */
  33592. export class AssetContainer extends AbstractScene {
  33593. /**
  33594. * The scene the AssetContainer belongs to.
  33595. */
  33596. scene: Scene;
  33597. /**
  33598. * Instantiates an AssetContainer.
  33599. * @param scene The scene the AssetContainer belongs to.
  33600. */
  33601. constructor(scene: Scene);
  33602. /**
  33603. * Adds all the assets from the container to the scene.
  33604. */
  33605. addAllToScene(): void;
  33606. /**
  33607. * Removes all the assets in the container from the scene
  33608. */
  33609. removeAllFromScene(): void;
  33610. /**
  33611. * Disposes all the assets in the container
  33612. */
  33613. dispose(): void;
  33614. private _moveAssets;
  33615. /**
  33616. * Removes all the assets contained in the scene and adds them to the container.
  33617. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33618. */
  33619. moveAllFromScene(keepAssets?: KeepAssets): void;
  33620. /**
  33621. * 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.
  33622. * @returns the root mesh
  33623. */
  33624. createRootMesh(): Mesh;
  33625. }
  33626. }
  33627. declare module "babylonjs/abstractScene" {
  33628. import { Scene } from "babylonjs/scene";
  33629. import { Nullable } from "babylonjs/types";
  33630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33631. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33632. import { Geometry } from "babylonjs/Meshes/geometry";
  33633. import { Skeleton } from "babylonjs/Bones/skeleton";
  33634. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33635. import { AssetContainer } from "babylonjs/assetContainer";
  33636. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33637. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33639. import { Material } from "babylonjs/Materials/material";
  33640. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33641. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33642. import { Camera } from "babylonjs/Cameras/camera";
  33643. import { Light } from "babylonjs/Lights/light";
  33644. import { Node } from "babylonjs/node";
  33645. import { Animation } from "babylonjs/Animations/animation";
  33646. /**
  33647. * Defines how the parser contract is defined.
  33648. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33649. */
  33650. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33651. /**
  33652. * Defines how the individual parser contract is defined.
  33653. * These parser can parse an individual asset
  33654. */
  33655. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33656. /**
  33657. * Base class of the scene acting as a container for the different elements composing a scene.
  33658. * This class is dynamically extended by the different components of the scene increasing
  33659. * flexibility and reducing coupling
  33660. */
  33661. export abstract class AbstractScene {
  33662. /**
  33663. * Stores the list of available parsers in the application.
  33664. */
  33665. private static _BabylonFileParsers;
  33666. /**
  33667. * Stores the list of available individual parsers in the application.
  33668. */
  33669. private static _IndividualBabylonFileParsers;
  33670. /**
  33671. * Adds a parser in the list of available ones
  33672. * @param name Defines the name of the parser
  33673. * @param parser Defines the parser to add
  33674. */
  33675. static AddParser(name: string, parser: BabylonFileParser): void;
  33676. /**
  33677. * Gets a general parser from the list of avaialble ones
  33678. * @param name Defines the name of the parser
  33679. * @returns the requested parser or null
  33680. */
  33681. static GetParser(name: string): Nullable<BabylonFileParser>;
  33682. /**
  33683. * Adds n individual parser in the list of available ones
  33684. * @param name Defines the name of the parser
  33685. * @param parser Defines the parser to add
  33686. */
  33687. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33688. /**
  33689. * Gets an individual parser from the list of avaialble ones
  33690. * @param name Defines the name of the parser
  33691. * @returns the requested parser or null
  33692. */
  33693. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33694. /**
  33695. * Parser json data and populate both a scene and its associated container object
  33696. * @param jsonData Defines the data to parse
  33697. * @param scene Defines the scene to parse the data for
  33698. * @param container Defines the container attached to the parsing sequence
  33699. * @param rootUrl Defines the root url of the data
  33700. */
  33701. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33702. /**
  33703. * Gets the list of root nodes (ie. nodes with no parent)
  33704. */
  33705. rootNodes: Node[];
  33706. /** All of the cameras added to this scene
  33707. * @see http://doc.babylonjs.com/babylon101/cameras
  33708. */
  33709. cameras: Camera[];
  33710. /**
  33711. * All of the lights added to this scene
  33712. * @see http://doc.babylonjs.com/babylon101/lights
  33713. */
  33714. lights: Light[];
  33715. /**
  33716. * All of the (abstract) meshes added to this scene
  33717. */
  33718. meshes: AbstractMesh[];
  33719. /**
  33720. * The list of skeletons added to the scene
  33721. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33722. */
  33723. skeletons: Skeleton[];
  33724. /**
  33725. * All of the particle systems added to this scene
  33726. * @see http://doc.babylonjs.com/babylon101/particles
  33727. */
  33728. particleSystems: IParticleSystem[];
  33729. /**
  33730. * Gets a list of Animations associated with the scene
  33731. */
  33732. animations: Animation[];
  33733. /**
  33734. * All of the animation groups added to this scene
  33735. * @see http://doc.babylonjs.com/how_to/group
  33736. */
  33737. animationGroups: AnimationGroup[];
  33738. /**
  33739. * All of the multi-materials added to this scene
  33740. * @see http://doc.babylonjs.com/how_to/multi_materials
  33741. */
  33742. multiMaterials: MultiMaterial[];
  33743. /**
  33744. * All of the materials added to this scene
  33745. * In the context of a Scene, it is not supposed to be modified manually.
  33746. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33747. * Note also that the order of the Material wihin the array is not significant and might change.
  33748. * @see http://doc.babylonjs.com/babylon101/materials
  33749. */
  33750. materials: Material[];
  33751. /**
  33752. * The list of morph target managers added to the scene
  33753. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33754. */
  33755. morphTargetManagers: MorphTargetManager[];
  33756. /**
  33757. * The list of geometries used in the scene.
  33758. */
  33759. geometries: Geometry[];
  33760. /**
  33761. * All of the tranform nodes added to this scene
  33762. * In the context of a Scene, it is not supposed to be modified manually.
  33763. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33764. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33765. * @see http://doc.babylonjs.com/how_to/transformnode
  33766. */
  33767. transformNodes: TransformNode[];
  33768. /**
  33769. * ActionManagers available on the scene.
  33770. */
  33771. actionManagers: AbstractActionManager[];
  33772. /**
  33773. * Textures to keep.
  33774. */
  33775. textures: BaseTexture[];
  33776. }
  33777. }
  33778. declare module "babylonjs/Audio/sound" {
  33779. import { Observable } from "babylonjs/Misc/observable";
  33780. import { Vector3 } from "babylonjs/Maths/math";
  33781. import { Nullable } from "babylonjs/types";
  33782. import { Scene } from "babylonjs/scene";
  33783. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33784. /**
  33785. * Defines a sound that can be played in the application.
  33786. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33788. */
  33789. export class Sound {
  33790. /**
  33791. * The name of the sound in the scene.
  33792. */
  33793. name: string;
  33794. /**
  33795. * Does the sound autoplay once loaded.
  33796. */
  33797. autoplay: boolean;
  33798. /**
  33799. * Does the sound loop after it finishes playing once.
  33800. */
  33801. loop: boolean;
  33802. /**
  33803. * Does the sound use a custom attenuation curve to simulate the falloff
  33804. * happening when the source gets further away from the camera.
  33805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33806. */
  33807. useCustomAttenuation: boolean;
  33808. /**
  33809. * The sound track id this sound belongs to.
  33810. */
  33811. soundTrackId: number;
  33812. /**
  33813. * Is this sound currently played.
  33814. */
  33815. isPlaying: boolean;
  33816. /**
  33817. * Is this sound currently paused.
  33818. */
  33819. isPaused: boolean;
  33820. /**
  33821. * Does this sound enables spatial sound.
  33822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33823. */
  33824. spatialSound: boolean;
  33825. /**
  33826. * Define the reference distance the sound should be heard perfectly.
  33827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33828. */
  33829. refDistance: number;
  33830. /**
  33831. * Define the roll off factor of spatial sounds.
  33832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33833. */
  33834. rolloffFactor: number;
  33835. /**
  33836. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33838. */
  33839. maxDistance: number;
  33840. /**
  33841. * Define the distance attenuation model the sound will follow.
  33842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33843. */
  33844. distanceModel: string;
  33845. /**
  33846. * @hidden
  33847. * Back Compat
  33848. **/
  33849. onended: () => any;
  33850. /**
  33851. * Observable event when the current playing sound finishes.
  33852. */
  33853. onEndedObservable: Observable<Sound>;
  33854. private _panningModel;
  33855. private _playbackRate;
  33856. private _streaming;
  33857. private _startTime;
  33858. private _startOffset;
  33859. private _position;
  33860. /** @hidden */
  33861. _positionInEmitterSpace: boolean;
  33862. private _localDirection;
  33863. private _volume;
  33864. private _isReadyToPlay;
  33865. private _isDirectional;
  33866. private _readyToPlayCallback;
  33867. private _audioBuffer;
  33868. private _soundSource;
  33869. private _streamingSource;
  33870. private _soundPanner;
  33871. private _soundGain;
  33872. private _inputAudioNode;
  33873. private _outputAudioNode;
  33874. private _coneInnerAngle;
  33875. private _coneOuterAngle;
  33876. private _coneOuterGain;
  33877. private _scene;
  33878. private _connectedTransformNode;
  33879. private _customAttenuationFunction;
  33880. private _registerFunc;
  33881. private _isOutputConnected;
  33882. private _htmlAudioElement;
  33883. private _urlType;
  33884. /** @hidden */
  33885. static _SceneComponentInitialization: (scene: Scene) => void;
  33886. /**
  33887. * Create a sound and attach it to a scene
  33888. * @param name Name of your sound
  33889. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33890. * @param scene defines the scene the sound belongs to
  33891. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33892. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33893. */
  33894. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33895. /**
  33896. * Release the sound and its associated resources
  33897. */
  33898. dispose(): void;
  33899. /**
  33900. * Gets if the sounds is ready to be played or not.
  33901. * @returns true if ready, otherwise false
  33902. */
  33903. isReady(): boolean;
  33904. private _soundLoaded;
  33905. /**
  33906. * Sets the data of the sound from an audiobuffer
  33907. * @param audioBuffer The audioBuffer containing the data
  33908. */
  33909. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33910. /**
  33911. * Updates the current sounds options such as maxdistance, loop...
  33912. * @param options A JSON object containing values named as the object properties
  33913. */
  33914. updateOptions(options: any): void;
  33915. private _createSpatialParameters;
  33916. private _updateSpatialParameters;
  33917. /**
  33918. * Switch the panning model to HRTF:
  33919. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33921. */
  33922. switchPanningModelToHRTF(): void;
  33923. /**
  33924. * Switch the panning model to Equal Power:
  33925. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33927. */
  33928. switchPanningModelToEqualPower(): void;
  33929. private _switchPanningModel;
  33930. /**
  33931. * Connect this sound to a sound track audio node like gain...
  33932. * @param soundTrackAudioNode the sound track audio node to connect to
  33933. */
  33934. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33935. /**
  33936. * Transform this sound into a directional source
  33937. * @param coneInnerAngle Size of the inner cone in degree
  33938. * @param coneOuterAngle Size of the outer cone in degree
  33939. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33940. */
  33941. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33942. /**
  33943. * Gets or sets the inner angle for the directional cone.
  33944. */
  33945. /**
  33946. * Gets or sets the inner angle for the directional cone.
  33947. */
  33948. directionalConeInnerAngle: number;
  33949. /**
  33950. * Gets or sets the outer angle for the directional cone.
  33951. */
  33952. /**
  33953. * Gets or sets the outer angle for the directional cone.
  33954. */
  33955. directionalConeOuterAngle: number;
  33956. /**
  33957. * Sets the position of the emitter if spatial sound is enabled
  33958. * @param newPosition Defines the new posisiton
  33959. */
  33960. setPosition(newPosition: Vector3): void;
  33961. /**
  33962. * Sets the local direction of the emitter if spatial sound is enabled
  33963. * @param newLocalDirection Defines the new local direction
  33964. */
  33965. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33966. private _updateDirection;
  33967. /** @hidden */
  33968. updateDistanceFromListener(): void;
  33969. /**
  33970. * Sets a new custom attenuation function for the sound.
  33971. * @param callback Defines the function used for the attenuation
  33972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33973. */
  33974. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33975. /**
  33976. * Play the sound
  33977. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33978. * @param offset (optional) Start the sound setting it at a specific time
  33979. */
  33980. play(time?: number, offset?: number): void;
  33981. private _onended;
  33982. /**
  33983. * Stop the sound
  33984. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33985. */
  33986. stop(time?: number): void;
  33987. /**
  33988. * Put the sound in pause
  33989. */
  33990. pause(): void;
  33991. /**
  33992. * Sets a dedicated volume for this sounds
  33993. * @param newVolume Define the new volume of the sound
  33994. * @param time Define in how long the sound should be at this value
  33995. */
  33996. setVolume(newVolume: number, time?: number): void;
  33997. /**
  33998. * Set the sound play back rate
  33999. * @param newPlaybackRate Define the playback rate the sound should be played at
  34000. */
  34001. setPlaybackRate(newPlaybackRate: number): void;
  34002. /**
  34003. * Gets the volume of the sound.
  34004. * @returns the volume of the sound
  34005. */
  34006. getVolume(): number;
  34007. /**
  34008. * Attach the sound to a dedicated mesh
  34009. * @param transformNode The transform node to connect the sound with
  34010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34011. */
  34012. attachToMesh(transformNode: TransformNode): void;
  34013. /**
  34014. * Detach the sound from the previously attached mesh
  34015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34016. */
  34017. detachFromMesh(): void;
  34018. private _onRegisterAfterWorldMatrixUpdate;
  34019. /**
  34020. * Clone the current sound in the scene.
  34021. * @returns the new sound clone
  34022. */
  34023. clone(): Nullable<Sound>;
  34024. /**
  34025. * Gets the current underlying audio buffer containing the data
  34026. * @returns the audio buffer
  34027. */
  34028. getAudioBuffer(): Nullable<AudioBuffer>;
  34029. /**
  34030. * Serializes the Sound in a JSON representation
  34031. * @returns the JSON representation of the sound
  34032. */
  34033. serialize(): any;
  34034. /**
  34035. * Parse a JSON representation of a sound to innstantiate in a given scene
  34036. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34037. * @param scene Define the scene the new parsed sound should be created in
  34038. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34039. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34040. * @returns the newly parsed sound
  34041. */
  34042. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34043. }
  34044. }
  34045. declare module "babylonjs/Actions/directAudioActions" {
  34046. import { Action } from "babylonjs/Actions/action";
  34047. import { Condition } from "babylonjs/Actions/condition";
  34048. import { Sound } from "babylonjs/Audio/sound";
  34049. /**
  34050. * This defines an action helpful to play a defined sound on a triggered action.
  34051. */
  34052. export class PlaySoundAction extends Action {
  34053. private _sound;
  34054. /**
  34055. * Instantiate the action
  34056. * @param triggerOptions defines the trigger options
  34057. * @param sound defines the sound to play
  34058. * @param condition defines the trigger related conditions
  34059. */
  34060. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34061. /** @hidden */
  34062. _prepare(): void;
  34063. /**
  34064. * Execute the action and play the sound.
  34065. */
  34066. execute(): void;
  34067. /**
  34068. * Serializes the actions and its related information.
  34069. * @param parent defines the object to serialize in
  34070. * @returns the serialized object
  34071. */
  34072. serialize(parent: any): any;
  34073. }
  34074. /**
  34075. * This defines an action helpful to stop a defined sound on a triggered action.
  34076. */
  34077. export class StopSoundAction extends Action {
  34078. private _sound;
  34079. /**
  34080. * Instantiate the action
  34081. * @param triggerOptions defines the trigger options
  34082. * @param sound defines the sound to stop
  34083. * @param condition defines the trigger related conditions
  34084. */
  34085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34086. /** @hidden */
  34087. _prepare(): void;
  34088. /**
  34089. * Execute the action and stop the sound.
  34090. */
  34091. execute(): void;
  34092. /**
  34093. * Serializes the actions and its related information.
  34094. * @param parent defines the object to serialize in
  34095. * @returns the serialized object
  34096. */
  34097. serialize(parent: any): any;
  34098. }
  34099. }
  34100. declare module "babylonjs/Actions/interpolateValueAction" {
  34101. import { Action } from "babylonjs/Actions/action";
  34102. import { Condition } from "babylonjs/Actions/condition";
  34103. import { Observable } from "babylonjs/Misc/observable";
  34104. /**
  34105. * This defines an action responsible to change the value of a property
  34106. * by interpolating between its current value and the newly set one once triggered.
  34107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34108. */
  34109. export class InterpolateValueAction extends Action {
  34110. /**
  34111. * Defines the path of the property where the value should be interpolated
  34112. */
  34113. propertyPath: string;
  34114. /**
  34115. * Defines the target value at the end of the interpolation.
  34116. */
  34117. value: any;
  34118. /**
  34119. * Defines the time it will take for the property to interpolate to the value.
  34120. */
  34121. duration: number;
  34122. /**
  34123. * Defines if the other scene animations should be stopped when the action has been triggered
  34124. */
  34125. stopOtherAnimations?: boolean;
  34126. /**
  34127. * Defines a callback raised once the interpolation animation has been done.
  34128. */
  34129. onInterpolationDone?: () => void;
  34130. /**
  34131. * Observable triggered once the interpolation animation has been done.
  34132. */
  34133. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34134. private _target;
  34135. private _effectiveTarget;
  34136. private _property;
  34137. /**
  34138. * Instantiate the action
  34139. * @param triggerOptions defines the trigger options
  34140. * @param target defines the object containing the value to interpolate
  34141. * @param propertyPath defines the path to the property in the target object
  34142. * @param value defines the target value at the end of the interpolation
  34143. * @param duration deines the time it will take for the property to interpolate to the value.
  34144. * @param condition defines the trigger related conditions
  34145. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34146. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34147. */
  34148. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34149. /** @hidden */
  34150. _prepare(): void;
  34151. /**
  34152. * Execute the action starts the value interpolation.
  34153. */
  34154. execute(): void;
  34155. /**
  34156. * Serializes the actions and its related information.
  34157. * @param parent defines the object to serialize in
  34158. * @returns the serialized object
  34159. */
  34160. serialize(parent: any): any;
  34161. }
  34162. }
  34163. declare module "babylonjs/Actions/index" {
  34164. export * from "babylonjs/Actions/action";
  34165. export * from "babylonjs/Actions/actionEvent";
  34166. export * from "babylonjs/Actions/actionManager";
  34167. export * from "babylonjs/Actions/condition";
  34168. export * from "babylonjs/Actions/directActions";
  34169. export * from "babylonjs/Actions/directAudioActions";
  34170. export * from "babylonjs/Actions/interpolateValueAction";
  34171. }
  34172. declare module "babylonjs/Animations/index" {
  34173. export * from "babylonjs/Animations/animatable";
  34174. export * from "babylonjs/Animations/animation";
  34175. export * from "babylonjs/Animations/animationGroup";
  34176. export * from "babylonjs/Animations/animationPropertiesOverride";
  34177. export * from "babylonjs/Animations/easing";
  34178. export * from "babylonjs/Animations/runtimeAnimation";
  34179. export * from "babylonjs/Animations/animationEvent";
  34180. export * from "babylonjs/Animations/animationGroup";
  34181. export * from "babylonjs/Animations/animationKey";
  34182. export * from "babylonjs/Animations/animationRange";
  34183. }
  34184. declare module "babylonjs/Audio/soundTrack" {
  34185. import { Sound } from "babylonjs/Audio/sound";
  34186. import { Analyser } from "babylonjs/Audio/analyser";
  34187. import { Scene } from "babylonjs/scene";
  34188. /**
  34189. * Options allowed during the creation of a sound track.
  34190. */
  34191. export interface ISoundTrackOptions {
  34192. /**
  34193. * The volume the sound track should take during creation
  34194. */
  34195. volume?: number;
  34196. /**
  34197. * Define if the sound track is the main sound track of the scene
  34198. */
  34199. mainTrack?: boolean;
  34200. }
  34201. /**
  34202. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34203. * It will be also used in a future release to apply effects on a specific track.
  34204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34205. */
  34206. export class SoundTrack {
  34207. /**
  34208. * The unique identifier of the sound track in the scene.
  34209. */
  34210. id: number;
  34211. /**
  34212. * The list of sounds included in the sound track.
  34213. */
  34214. soundCollection: Array<Sound>;
  34215. private _outputAudioNode;
  34216. private _scene;
  34217. private _isMainTrack;
  34218. private _connectedAnalyser;
  34219. private _options;
  34220. private _isInitialized;
  34221. /**
  34222. * Creates a new sound track.
  34223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34224. * @param scene Define the scene the sound track belongs to
  34225. * @param options
  34226. */
  34227. constructor(scene: Scene, options?: ISoundTrackOptions);
  34228. private _initializeSoundTrackAudioGraph;
  34229. /**
  34230. * Release the sound track and its associated resources
  34231. */
  34232. dispose(): void;
  34233. /**
  34234. * Adds a sound to this sound track
  34235. * @param sound define the cound to add
  34236. * @ignoreNaming
  34237. */
  34238. AddSound(sound: Sound): void;
  34239. /**
  34240. * Removes a sound to this sound track
  34241. * @param sound define the cound to remove
  34242. * @ignoreNaming
  34243. */
  34244. RemoveSound(sound: Sound): void;
  34245. /**
  34246. * Set a global volume for the full sound track.
  34247. * @param newVolume Define the new volume of the sound track
  34248. */
  34249. setVolume(newVolume: number): void;
  34250. /**
  34251. * Switch the panning model to HRTF:
  34252. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34254. */
  34255. switchPanningModelToHRTF(): void;
  34256. /**
  34257. * Switch the panning model to Equal Power:
  34258. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34260. */
  34261. switchPanningModelToEqualPower(): void;
  34262. /**
  34263. * Connect the sound track to an audio analyser allowing some amazing
  34264. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34266. * @param analyser The analyser to connect to the engine
  34267. */
  34268. connectToAnalyser(analyser: Analyser): void;
  34269. }
  34270. }
  34271. declare module "babylonjs/Audio/audioSceneComponent" {
  34272. import { Sound } from "babylonjs/Audio/sound";
  34273. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34274. import { Nullable } from "babylonjs/types";
  34275. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34276. import { Scene } from "babylonjs/scene";
  34277. import { AbstractScene } from "babylonjs/abstractScene";
  34278. module "babylonjs/abstractScene" {
  34279. interface AbstractScene {
  34280. /**
  34281. * The list of sounds used in the scene.
  34282. */
  34283. sounds: Nullable<Array<Sound>>;
  34284. }
  34285. }
  34286. module "babylonjs/scene" {
  34287. interface Scene {
  34288. /**
  34289. * @hidden
  34290. * Backing field
  34291. */
  34292. _mainSoundTrack: SoundTrack;
  34293. /**
  34294. * The main sound track played by the scene.
  34295. * It cotains your primary collection of sounds.
  34296. */
  34297. mainSoundTrack: SoundTrack;
  34298. /**
  34299. * The list of sound tracks added to the scene
  34300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34301. */
  34302. soundTracks: Nullable<Array<SoundTrack>>;
  34303. /**
  34304. * Gets a sound using a given name
  34305. * @param name defines the name to search for
  34306. * @return the found sound or null if not found at all.
  34307. */
  34308. getSoundByName(name: string): Nullable<Sound>;
  34309. /**
  34310. * Gets or sets if audio support is enabled
  34311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34312. */
  34313. audioEnabled: boolean;
  34314. /**
  34315. * Gets or sets if audio will be output to headphones
  34316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34317. */
  34318. headphone: boolean;
  34319. }
  34320. }
  34321. /**
  34322. * Defines the sound scene component responsible to manage any sounds
  34323. * in a given scene.
  34324. */
  34325. export class AudioSceneComponent implements ISceneSerializableComponent {
  34326. /**
  34327. * The component name helpfull to identify the component in the list of scene components.
  34328. */
  34329. readonly name: string;
  34330. /**
  34331. * The scene the component belongs to.
  34332. */
  34333. scene: Scene;
  34334. private _audioEnabled;
  34335. /**
  34336. * Gets whether audio is enabled or not.
  34337. * Please use related enable/disable method to switch state.
  34338. */
  34339. readonly audioEnabled: boolean;
  34340. private _headphone;
  34341. /**
  34342. * Gets whether audio is outputing to headphone or not.
  34343. * Please use the according Switch methods to change output.
  34344. */
  34345. readonly headphone: boolean;
  34346. /**
  34347. * Creates a new instance of the component for the given scene
  34348. * @param scene Defines the scene to register the component in
  34349. */
  34350. constructor(scene: Scene);
  34351. /**
  34352. * Registers the component in a given scene
  34353. */
  34354. register(): void;
  34355. /**
  34356. * Rebuilds the elements related to this component in case of
  34357. * context lost for instance.
  34358. */
  34359. rebuild(): void;
  34360. /**
  34361. * Serializes the component data to the specified json object
  34362. * @param serializationObject The object to serialize to
  34363. */
  34364. serialize(serializationObject: any): void;
  34365. /**
  34366. * Adds all the element from the container to the scene
  34367. * @param container the container holding the elements
  34368. */
  34369. addFromContainer(container: AbstractScene): void;
  34370. /**
  34371. * Removes all the elements in the container from the scene
  34372. * @param container contains the elements to remove
  34373. */
  34374. removeFromContainer(container: AbstractScene): void;
  34375. /**
  34376. * Disposes the component and the associated ressources.
  34377. */
  34378. dispose(): void;
  34379. /**
  34380. * Disables audio in the associated scene.
  34381. */
  34382. disableAudio(): void;
  34383. /**
  34384. * Enables audio in the associated scene.
  34385. */
  34386. enableAudio(): void;
  34387. /**
  34388. * Switch audio to headphone output.
  34389. */
  34390. switchAudioModeForHeadphones(): void;
  34391. /**
  34392. * Switch audio to normal speakers.
  34393. */
  34394. switchAudioModeForNormalSpeakers(): void;
  34395. private _afterRender;
  34396. }
  34397. }
  34398. declare module "babylonjs/Audio/weightedsound" {
  34399. import { Sound } from "babylonjs/Audio/sound";
  34400. /**
  34401. * Wraps one or more Sound objects and selects one with random weight for playback.
  34402. */
  34403. export class WeightedSound {
  34404. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34405. loop: boolean;
  34406. private _coneInnerAngle;
  34407. private _coneOuterAngle;
  34408. private _volume;
  34409. /** A Sound is currently playing. */
  34410. isPlaying: boolean;
  34411. /** A Sound is currently paused. */
  34412. isPaused: boolean;
  34413. private _sounds;
  34414. private _weights;
  34415. private _currentIndex?;
  34416. /**
  34417. * Creates a new WeightedSound from the list of sounds given.
  34418. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34419. * @param sounds Array of Sounds that will be selected from.
  34420. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34421. */
  34422. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34423. /**
  34424. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34425. */
  34426. /**
  34427. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34428. */
  34429. directionalConeInnerAngle: number;
  34430. /**
  34431. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34432. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34433. */
  34434. /**
  34435. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34436. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34437. */
  34438. directionalConeOuterAngle: number;
  34439. /**
  34440. * Playback volume.
  34441. */
  34442. /**
  34443. * Playback volume.
  34444. */
  34445. volume: number;
  34446. private _onended;
  34447. /**
  34448. * Suspend playback
  34449. */
  34450. pause(): void;
  34451. /**
  34452. * Stop playback
  34453. */
  34454. stop(): void;
  34455. /**
  34456. * Start playback.
  34457. * @param startOffset Position the clip head at a specific time in seconds.
  34458. */
  34459. play(startOffset?: number): void;
  34460. }
  34461. }
  34462. declare module "babylonjs/Audio/index" {
  34463. export * from "babylonjs/Audio/analyser";
  34464. export * from "babylonjs/Audio/audioEngine";
  34465. export * from "babylonjs/Audio/audioSceneComponent";
  34466. export * from "babylonjs/Audio/sound";
  34467. export * from "babylonjs/Audio/soundTrack";
  34468. export * from "babylonjs/Audio/weightedsound";
  34469. }
  34470. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34471. import { Behavior } from "babylonjs/Behaviors/behavior";
  34472. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34473. import { BackEase } from "babylonjs/Animations/easing";
  34474. /**
  34475. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34476. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34477. */
  34478. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34479. /**
  34480. * Gets the name of the behavior.
  34481. */
  34482. readonly name: string;
  34483. /**
  34484. * The easing function used by animations
  34485. */
  34486. static EasingFunction: BackEase;
  34487. /**
  34488. * The easing mode used by animations
  34489. */
  34490. static EasingMode: number;
  34491. /**
  34492. * The duration of the animation, in milliseconds
  34493. */
  34494. transitionDuration: number;
  34495. /**
  34496. * Length of the distance animated by the transition when lower radius is reached
  34497. */
  34498. lowerRadiusTransitionRange: number;
  34499. /**
  34500. * Length of the distance animated by the transition when upper radius is reached
  34501. */
  34502. upperRadiusTransitionRange: number;
  34503. private _autoTransitionRange;
  34504. /**
  34505. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34506. */
  34507. /**
  34508. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34509. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34510. */
  34511. autoTransitionRange: boolean;
  34512. private _attachedCamera;
  34513. private _onAfterCheckInputsObserver;
  34514. private _onMeshTargetChangedObserver;
  34515. /**
  34516. * Initializes the behavior.
  34517. */
  34518. init(): void;
  34519. /**
  34520. * Attaches the behavior to its arc rotate camera.
  34521. * @param camera Defines the camera to attach the behavior to
  34522. */
  34523. attach(camera: ArcRotateCamera): void;
  34524. /**
  34525. * Detaches the behavior from its current arc rotate camera.
  34526. */
  34527. detach(): void;
  34528. private _radiusIsAnimating;
  34529. private _radiusBounceTransition;
  34530. private _animatables;
  34531. private _cachedWheelPrecision;
  34532. /**
  34533. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34534. * @param radiusLimit The limit to check against.
  34535. * @return Bool to indicate if at limit.
  34536. */
  34537. private _isRadiusAtLimit;
  34538. /**
  34539. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34540. * @param radiusDelta The delta by which to animate to. Can be negative.
  34541. */
  34542. private _applyBoundRadiusAnimation;
  34543. /**
  34544. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34545. */
  34546. protected _clearAnimationLocks(): void;
  34547. /**
  34548. * Stops and removes all animations that have been applied to the camera
  34549. */
  34550. stopAllAnimations(): void;
  34551. }
  34552. }
  34553. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34554. import { Behavior } from "babylonjs/Behaviors/behavior";
  34555. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34556. import { ExponentialEase } from "babylonjs/Animations/easing";
  34557. import { Nullable } from "babylonjs/types";
  34558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34559. import { Vector3 } from "babylonjs/Maths/math";
  34560. /**
  34561. * 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.
  34562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34563. */
  34564. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34565. /**
  34566. * Gets the name of the behavior.
  34567. */
  34568. readonly name: string;
  34569. private _mode;
  34570. private _radiusScale;
  34571. private _positionScale;
  34572. private _defaultElevation;
  34573. private _elevationReturnTime;
  34574. private _elevationReturnWaitTime;
  34575. private _zoomStopsAnimation;
  34576. private _framingTime;
  34577. /**
  34578. * The easing function used by animations
  34579. */
  34580. static EasingFunction: ExponentialEase;
  34581. /**
  34582. * The easing mode used by animations
  34583. */
  34584. static EasingMode: number;
  34585. /**
  34586. * Sets the current mode used by the behavior
  34587. */
  34588. /**
  34589. * Gets current mode used by the behavior.
  34590. */
  34591. mode: number;
  34592. /**
  34593. * Sets the scale applied to the radius (1 by default)
  34594. */
  34595. /**
  34596. * Gets the scale applied to the radius
  34597. */
  34598. radiusScale: number;
  34599. /**
  34600. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34601. */
  34602. /**
  34603. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34604. */
  34605. positionScale: number;
  34606. /**
  34607. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34608. * behaviour is triggered, in radians.
  34609. */
  34610. /**
  34611. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34612. * behaviour is triggered, in radians.
  34613. */
  34614. defaultElevation: number;
  34615. /**
  34616. * Sets the time (in milliseconds) taken to return to the default beta position.
  34617. * Negative value indicates camera should not return to default.
  34618. */
  34619. /**
  34620. * Gets the time (in milliseconds) taken to return to the default beta position.
  34621. * Negative value indicates camera should not return to default.
  34622. */
  34623. elevationReturnTime: number;
  34624. /**
  34625. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34626. */
  34627. /**
  34628. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34629. */
  34630. elevationReturnWaitTime: number;
  34631. /**
  34632. * Sets the flag that indicates if user zooming should stop animation.
  34633. */
  34634. /**
  34635. * Gets the flag that indicates if user zooming should stop animation.
  34636. */
  34637. zoomStopsAnimation: boolean;
  34638. /**
  34639. * Sets the transition time when framing the mesh, in milliseconds
  34640. */
  34641. /**
  34642. * Gets the transition time when framing the mesh, in milliseconds
  34643. */
  34644. framingTime: number;
  34645. /**
  34646. * Define if the behavior should automatically change the configured
  34647. * camera limits and sensibilities.
  34648. */
  34649. autoCorrectCameraLimitsAndSensibility: boolean;
  34650. private _onPrePointerObservableObserver;
  34651. private _onAfterCheckInputsObserver;
  34652. private _onMeshTargetChangedObserver;
  34653. private _attachedCamera;
  34654. private _isPointerDown;
  34655. private _lastInteractionTime;
  34656. /**
  34657. * Initializes the behavior.
  34658. */
  34659. init(): void;
  34660. /**
  34661. * Attaches the behavior to its arc rotate camera.
  34662. * @param camera Defines the camera to attach the behavior to
  34663. */
  34664. attach(camera: ArcRotateCamera): void;
  34665. /**
  34666. * Detaches the behavior from its current arc rotate camera.
  34667. */
  34668. detach(): void;
  34669. private _animatables;
  34670. private _betaIsAnimating;
  34671. private _betaTransition;
  34672. private _radiusTransition;
  34673. private _vectorTransition;
  34674. /**
  34675. * Targets the given mesh and updates zoom level accordingly.
  34676. * @param mesh The mesh to target.
  34677. * @param radius Optional. If a cached radius position already exists, overrides default.
  34678. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34679. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34680. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34681. */
  34682. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34683. /**
  34684. * Targets the given mesh with its children and updates zoom level accordingly.
  34685. * @param mesh The mesh to target.
  34686. * @param radius Optional. If a cached radius position already exists, overrides default.
  34687. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34688. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34689. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34690. */
  34691. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34692. /**
  34693. * Targets the given meshes with their children and updates zoom level accordingly.
  34694. * @param meshes The mesh to target.
  34695. * @param radius Optional. If a cached radius position already exists, overrides default.
  34696. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34697. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34698. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34699. */
  34700. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34701. /**
  34702. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34703. * @param minimumWorld Determines the smaller position of the bounding box extend
  34704. * @param maximumWorld Determines the bigger position of the bounding box extend
  34705. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34706. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34707. */
  34708. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34709. /**
  34710. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34711. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34712. * frustum width.
  34713. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34714. * to fully enclose the mesh in the viewing frustum.
  34715. */
  34716. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34717. /**
  34718. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34719. * is automatically returned to its default position (expected to be above ground plane).
  34720. */
  34721. private _maintainCameraAboveGround;
  34722. /**
  34723. * Returns the frustum slope based on the canvas ratio and camera FOV
  34724. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34725. */
  34726. private _getFrustumSlope;
  34727. /**
  34728. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34729. */
  34730. private _clearAnimationLocks;
  34731. /**
  34732. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34733. */
  34734. private _applyUserInteraction;
  34735. /**
  34736. * Stops and removes all animations that have been applied to the camera
  34737. */
  34738. stopAllAnimations(): void;
  34739. /**
  34740. * Gets a value indicating if the user is moving the camera
  34741. */
  34742. readonly isUserIsMoving: boolean;
  34743. /**
  34744. * The camera can move all the way towards the mesh.
  34745. */
  34746. static IgnoreBoundsSizeMode: number;
  34747. /**
  34748. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34749. */
  34750. static FitFrustumSidesMode: number;
  34751. }
  34752. }
  34753. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34754. import { Nullable } from "babylonjs/types";
  34755. import { Camera } from "babylonjs/Cameras/camera";
  34756. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34757. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34758. /**
  34759. * Base class for Camera Pointer Inputs.
  34760. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34761. * for example usage.
  34762. */
  34763. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34764. /**
  34765. * Defines the camera the input is attached to.
  34766. */
  34767. abstract camera: Camera;
  34768. /**
  34769. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34770. */
  34771. protected _altKey: boolean;
  34772. protected _ctrlKey: boolean;
  34773. protected _metaKey: boolean;
  34774. protected _shiftKey: boolean;
  34775. /**
  34776. * Which mouse buttons were pressed at time of last mouse event.
  34777. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34778. */
  34779. protected _buttonsPressed: number;
  34780. /**
  34781. * Defines the buttons associated with the input to handle camera move.
  34782. */
  34783. buttons: number[];
  34784. /**
  34785. * Attach the input controls to a specific dom element to get the input from.
  34786. * @param element Defines the element the controls should be listened from
  34787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34788. */
  34789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34790. /**
  34791. * Detach the current controls from the specified dom element.
  34792. * @param element Defines the element to stop listening the inputs from
  34793. */
  34794. detachControl(element: Nullable<HTMLElement>): void;
  34795. /**
  34796. * Gets the class name of the current input.
  34797. * @returns the class name
  34798. */
  34799. getClassName(): string;
  34800. /**
  34801. * Get the friendly name associated with the input class.
  34802. * @returns the input friendly name
  34803. */
  34804. getSimpleName(): string;
  34805. /**
  34806. * Called on pointer POINTERDOUBLETAP event.
  34807. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34808. */
  34809. protected onDoubleTap(type: string): void;
  34810. /**
  34811. * Called on pointer POINTERMOVE event if only a single touch is active.
  34812. * Override this method to provide functionality.
  34813. */
  34814. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34815. /**
  34816. * Called on pointer POINTERMOVE event if multiple touches are active.
  34817. * Override this method to provide functionality.
  34818. */
  34819. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34820. /**
  34821. * Called on JS contextmenu event.
  34822. * Override this method to provide functionality.
  34823. */
  34824. protected onContextMenu(evt: PointerEvent): void;
  34825. /**
  34826. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34827. * press.
  34828. * Override this method to provide functionality.
  34829. */
  34830. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34831. /**
  34832. * Called each time a new POINTERUP event occurs. Ie, for each button
  34833. * release.
  34834. * Override this method to provide functionality.
  34835. */
  34836. protected onButtonUp(evt: PointerEvent): void;
  34837. /**
  34838. * Called when window becomes inactive.
  34839. * Override this method to provide functionality.
  34840. */
  34841. protected onLostFocus(): void;
  34842. private _pointerInput;
  34843. private _observer;
  34844. private _onLostFocus;
  34845. }
  34846. }
  34847. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34848. import { Nullable } from "babylonjs/types";
  34849. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34850. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34851. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34852. /**
  34853. * Manage the pointers inputs to control an arc rotate camera.
  34854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34855. */
  34856. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34857. /**
  34858. * Defines the camera the input is attached to.
  34859. */
  34860. camera: ArcRotateCamera;
  34861. /**
  34862. * Gets the class name of the current input.
  34863. * @returns the class name
  34864. */
  34865. getClassName(): string;
  34866. /**
  34867. * Defines the buttons associated with the input to handle camera move.
  34868. */
  34869. buttons: number[];
  34870. /**
  34871. * Defines the pointer angular sensibility along the X axis or how fast is
  34872. * the camera rotating.
  34873. */
  34874. angularSensibilityX: number;
  34875. /**
  34876. * Defines the pointer angular sensibility along the Y axis or how fast is
  34877. * the camera rotating.
  34878. */
  34879. angularSensibilityY: number;
  34880. /**
  34881. * Defines the pointer pinch precision or how fast is the camera zooming.
  34882. */
  34883. pinchPrecision: number;
  34884. /**
  34885. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34886. * from 0.
  34887. * It defines the percentage of current camera.radius to use as delta when
  34888. * pinch zoom is used.
  34889. */
  34890. pinchDeltaPercentage: number;
  34891. /**
  34892. * Defines the pointer panning sensibility or how fast is the camera moving.
  34893. */
  34894. panningSensibility: number;
  34895. /**
  34896. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34897. */
  34898. multiTouchPanning: boolean;
  34899. /**
  34900. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34901. * zoom (pinch) through multitouch.
  34902. */
  34903. multiTouchPanAndZoom: boolean;
  34904. /**
  34905. * Revers pinch action direction.
  34906. */
  34907. pinchInwards: boolean;
  34908. private _isPanClick;
  34909. private _twoFingerActivityCount;
  34910. private _isPinching;
  34911. /**
  34912. * Called on pointer POINTERMOVE event if only a single touch is active.
  34913. */
  34914. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34915. /**
  34916. * Called on pointer POINTERDOUBLETAP event.
  34917. */
  34918. protected onDoubleTap(type: string): void;
  34919. /**
  34920. * Called on pointer POINTERMOVE event if multiple touches are active.
  34921. */
  34922. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34923. /**
  34924. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34925. * press.
  34926. */
  34927. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34928. /**
  34929. * Called each time a new POINTERUP event occurs. Ie, for each button
  34930. * release.
  34931. */
  34932. protected onButtonUp(evt: PointerEvent): void;
  34933. /**
  34934. * Called when window becomes inactive.
  34935. */
  34936. protected onLostFocus(): void;
  34937. }
  34938. }
  34939. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34940. import { Nullable } from "babylonjs/types";
  34941. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34942. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34943. /**
  34944. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34946. */
  34947. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34948. /**
  34949. * Defines the camera the input is attached to.
  34950. */
  34951. camera: ArcRotateCamera;
  34952. /**
  34953. * Defines the list of key codes associated with the up action (increase alpha)
  34954. */
  34955. keysUp: number[];
  34956. /**
  34957. * Defines the list of key codes associated with the down action (decrease alpha)
  34958. */
  34959. keysDown: number[];
  34960. /**
  34961. * Defines the list of key codes associated with the left action (increase beta)
  34962. */
  34963. keysLeft: number[];
  34964. /**
  34965. * Defines the list of key codes associated with the right action (decrease beta)
  34966. */
  34967. keysRight: number[];
  34968. /**
  34969. * Defines the list of key codes associated with the reset action.
  34970. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34971. */
  34972. keysReset: number[];
  34973. /**
  34974. * Defines the panning sensibility of the inputs.
  34975. * (How fast is the camera paning)
  34976. */
  34977. panningSensibility: number;
  34978. /**
  34979. * Defines the zooming sensibility of the inputs.
  34980. * (How fast is the camera zooming)
  34981. */
  34982. zoomingSensibility: number;
  34983. /**
  34984. * Defines wether maintaining the alt key down switch the movement mode from
  34985. * orientation to zoom.
  34986. */
  34987. useAltToZoom: boolean;
  34988. /**
  34989. * Rotation speed of the camera
  34990. */
  34991. angularSpeed: number;
  34992. private _keys;
  34993. private _ctrlPressed;
  34994. private _altPressed;
  34995. private _onCanvasBlurObserver;
  34996. private _onKeyboardObserver;
  34997. private _engine;
  34998. private _scene;
  34999. /**
  35000. * Attach the input controls to a specific dom element to get the input from.
  35001. * @param element Defines the element the controls should be listened from
  35002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35003. */
  35004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35005. /**
  35006. * Detach the current controls from the specified dom element.
  35007. * @param element Defines the element to stop listening the inputs from
  35008. */
  35009. detachControl(element: Nullable<HTMLElement>): void;
  35010. /**
  35011. * Update the current camera state depending on the inputs that have been used this frame.
  35012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35013. */
  35014. checkInputs(): void;
  35015. /**
  35016. * Gets the class name of the current intput.
  35017. * @returns the class name
  35018. */
  35019. getClassName(): string;
  35020. /**
  35021. * Get the friendly name associated with the input class.
  35022. * @returns the input friendly name
  35023. */
  35024. getSimpleName(): string;
  35025. }
  35026. }
  35027. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35028. import { Nullable } from "babylonjs/types";
  35029. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35030. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35031. /**
  35032. * Manage the mouse wheel inputs to control an arc rotate camera.
  35033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35034. */
  35035. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35036. /**
  35037. * Defines the camera the input is attached to.
  35038. */
  35039. camera: ArcRotateCamera;
  35040. /**
  35041. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35042. */
  35043. wheelPrecision: number;
  35044. /**
  35045. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35046. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35047. */
  35048. wheelDeltaPercentage: number;
  35049. private _wheel;
  35050. private _observer;
  35051. /**
  35052. * Attach the input controls to a specific dom element to get the input from.
  35053. * @param element Defines the element the controls should be listened from
  35054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35055. */
  35056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35057. /**
  35058. * Detach the current controls from the specified dom element.
  35059. * @param element Defines the element to stop listening the inputs from
  35060. */
  35061. detachControl(element: Nullable<HTMLElement>): void;
  35062. /**
  35063. * Gets the class name of the current intput.
  35064. * @returns the class name
  35065. */
  35066. getClassName(): string;
  35067. /**
  35068. * Get the friendly name associated with the input class.
  35069. * @returns the input friendly name
  35070. */
  35071. getSimpleName(): string;
  35072. }
  35073. }
  35074. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35076. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35077. /**
  35078. * Default Inputs manager for the ArcRotateCamera.
  35079. * It groups all the default supported inputs for ease of use.
  35080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35081. */
  35082. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35083. /**
  35084. * Instantiates a new ArcRotateCameraInputsManager.
  35085. * @param camera Defines the camera the inputs belong to
  35086. */
  35087. constructor(camera: ArcRotateCamera);
  35088. /**
  35089. * Add mouse wheel input support to the input manager.
  35090. * @returns the current input manager
  35091. */
  35092. addMouseWheel(): ArcRotateCameraInputsManager;
  35093. /**
  35094. * Add pointers input support to the input manager.
  35095. * @returns the current input manager
  35096. */
  35097. addPointers(): ArcRotateCameraInputsManager;
  35098. /**
  35099. * Add keyboard input support to the input manager.
  35100. * @returns the current input manager
  35101. */
  35102. addKeyboard(): ArcRotateCameraInputsManager;
  35103. }
  35104. }
  35105. declare module "babylonjs/Cameras/arcRotateCamera" {
  35106. import { Observable } from "babylonjs/Misc/observable";
  35107. import { Nullable } from "babylonjs/types";
  35108. import { Scene } from "babylonjs/scene";
  35109. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35111. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35112. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35113. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35114. import { Camera } from "babylonjs/Cameras/camera";
  35115. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35116. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35117. import { Collider } from "babylonjs/Collisions/collider";
  35118. /**
  35119. * This represents an orbital type of camera.
  35120. *
  35121. * 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.
  35122. * 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.
  35123. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35124. */
  35125. export class ArcRotateCamera extends TargetCamera {
  35126. /**
  35127. * Defines the rotation angle of the camera along the longitudinal axis.
  35128. */
  35129. alpha: number;
  35130. /**
  35131. * Defines the rotation angle of the camera along the latitudinal axis.
  35132. */
  35133. beta: number;
  35134. /**
  35135. * Defines the radius of the camera from it s target point.
  35136. */
  35137. radius: number;
  35138. protected _target: Vector3;
  35139. protected _targetHost: Nullable<AbstractMesh>;
  35140. /**
  35141. * Defines the target point of the camera.
  35142. * The camera looks towards it form the radius distance.
  35143. */
  35144. target: Vector3;
  35145. /**
  35146. * Define the current local position of the camera in the scene
  35147. */
  35148. position: Vector3;
  35149. /**
  35150. * Current inertia value on the longitudinal axis.
  35151. * The bigger this number the longer it will take for the camera to stop.
  35152. */
  35153. inertialAlphaOffset: number;
  35154. /**
  35155. * Current inertia value on the latitudinal axis.
  35156. * The bigger this number the longer it will take for the camera to stop.
  35157. */
  35158. inertialBetaOffset: number;
  35159. /**
  35160. * Current inertia value on the radius axis.
  35161. * The bigger this number the longer it will take for the camera to stop.
  35162. */
  35163. inertialRadiusOffset: number;
  35164. /**
  35165. * Minimum allowed angle on the longitudinal axis.
  35166. * This can help limiting how the Camera is able to move in the scene.
  35167. */
  35168. lowerAlphaLimit: Nullable<number>;
  35169. /**
  35170. * Maximum allowed angle on the longitudinal axis.
  35171. * This can help limiting how the Camera is able to move in the scene.
  35172. */
  35173. upperAlphaLimit: Nullable<number>;
  35174. /**
  35175. * Minimum allowed angle on the latitudinal axis.
  35176. * This can help limiting how the Camera is able to move in the scene.
  35177. */
  35178. lowerBetaLimit: number;
  35179. /**
  35180. * Maximum allowed angle on the latitudinal axis.
  35181. * This can help limiting how the Camera is able to move in the scene.
  35182. */
  35183. upperBetaLimit: number;
  35184. /**
  35185. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35186. * This can help limiting how the Camera is able to move in the scene.
  35187. */
  35188. lowerRadiusLimit: Nullable<number>;
  35189. /**
  35190. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35191. * This can help limiting how the Camera is able to move in the scene.
  35192. */
  35193. upperRadiusLimit: Nullable<number>;
  35194. /**
  35195. * Defines the current inertia value used during panning of the camera along the X axis.
  35196. */
  35197. inertialPanningX: number;
  35198. /**
  35199. * Defines the current inertia value used during panning of the camera along the Y axis.
  35200. */
  35201. inertialPanningY: number;
  35202. /**
  35203. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35204. * Basically if your fingers moves away from more than this distance you will be considered
  35205. * in pinch mode.
  35206. */
  35207. pinchToPanMaxDistance: number;
  35208. /**
  35209. * Defines the maximum distance the camera can pan.
  35210. * This could help keeping the cammera always in your scene.
  35211. */
  35212. panningDistanceLimit: Nullable<number>;
  35213. /**
  35214. * Defines the target of the camera before paning.
  35215. */
  35216. panningOriginTarget: Vector3;
  35217. /**
  35218. * Defines the value of the inertia used during panning.
  35219. * 0 would mean stop inertia and one would mean no decelleration at all.
  35220. */
  35221. panningInertia: number;
  35222. /**
  35223. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35224. */
  35225. angularSensibilityX: number;
  35226. /**
  35227. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35228. */
  35229. angularSensibilityY: number;
  35230. /**
  35231. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35232. */
  35233. pinchPrecision: number;
  35234. /**
  35235. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35236. * It will be used instead of pinchDeltaPrecision if different from 0.
  35237. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35238. */
  35239. pinchDeltaPercentage: number;
  35240. /**
  35241. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35242. */
  35243. panningSensibility: number;
  35244. /**
  35245. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35246. */
  35247. keysUp: number[];
  35248. /**
  35249. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35250. */
  35251. keysDown: number[];
  35252. /**
  35253. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35254. */
  35255. keysLeft: number[];
  35256. /**
  35257. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35258. */
  35259. keysRight: number[];
  35260. /**
  35261. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35262. */
  35263. wheelPrecision: number;
  35264. /**
  35265. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35266. * It will be used instead of pinchDeltaPrecision if different from 0.
  35267. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35268. */
  35269. wheelDeltaPercentage: number;
  35270. /**
  35271. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35272. */
  35273. zoomOnFactor: number;
  35274. /**
  35275. * Defines a screen offset for the camera position.
  35276. */
  35277. targetScreenOffset: Vector2;
  35278. /**
  35279. * Allows the camera to be completely reversed.
  35280. * If false the camera can not arrive upside down.
  35281. */
  35282. allowUpsideDown: boolean;
  35283. /**
  35284. * Define if double tap/click is used to restore the previously saved state of the camera.
  35285. */
  35286. useInputToRestoreState: boolean;
  35287. /** @hidden */
  35288. _viewMatrix: Matrix;
  35289. /** @hidden */
  35290. _useCtrlForPanning: boolean;
  35291. /** @hidden */
  35292. _panningMouseButton: number;
  35293. /**
  35294. * Defines the input associated to the camera.
  35295. */
  35296. inputs: ArcRotateCameraInputsManager;
  35297. /** @hidden */
  35298. _reset: () => void;
  35299. /**
  35300. * Defines the allowed panning axis.
  35301. */
  35302. panningAxis: Vector3;
  35303. protected _localDirection: Vector3;
  35304. protected _transformedDirection: Vector3;
  35305. private _bouncingBehavior;
  35306. /**
  35307. * Gets the bouncing behavior of the camera if it has been enabled.
  35308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35309. */
  35310. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35311. /**
  35312. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35314. */
  35315. useBouncingBehavior: boolean;
  35316. private _framingBehavior;
  35317. /**
  35318. * Gets the framing behavior of the camera if it has been enabled.
  35319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35320. */
  35321. readonly framingBehavior: Nullable<FramingBehavior>;
  35322. /**
  35323. * Defines if the framing behavior of the camera is enabled on the camera.
  35324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35325. */
  35326. useFramingBehavior: boolean;
  35327. private _autoRotationBehavior;
  35328. /**
  35329. * Gets the auto rotation behavior of the camera if it has been enabled.
  35330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35331. */
  35332. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35333. /**
  35334. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35336. */
  35337. useAutoRotationBehavior: boolean;
  35338. /**
  35339. * Observable triggered when the mesh target has been changed on the camera.
  35340. */
  35341. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35342. /**
  35343. * Event raised when the camera is colliding with a mesh.
  35344. */
  35345. onCollide: (collidedMesh: AbstractMesh) => void;
  35346. /**
  35347. * Defines whether the camera should check collision with the objects oh the scene.
  35348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35349. */
  35350. checkCollisions: boolean;
  35351. /**
  35352. * Defines the collision radius of the camera.
  35353. * This simulates a sphere around the camera.
  35354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35355. */
  35356. collisionRadius: Vector3;
  35357. protected _collider: Collider;
  35358. protected _previousPosition: Vector3;
  35359. protected _collisionVelocity: Vector3;
  35360. protected _newPosition: Vector3;
  35361. protected _previousAlpha: number;
  35362. protected _previousBeta: number;
  35363. protected _previousRadius: number;
  35364. protected _collisionTriggered: boolean;
  35365. protected _targetBoundingCenter: Nullable<Vector3>;
  35366. private _computationVector;
  35367. private _tempAxisVector;
  35368. private _tempAxisRotationMatrix;
  35369. /**
  35370. * Instantiates a new ArcRotateCamera in a given scene
  35371. * @param name Defines the name of the camera
  35372. * @param alpha Defines the camera rotation along the logitudinal axis
  35373. * @param beta Defines the camera rotation along the latitudinal axis
  35374. * @param radius Defines the camera distance from its target
  35375. * @param target Defines the camera target
  35376. * @param scene Defines the scene the camera belongs to
  35377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35378. */
  35379. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35380. /** @hidden */
  35381. _initCache(): void;
  35382. /** @hidden */
  35383. _updateCache(ignoreParentClass?: boolean): void;
  35384. protected _getTargetPosition(): Vector3;
  35385. private _storedAlpha;
  35386. private _storedBeta;
  35387. private _storedRadius;
  35388. private _storedTarget;
  35389. /**
  35390. * Stores the current state of the camera (alpha, beta, radius and target)
  35391. * @returns the camera itself
  35392. */
  35393. storeState(): Camera;
  35394. /**
  35395. * @hidden
  35396. * Restored camera state. You must call storeState() first
  35397. */
  35398. _restoreStateValues(): boolean;
  35399. /** @hidden */
  35400. _isSynchronizedViewMatrix(): boolean;
  35401. /**
  35402. * Attached controls to the current camera.
  35403. * @param element Defines the element the controls should be listened from
  35404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35405. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35406. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35407. */
  35408. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35409. /**
  35410. * Detach the current controls from the camera.
  35411. * The camera will stop reacting to inputs.
  35412. * @param element Defines the element to stop listening the inputs from
  35413. */
  35414. detachControl(element: HTMLElement): void;
  35415. /** @hidden */
  35416. _checkInputs(): void;
  35417. protected _checkLimits(): void;
  35418. /**
  35419. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35420. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35421. */
  35422. rebuildAnglesAndRadius(updateView?: boolean): void;
  35423. /**
  35424. * Use a position to define the current camera related information like aplha, beta and radius
  35425. * @param position Defines the position to set the camera at
  35426. */
  35427. setPosition(position: Vector3): void;
  35428. /**
  35429. * Defines the target the camera should look at.
  35430. * This will automatically adapt alpha beta and radius to fit within the new target.
  35431. * @param target Defines the new target as a Vector or a mesh
  35432. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35433. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35434. */
  35435. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35436. /** @hidden */
  35437. _getViewMatrix(): Matrix;
  35438. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35439. /**
  35440. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35441. * @param meshes Defines the mesh to zoom on
  35442. * @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)
  35443. */
  35444. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35445. /**
  35446. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35447. * The target will be changed but the radius
  35448. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35449. * @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)
  35450. */
  35451. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35452. min: Vector3;
  35453. max: Vector3;
  35454. distance: number;
  35455. }, doNotUpdateMaxZ?: boolean): void;
  35456. /**
  35457. * @override
  35458. * Override Camera.createRigCamera
  35459. */
  35460. createRigCamera(name: string, cameraIndex: number): Camera;
  35461. /**
  35462. * @hidden
  35463. * @override
  35464. * Override Camera._updateRigCameras
  35465. */
  35466. _updateRigCameras(): void;
  35467. /**
  35468. * Destroy the camera and release the current resources hold by it.
  35469. */
  35470. dispose(): void;
  35471. /**
  35472. * Gets the current object class name.
  35473. * @return the class name
  35474. */
  35475. getClassName(): string;
  35476. }
  35477. }
  35478. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35479. import { Behavior } from "babylonjs/Behaviors/behavior";
  35480. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35481. /**
  35482. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35484. */
  35485. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35486. /**
  35487. * Gets the name of the behavior.
  35488. */
  35489. readonly name: string;
  35490. private _zoomStopsAnimation;
  35491. private _idleRotationSpeed;
  35492. private _idleRotationWaitTime;
  35493. private _idleRotationSpinupTime;
  35494. /**
  35495. * Sets the flag that indicates if user zooming should stop animation.
  35496. */
  35497. /**
  35498. * Gets the flag that indicates if user zooming should stop animation.
  35499. */
  35500. zoomStopsAnimation: boolean;
  35501. /**
  35502. * Sets the default speed at which the camera rotates around the model.
  35503. */
  35504. /**
  35505. * Gets the default speed at which the camera rotates around the model.
  35506. */
  35507. idleRotationSpeed: number;
  35508. /**
  35509. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35510. */
  35511. /**
  35512. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35513. */
  35514. idleRotationWaitTime: number;
  35515. /**
  35516. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35517. */
  35518. /**
  35519. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35520. */
  35521. idleRotationSpinupTime: number;
  35522. /**
  35523. * Gets a value indicating if the camera is currently rotating because of this behavior
  35524. */
  35525. readonly rotationInProgress: boolean;
  35526. private _onPrePointerObservableObserver;
  35527. private _onAfterCheckInputsObserver;
  35528. private _attachedCamera;
  35529. private _isPointerDown;
  35530. private _lastFrameTime;
  35531. private _lastInteractionTime;
  35532. private _cameraRotationSpeed;
  35533. /**
  35534. * Initializes the behavior.
  35535. */
  35536. init(): void;
  35537. /**
  35538. * Attaches the behavior to its arc rotate camera.
  35539. * @param camera Defines the camera to attach the behavior to
  35540. */
  35541. attach(camera: ArcRotateCamera): void;
  35542. /**
  35543. * Detaches the behavior from its current arc rotate camera.
  35544. */
  35545. detach(): void;
  35546. /**
  35547. * Returns true if user is scrolling.
  35548. * @return true if user is scrolling.
  35549. */
  35550. private _userIsZooming;
  35551. private _lastFrameRadius;
  35552. private _shouldAnimationStopForInteraction;
  35553. /**
  35554. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35555. */
  35556. private _applyUserInteraction;
  35557. private _userIsMoving;
  35558. }
  35559. }
  35560. declare module "babylonjs/Behaviors/Cameras/index" {
  35561. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35562. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35563. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35564. }
  35565. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35568. import { Behavior } from "babylonjs/Behaviors/behavior";
  35569. /**
  35570. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35571. */
  35572. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35573. private ui;
  35574. /**
  35575. * The name of the behavior
  35576. */
  35577. name: string;
  35578. /**
  35579. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35580. */
  35581. distanceAwayFromFace: number;
  35582. /**
  35583. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35584. */
  35585. distanceAwayFromBottomOfFace: number;
  35586. private _faceVectors;
  35587. private _target;
  35588. private _scene;
  35589. private _onRenderObserver;
  35590. private _tmpMatrix;
  35591. private _tmpVector;
  35592. /**
  35593. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35594. * @param ui The transform node that should be attched to the mesh
  35595. */
  35596. constructor(ui: TransformNode);
  35597. /**
  35598. * Initializes the behavior
  35599. */
  35600. init(): void;
  35601. private _closestFace;
  35602. private _zeroVector;
  35603. private _lookAtTmpMatrix;
  35604. private _lookAtToRef;
  35605. /**
  35606. * Attaches the AttachToBoxBehavior to the passed in mesh
  35607. * @param target The mesh that the specified node will be attached to
  35608. */
  35609. attach(target: Mesh): void;
  35610. /**
  35611. * Detaches the behavior from the mesh
  35612. */
  35613. detach(): void;
  35614. }
  35615. }
  35616. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35617. import { Behavior } from "babylonjs/Behaviors/behavior";
  35618. import { Mesh } from "babylonjs/Meshes/mesh";
  35619. /**
  35620. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35621. */
  35622. export class FadeInOutBehavior implements Behavior<Mesh> {
  35623. /**
  35624. * Time in milliseconds to delay before fading in (Default: 0)
  35625. */
  35626. delay: number;
  35627. /**
  35628. * Time in milliseconds for the mesh to fade in (Default: 300)
  35629. */
  35630. fadeInTime: number;
  35631. private _millisecondsPerFrame;
  35632. private _hovered;
  35633. private _hoverValue;
  35634. private _ownerNode;
  35635. /**
  35636. * Instatiates the FadeInOutBehavior
  35637. */
  35638. constructor();
  35639. /**
  35640. * The name of the behavior
  35641. */
  35642. readonly name: string;
  35643. /**
  35644. * Initializes the behavior
  35645. */
  35646. init(): void;
  35647. /**
  35648. * Attaches the fade behavior on the passed in mesh
  35649. * @param ownerNode The mesh that will be faded in/out once attached
  35650. */
  35651. attach(ownerNode: Mesh): void;
  35652. /**
  35653. * Detaches the behavior from the mesh
  35654. */
  35655. detach(): void;
  35656. /**
  35657. * Triggers the mesh to begin fading in or out
  35658. * @param value if the object should fade in or out (true to fade in)
  35659. */
  35660. fadeIn(value: boolean): void;
  35661. private _update;
  35662. private _setAllVisibility;
  35663. }
  35664. }
  35665. declare module "babylonjs/Misc/pivotTools" {
  35666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35667. /**
  35668. * Class containing a set of static utilities functions for managing Pivots
  35669. * @hidden
  35670. */
  35671. export class PivotTools {
  35672. private static _PivotCached;
  35673. private static _OldPivotPoint;
  35674. private static _PivotTranslation;
  35675. private static _PivotTmpVector;
  35676. /** @hidden */
  35677. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35678. /** @hidden */
  35679. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35680. }
  35681. }
  35682. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35683. import { Scene } from "babylonjs/scene";
  35684. import { Vector4, Plane } from "babylonjs/Maths/math";
  35685. import { Mesh } from "babylonjs/Meshes/mesh";
  35686. /**
  35687. * Class containing static functions to help procedurally build meshes
  35688. */
  35689. export class PlaneBuilder {
  35690. /**
  35691. * Creates a plane mesh
  35692. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35693. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35694. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35696. * * If you create a double-sided mesh, you can choose what parts of 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
  35697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35698. * @param name defines the name of the mesh
  35699. * @param options defines the options used to create the mesh
  35700. * @param scene defines the hosting scene
  35701. * @returns the plane mesh
  35702. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35703. */
  35704. static CreatePlane(name: string, options: {
  35705. size?: number;
  35706. width?: number;
  35707. height?: number;
  35708. sideOrientation?: number;
  35709. frontUVs?: Vector4;
  35710. backUVs?: Vector4;
  35711. updatable?: boolean;
  35712. sourcePlane?: Plane;
  35713. }, scene: Scene): Mesh;
  35714. }
  35715. }
  35716. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35717. import { Behavior } from "babylonjs/Behaviors/behavior";
  35718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35719. import { Observable } from "babylonjs/Misc/observable";
  35720. import { Vector3 } from "babylonjs/Maths/math";
  35721. import { Ray } from "babylonjs/Culling/ray";
  35722. import "babylonjs/Meshes/Builders/planeBuilder";
  35723. /**
  35724. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35725. */
  35726. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35727. private static _AnyMouseID;
  35728. private _attachedNode;
  35729. private _dragPlane;
  35730. private _scene;
  35731. private _pointerObserver;
  35732. private _beforeRenderObserver;
  35733. private static _planeScene;
  35734. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35735. /**
  35736. * 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)
  35737. */
  35738. maxDragAngle: number;
  35739. /**
  35740. * @hidden
  35741. */
  35742. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35743. /**
  35744. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35745. */
  35746. currentDraggingPointerID: number;
  35747. /**
  35748. * The last position where the pointer hit the drag plane in world space
  35749. */
  35750. lastDragPosition: Vector3;
  35751. /**
  35752. * If the behavior is currently in a dragging state
  35753. */
  35754. dragging: boolean;
  35755. /**
  35756. * 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)
  35757. */
  35758. dragDeltaRatio: number;
  35759. /**
  35760. * If the drag plane orientation should be updated during the dragging (Default: true)
  35761. */
  35762. updateDragPlane: boolean;
  35763. private _debugMode;
  35764. private _moving;
  35765. /**
  35766. * Fires each time the attached mesh is dragged with the pointer
  35767. * * delta between last drag position and current drag position in world space
  35768. * * dragDistance along the drag axis
  35769. * * dragPlaneNormal normal of the current drag plane used during the drag
  35770. * * dragPlanePoint in world space where the drag intersects the drag plane
  35771. */
  35772. onDragObservable: Observable<{
  35773. delta: Vector3;
  35774. dragPlanePoint: Vector3;
  35775. dragPlaneNormal: Vector3;
  35776. dragDistance: number;
  35777. pointerId: number;
  35778. }>;
  35779. /**
  35780. * Fires each time a drag begins (eg. mouse down on mesh)
  35781. */
  35782. onDragStartObservable: Observable<{
  35783. dragPlanePoint: Vector3;
  35784. pointerId: number;
  35785. }>;
  35786. /**
  35787. * Fires each time a drag ends (eg. mouse release after drag)
  35788. */
  35789. onDragEndObservable: Observable<{
  35790. dragPlanePoint: Vector3;
  35791. pointerId: number;
  35792. }>;
  35793. /**
  35794. * If the attached mesh should be moved when dragged
  35795. */
  35796. moveAttached: boolean;
  35797. /**
  35798. * If the drag behavior will react to drag events (Default: true)
  35799. */
  35800. enabled: boolean;
  35801. /**
  35802. * If camera controls should be detached during the drag
  35803. */
  35804. detachCameraControls: boolean;
  35805. /**
  35806. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35807. */
  35808. useObjectOrienationForDragging: boolean;
  35809. private _options;
  35810. /**
  35811. * Creates a pointer drag behavior that can be attached to a mesh
  35812. * @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)
  35813. */
  35814. constructor(options?: {
  35815. dragAxis?: Vector3;
  35816. dragPlaneNormal?: Vector3;
  35817. });
  35818. /**
  35819. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35820. */
  35821. validateDrag: (targetPosition: Vector3) => boolean;
  35822. /**
  35823. * The name of the behavior
  35824. */
  35825. readonly name: string;
  35826. /**
  35827. * Initializes the behavior
  35828. */
  35829. init(): void;
  35830. private _tmpVector;
  35831. private _alternatePickedPoint;
  35832. private _worldDragAxis;
  35833. private _targetPosition;
  35834. private _attachedElement;
  35835. /**
  35836. * Attaches the drag behavior the passed in mesh
  35837. * @param ownerNode The mesh that will be dragged around once attached
  35838. */
  35839. attach(ownerNode: AbstractMesh): void;
  35840. /**
  35841. * Force relase the drag action by code.
  35842. */
  35843. releaseDrag(): void;
  35844. private _startDragRay;
  35845. private _lastPointerRay;
  35846. /**
  35847. * Simulates the start of a pointer drag event on the behavior
  35848. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35849. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35850. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35851. */
  35852. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35853. private _startDrag;
  35854. private _dragDelta;
  35855. private _moveDrag;
  35856. private _pickWithRayOnDragPlane;
  35857. private _pointA;
  35858. private _pointB;
  35859. private _pointC;
  35860. private _lineA;
  35861. private _lineB;
  35862. private _localAxis;
  35863. private _lookAt;
  35864. private _updateDragPlanePosition;
  35865. /**
  35866. * Detaches the behavior from the mesh
  35867. */
  35868. detach(): void;
  35869. }
  35870. }
  35871. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35872. import { Mesh } from "babylonjs/Meshes/mesh";
  35873. import { Behavior } from "babylonjs/Behaviors/behavior";
  35874. /**
  35875. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35876. */
  35877. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35878. private _dragBehaviorA;
  35879. private _dragBehaviorB;
  35880. private _startDistance;
  35881. private _initialScale;
  35882. private _targetScale;
  35883. private _ownerNode;
  35884. private _sceneRenderObserver;
  35885. /**
  35886. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35887. */
  35888. constructor();
  35889. /**
  35890. * The name of the behavior
  35891. */
  35892. readonly name: string;
  35893. /**
  35894. * Initializes the behavior
  35895. */
  35896. init(): void;
  35897. private _getCurrentDistance;
  35898. /**
  35899. * Attaches the scale behavior the passed in mesh
  35900. * @param ownerNode The mesh that will be scaled around once attached
  35901. */
  35902. attach(ownerNode: Mesh): void;
  35903. /**
  35904. * Detaches the behavior from the mesh
  35905. */
  35906. detach(): void;
  35907. }
  35908. }
  35909. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35910. import { Behavior } from "babylonjs/Behaviors/behavior";
  35911. import { Mesh } from "babylonjs/Meshes/mesh";
  35912. import { Observable } from "babylonjs/Misc/observable";
  35913. /**
  35914. * 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
  35915. */
  35916. export class SixDofDragBehavior implements Behavior<Mesh> {
  35917. private static _virtualScene;
  35918. private _ownerNode;
  35919. private _sceneRenderObserver;
  35920. private _scene;
  35921. private _targetPosition;
  35922. private _virtualOriginMesh;
  35923. private _virtualDragMesh;
  35924. private _pointerObserver;
  35925. private _moving;
  35926. private _startingOrientation;
  35927. /**
  35928. * 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)
  35929. */
  35930. private zDragFactor;
  35931. /**
  35932. * If the object should rotate to face the drag origin
  35933. */
  35934. rotateDraggedObject: boolean;
  35935. /**
  35936. * If the behavior is currently in a dragging state
  35937. */
  35938. dragging: boolean;
  35939. /**
  35940. * 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)
  35941. */
  35942. dragDeltaRatio: number;
  35943. /**
  35944. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35945. */
  35946. currentDraggingPointerID: number;
  35947. /**
  35948. * If camera controls should be detached during the drag
  35949. */
  35950. detachCameraControls: boolean;
  35951. /**
  35952. * Fires each time a drag starts
  35953. */
  35954. onDragStartObservable: Observable<{}>;
  35955. /**
  35956. * Fires each time a drag ends (eg. mouse release after drag)
  35957. */
  35958. onDragEndObservable: Observable<{}>;
  35959. /**
  35960. * 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
  35961. */
  35962. constructor();
  35963. /**
  35964. * The name of the behavior
  35965. */
  35966. readonly name: string;
  35967. /**
  35968. * Initializes the behavior
  35969. */
  35970. init(): void;
  35971. /**
  35972. * Attaches the scale behavior the passed in mesh
  35973. * @param ownerNode The mesh that will be scaled around once attached
  35974. */
  35975. attach(ownerNode: Mesh): void;
  35976. /**
  35977. * Detaches the behavior from the mesh
  35978. */
  35979. detach(): void;
  35980. }
  35981. }
  35982. declare module "babylonjs/Behaviors/Meshes/index" {
  35983. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35984. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35985. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35986. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35987. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35988. }
  35989. declare module "babylonjs/Behaviors/index" {
  35990. export * from "babylonjs/Behaviors/behavior";
  35991. export * from "babylonjs/Behaviors/Cameras/index";
  35992. export * from "babylonjs/Behaviors/Meshes/index";
  35993. }
  35994. declare module "babylonjs/Bones/boneIKController" {
  35995. import { Bone } from "babylonjs/Bones/bone";
  35996. import { Vector3 } from "babylonjs/Maths/math";
  35997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35998. import { Nullable } from "babylonjs/types";
  35999. /**
  36000. * Class used to apply inverse kinematics to bones
  36001. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36002. */
  36003. export class BoneIKController {
  36004. private static _tmpVecs;
  36005. private static _tmpQuat;
  36006. private static _tmpMats;
  36007. /**
  36008. * Gets or sets the target mesh
  36009. */
  36010. targetMesh: AbstractMesh;
  36011. /** Gets or sets the mesh used as pole */
  36012. poleTargetMesh: AbstractMesh;
  36013. /**
  36014. * Gets or sets the bone used as pole
  36015. */
  36016. poleTargetBone: Nullable<Bone>;
  36017. /**
  36018. * Gets or sets the target position
  36019. */
  36020. targetPosition: Vector3;
  36021. /**
  36022. * Gets or sets the pole target position
  36023. */
  36024. poleTargetPosition: Vector3;
  36025. /**
  36026. * Gets or sets the pole target local offset
  36027. */
  36028. poleTargetLocalOffset: Vector3;
  36029. /**
  36030. * Gets or sets the pole angle
  36031. */
  36032. poleAngle: number;
  36033. /**
  36034. * Gets or sets the mesh associated with the controller
  36035. */
  36036. mesh: AbstractMesh;
  36037. /**
  36038. * 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)
  36039. */
  36040. slerpAmount: number;
  36041. private _bone1Quat;
  36042. private _bone1Mat;
  36043. private _bone2Ang;
  36044. private _bone1;
  36045. private _bone2;
  36046. private _bone1Length;
  36047. private _bone2Length;
  36048. private _maxAngle;
  36049. private _maxReach;
  36050. private _rightHandedSystem;
  36051. private _bendAxis;
  36052. private _slerping;
  36053. private _adjustRoll;
  36054. /**
  36055. * Gets or sets maximum allowed angle
  36056. */
  36057. maxAngle: number;
  36058. /**
  36059. * Creates a new BoneIKController
  36060. * @param mesh defines the mesh to control
  36061. * @param bone defines the bone to control
  36062. * @param options defines options to set up the controller
  36063. */
  36064. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36065. targetMesh?: AbstractMesh;
  36066. poleTargetMesh?: AbstractMesh;
  36067. poleTargetBone?: Bone;
  36068. poleTargetLocalOffset?: Vector3;
  36069. poleAngle?: number;
  36070. bendAxis?: Vector3;
  36071. maxAngle?: number;
  36072. slerpAmount?: number;
  36073. });
  36074. private _setMaxAngle;
  36075. /**
  36076. * Force the controller to update the bones
  36077. */
  36078. update(): void;
  36079. }
  36080. }
  36081. declare module "babylonjs/Bones/boneLookController" {
  36082. import { Vector3, Space } from "babylonjs/Maths/math";
  36083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36084. import { Bone } from "babylonjs/Bones/bone";
  36085. /**
  36086. * Class used to make a bone look toward a point in space
  36087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36088. */
  36089. export class BoneLookController {
  36090. private static _tmpVecs;
  36091. private static _tmpQuat;
  36092. private static _tmpMats;
  36093. /**
  36094. * The target Vector3 that the bone will look at
  36095. */
  36096. target: Vector3;
  36097. /**
  36098. * The mesh that the bone is attached to
  36099. */
  36100. mesh: AbstractMesh;
  36101. /**
  36102. * The bone that will be looking to the target
  36103. */
  36104. bone: Bone;
  36105. /**
  36106. * The up axis of the coordinate system that is used when the bone is rotated
  36107. */
  36108. upAxis: Vector3;
  36109. /**
  36110. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36111. */
  36112. upAxisSpace: Space;
  36113. /**
  36114. * Used to make an adjustment to the yaw of the bone
  36115. */
  36116. adjustYaw: number;
  36117. /**
  36118. * Used to make an adjustment to the pitch of the bone
  36119. */
  36120. adjustPitch: number;
  36121. /**
  36122. * Used to make an adjustment to the roll of the bone
  36123. */
  36124. adjustRoll: number;
  36125. /**
  36126. * 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)
  36127. */
  36128. slerpAmount: number;
  36129. private _minYaw;
  36130. private _maxYaw;
  36131. private _minPitch;
  36132. private _maxPitch;
  36133. private _minYawSin;
  36134. private _minYawCos;
  36135. private _maxYawSin;
  36136. private _maxYawCos;
  36137. private _midYawConstraint;
  36138. private _minPitchTan;
  36139. private _maxPitchTan;
  36140. private _boneQuat;
  36141. private _slerping;
  36142. private _transformYawPitch;
  36143. private _transformYawPitchInv;
  36144. private _firstFrameSkipped;
  36145. private _yawRange;
  36146. private _fowardAxis;
  36147. /**
  36148. * Gets or sets the minimum yaw angle that the bone can look to
  36149. */
  36150. minYaw: number;
  36151. /**
  36152. * Gets or sets the maximum yaw angle that the bone can look to
  36153. */
  36154. maxYaw: number;
  36155. /**
  36156. * Gets or sets the minimum pitch angle that the bone can look to
  36157. */
  36158. minPitch: number;
  36159. /**
  36160. * Gets or sets the maximum pitch angle that the bone can look to
  36161. */
  36162. maxPitch: number;
  36163. /**
  36164. * Create a BoneLookController
  36165. * @param mesh the mesh that the bone belongs to
  36166. * @param bone the bone that will be looking to the target
  36167. * @param target the target Vector3 to look at
  36168. * @param options optional settings:
  36169. * * maxYaw: the maximum angle the bone will yaw to
  36170. * * minYaw: the minimum angle the bone will yaw to
  36171. * * maxPitch: the maximum angle the bone will pitch to
  36172. * * minPitch: the minimum angle the bone will yaw to
  36173. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36174. * * upAxis: the up axis of the coordinate system
  36175. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36176. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36177. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36178. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36179. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36180. * * adjustRoll: used to make an adjustment to the roll of the bone
  36181. **/
  36182. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36183. maxYaw?: number;
  36184. minYaw?: number;
  36185. maxPitch?: number;
  36186. minPitch?: number;
  36187. slerpAmount?: number;
  36188. upAxis?: Vector3;
  36189. upAxisSpace?: Space;
  36190. yawAxis?: Vector3;
  36191. pitchAxis?: Vector3;
  36192. adjustYaw?: number;
  36193. adjustPitch?: number;
  36194. adjustRoll?: number;
  36195. });
  36196. /**
  36197. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36198. */
  36199. update(): void;
  36200. private _getAngleDiff;
  36201. private _getAngleBetween;
  36202. private _isAngleBetween;
  36203. }
  36204. }
  36205. declare module "babylonjs/Bones/index" {
  36206. export * from "babylonjs/Bones/bone";
  36207. export * from "babylonjs/Bones/boneIKController";
  36208. export * from "babylonjs/Bones/boneLookController";
  36209. export * from "babylonjs/Bones/skeleton";
  36210. }
  36211. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36212. import { Nullable } from "babylonjs/types";
  36213. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36214. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36215. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36216. /**
  36217. * Manage the gamepad inputs to control an arc rotate camera.
  36218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36219. */
  36220. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36221. /**
  36222. * Defines the camera the input is attached to.
  36223. */
  36224. camera: ArcRotateCamera;
  36225. /**
  36226. * Defines the gamepad the input is gathering event from.
  36227. */
  36228. gamepad: Nullable<Gamepad>;
  36229. /**
  36230. * Defines the gamepad rotation sensiblity.
  36231. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36232. */
  36233. gamepadRotationSensibility: number;
  36234. /**
  36235. * Defines the gamepad move sensiblity.
  36236. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36237. */
  36238. gamepadMoveSensibility: number;
  36239. private _onGamepadConnectedObserver;
  36240. private _onGamepadDisconnectedObserver;
  36241. /**
  36242. * Attach the input controls to a specific dom element to get the input from.
  36243. * @param element Defines the element the controls should be listened from
  36244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36245. */
  36246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36247. /**
  36248. * Detach the current controls from the specified dom element.
  36249. * @param element Defines the element to stop listening the inputs from
  36250. */
  36251. detachControl(element: Nullable<HTMLElement>): void;
  36252. /**
  36253. * Update the current camera state depending on the inputs that have been used this frame.
  36254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36255. */
  36256. checkInputs(): void;
  36257. /**
  36258. * Gets the class name of the current intput.
  36259. * @returns the class name
  36260. */
  36261. getClassName(): string;
  36262. /**
  36263. * Get the friendly name associated with the input class.
  36264. * @returns the input friendly name
  36265. */
  36266. getSimpleName(): string;
  36267. }
  36268. }
  36269. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36270. import { Nullable } from "babylonjs/types";
  36271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36273. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36274. interface ArcRotateCameraInputsManager {
  36275. /**
  36276. * Add orientation input support to the input manager.
  36277. * @returns the current input manager
  36278. */
  36279. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36280. }
  36281. }
  36282. /**
  36283. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36285. */
  36286. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36287. /**
  36288. * Defines the camera the input is attached to.
  36289. */
  36290. camera: ArcRotateCamera;
  36291. /**
  36292. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36293. */
  36294. alphaCorrection: number;
  36295. /**
  36296. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36297. */
  36298. gammaCorrection: number;
  36299. private _alpha;
  36300. private _gamma;
  36301. private _dirty;
  36302. private _deviceOrientationHandler;
  36303. /**
  36304. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36305. */
  36306. constructor();
  36307. /**
  36308. * Attach the input controls to a specific dom element to get the input from.
  36309. * @param element Defines the element the controls should be listened from
  36310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36311. */
  36312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36313. /** @hidden */
  36314. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36315. /**
  36316. * Update the current camera state depending on the inputs that have been used this frame.
  36317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36318. */
  36319. checkInputs(): void;
  36320. /**
  36321. * Detach the current controls from the specified dom element.
  36322. * @param element Defines the element to stop listening the inputs from
  36323. */
  36324. detachControl(element: Nullable<HTMLElement>): void;
  36325. /**
  36326. * Gets the class name of the current intput.
  36327. * @returns the class name
  36328. */
  36329. getClassName(): string;
  36330. /**
  36331. * Get the friendly name associated with the input class.
  36332. * @returns the input friendly name
  36333. */
  36334. getSimpleName(): string;
  36335. }
  36336. }
  36337. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36338. import { Nullable } from "babylonjs/types";
  36339. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36340. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36341. /**
  36342. * Listen to mouse events to control the camera.
  36343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36344. */
  36345. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36346. /**
  36347. * Defines the camera the input is attached to.
  36348. */
  36349. camera: FlyCamera;
  36350. /**
  36351. * Defines if touch is enabled. (Default is true.)
  36352. */
  36353. touchEnabled: boolean;
  36354. /**
  36355. * Defines the buttons associated with the input to handle camera rotation.
  36356. */
  36357. buttons: number[];
  36358. /**
  36359. * Assign buttons for Yaw control.
  36360. */
  36361. buttonsYaw: number[];
  36362. /**
  36363. * Assign buttons for Pitch control.
  36364. */
  36365. buttonsPitch: number[];
  36366. /**
  36367. * Assign buttons for Roll control.
  36368. */
  36369. buttonsRoll: number[];
  36370. /**
  36371. * Detect if any button is being pressed while mouse is moved.
  36372. * -1 = Mouse locked.
  36373. * 0 = Left button.
  36374. * 1 = Middle Button.
  36375. * 2 = Right Button.
  36376. */
  36377. activeButton: number;
  36378. /**
  36379. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36380. * Higher values reduce its sensitivity.
  36381. */
  36382. angularSensibility: number;
  36383. private _mousemoveCallback;
  36384. private _observer;
  36385. private _rollObserver;
  36386. private previousPosition;
  36387. private noPreventDefault;
  36388. private element;
  36389. /**
  36390. * Listen to mouse events to control the camera.
  36391. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36393. */
  36394. constructor(touchEnabled?: boolean);
  36395. /**
  36396. * Attach the mouse control to the HTML DOM element.
  36397. * @param element Defines the element that listens to the input events.
  36398. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36399. */
  36400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36401. /**
  36402. * Detach the current controls from the specified dom element.
  36403. * @param element Defines the element to stop listening the inputs from
  36404. */
  36405. detachControl(element: Nullable<HTMLElement>): void;
  36406. /**
  36407. * Gets the class name of the current input.
  36408. * @returns the class name.
  36409. */
  36410. getClassName(): string;
  36411. /**
  36412. * Get the friendly name associated with the input class.
  36413. * @returns the input's friendly name.
  36414. */
  36415. getSimpleName(): string;
  36416. private _pointerInput;
  36417. private _onMouseMove;
  36418. /**
  36419. * Rotate camera by mouse offset.
  36420. */
  36421. private rotateCamera;
  36422. }
  36423. }
  36424. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36425. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36426. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36427. /**
  36428. * Default Inputs manager for the FlyCamera.
  36429. * It groups all the default supported inputs for ease of use.
  36430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36431. */
  36432. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36433. /**
  36434. * Instantiates a new FlyCameraInputsManager.
  36435. * @param camera Defines the camera the inputs belong to.
  36436. */
  36437. constructor(camera: FlyCamera);
  36438. /**
  36439. * Add keyboard input support to the input manager.
  36440. * @returns the new FlyCameraKeyboardMoveInput().
  36441. */
  36442. addKeyboard(): FlyCameraInputsManager;
  36443. /**
  36444. * Add mouse input support to the input manager.
  36445. * @param touchEnabled Enable touch screen support.
  36446. * @returns the new FlyCameraMouseInput().
  36447. */
  36448. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36449. }
  36450. }
  36451. declare module "babylonjs/Cameras/flyCamera" {
  36452. import { Scene } from "babylonjs/scene";
  36453. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36456. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36457. /**
  36458. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36459. * such as in a 3D Space Shooter or a Flight Simulator.
  36460. */
  36461. export class FlyCamera extends TargetCamera {
  36462. /**
  36463. * Define the collision ellipsoid of the camera.
  36464. * This is helpful for simulating a camera body, like a player's body.
  36465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36466. */
  36467. ellipsoid: Vector3;
  36468. /**
  36469. * Define an offset for the position of the ellipsoid around the camera.
  36470. * This can be helpful if the camera is attached away from the player's body center,
  36471. * such as at its head.
  36472. */
  36473. ellipsoidOffset: Vector3;
  36474. /**
  36475. * Enable or disable collisions of the camera with the rest of the scene objects.
  36476. */
  36477. checkCollisions: boolean;
  36478. /**
  36479. * Enable or disable gravity on the camera.
  36480. */
  36481. applyGravity: boolean;
  36482. /**
  36483. * Define the current direction the camera is moving to.
  36484. */
  36485. cameraDirection: Vector3;
  36486. /**
  36487. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36488. * This overrides and empties cameraRotation.
  36489. */
  36490. rotationQuaternion: Quaternion;
  36491. /**
  36492. * Track Roll to maintain the wanted Rolling when looking around.
  36493. */
  36494. _trackRoll: number;
  36495. /**
  36496. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36497. */
  36498. rollCorrect: number;
  36499. /**
  36500. * Mimic a banked turn, Rolling the camera when Yawing.
  36501. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36502. */
  36503. bankedTurn: boolean;
  36504. /**
  36505. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36506. */
  36507. bankedTurnLimit: number;
  36508. /**
  36509. * Value of 0 disables the banked Roll.
  36510. * Value of 1 is equal to the Yaw angle in radians.
  36511. */
  36512. bankedTurnMultiplier: number;
  36513. /**
  36514. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36515. */
  36516. inputs: FlyCameraInputsManager;
  36517. /**
  36518. * Gets the input sensibility for mouse input.
  36519. * Higher values reduce sensitivity.
  36520. */
  36521. /**
  36522. * Sets the input sensibility for a mouse input.
  36523. * Higher values reduce sensitivity.
  36524. */
  36525. angularSensibility: number;
  36526. /**
  36527. * Get the keys for camera movement forward.
  36528. */
  36529. /**
  36530. * Set the keys for camera movement forward.
  36531. */
  36532. keysForward: number[];
  36533. /**
  36534. * Get the keys for camera movement backward.
  36535. */
  36536. keysBackward: number[];
  36537. /**
  36538. * Get the keys for camera movement up.
  36539. */
  36540. /**
  36541. * Set the keys for camera movement up.
  36542. */
  36543. keysUp: number[];
  36544. /**
  36545. * Get the keys for camera movement down.
  36546. */
  36547. /**
  36548. * Set the keys for camera movement down.
  36549. */
  36550. keysDown: number[];
  36551. /**
  36552. * Get the keys for camera movement left.
  36553. */
  36554. /**
  36555. * Set the keys for camera movement left.
  36556. */
  36557. keysLeft: number[];
  36558. /**
  36559. * Set the keys for camera movement right.
  36560. */
  36561. /**
  36562. * Set the keys for camera movement right.
  36563. */
  36564. keysRight: number[];
  36565. /**
  36566. * Event raised when the camera collides with a mesh in the scene.
  36567. */
  36568. onCollide: (collidedMesh: AbstractMesh) => void;
  36569. private _collider;
  36570. private _needMoveForGravity;
  36571. private _oldPosition;
  36572. private _diffPosition;
  36573. private _newPosition;
  36574. /** @hidden */
  36575. _localDirection: Vector3;
  36576. /** @hidden */
  36577. _transformedDirection: Vector3;
  36578. /**
  36579. * Instantiates a FlyCamera.
  36580. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36581. * such as in a 3D Space Shooter or a Flight Simulator.
  36582. * @param name Define the name of the camera in the scene.
  36583. * @param position Define the starting position of the camera in the scene.
  36584. * @param scene Define the scene the camera belongs to.
  36585. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36586. */
  36587. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36588. /**
  36589. * Attach a control to the HTML DOM element.
  36590. * @param element Defines the element that listens to the input events.
  36591. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36592. */
  36593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36594. /**
  36595. * Detach a control from the HTML DOM element.
  36596. * The camera will stop reacting to that input.
  36597. * @param element Defines the element that listens to the input events.
  36598. */
  36599. detachControl(element: HTMLElement): void;
  36600. private _collisionMask;
  36601. /**
  36602. * Get the mask that the camera ignores in collision events.
  36603. */
  36604. /**
  36605. * Set the mask that the camera ignores in collision events.
  36606. */
  36607. collisionMask: number;
  36608. /** @hidden */
  36609. _collideWithWorld(displacement: Vector3): void;
  36610. /** @hidden */
  36611. private _onCollisionPositionChange;
  36612. /** @hidden */
  36613. _checkInputs(): void;
  36614. /** @hidden */
  36615. _decideIfNeedsToMove(): boolean;
  36616. /** @hidden */
  36617. _updatePosition(): void;
  36618. /**
  36619. * Restore the Roll to its target value at the rate specified.
  36620. * @param rate - Higher means slower restoring.
  36621. * @hidden
  36622. */
  36623. restoreRoll(rate: number): void;
  36624. /**
  36625. * Destroy the camera and release the current resources held by it.
  36626. */
  36627. dispose(): void;
  36628. /**
  36629. * Get the current object class name.
  36630. * @returns the class name.
  36631. */
  36632. getClassName(): string;
  36633. }
  36634. }
  36635. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36636. import { Nullable } from "babylonjs/types";
  36637. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36638. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36639. /**
  36640. * Listen to keyboard events to control the camera.
  36641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36642. */
  36643. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36644. /**
  36645. * Defines the camera the input is attached to.
  36646. */
  36647. camera: FlyCamera;
  36648. /**
  36649. * The list of keyboard keys used to control the forward move of the camera.
  36650. */
  36651. keysForward: number[];
  36652. /**
  36653. * The list of keyboard keys used to control the backward move of the camera.
  36654. */
  36655. keysBackward: number[];
  36656. /**
  36657. * The list of keyboard keys used to control the forward move of the camera.
  36658. */
  36659. keysUp: number[];
  36660. /**
  36661. * The list of keyboard keys used to control the backward move of the camera.
  36662. */
  36663. keysDown: number[];
  36664. /**
  36665. * The list of keyboard keys used to control the right strafe move of the camera.
  36666. */
  36667. keysRight: number[];
  36668. /**
  36669. * The list of keyboard keys used to control the left strafe move of the camera.
  36670. */
  36671. keysLeft: number[];
  36672. private _keys;
  36673. private _onCanvasBlurObserver;
  36674. private _onKeyboardObserver;
  36675. private _engine;
  36676. private _scene;
  36677. /**
  36678. * Attach the input controls to a specific dom element to get the input from.
  36679. * @param element Defines the element the controls should be listened from
  36680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36681. */
  36682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36683. /**
  36684. * Detach the current controls from the specified dom element.
  36685. * @param element Defines the element to stop listening the inputs from
  36686. */
  36687. detachControl(element: Nullable<HTMLElement>): void;
  36688. /**
  36689. * Gets the class name of the current intput.
  36690. * @returns the class name
  36691. */
  36692. getClassName(): string;
  36693. /** @hidden */
  36694. _onLostFocus(e: FocusEvent): void;
  36695. /**
  36696. * Get the friendly name associated with the input class.
  36697. * @returns the input friendly name
  36698. */
  36699. getSimpleName(): string;
  36700. /**
  36701. * Update the current camera state depending on the inputs that have been used this frame.
  36702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36703. */
  36704. checkInputs(): void;
  36705. }
  36706. }
  36707. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36708. import { Nullable } from "babylonjs/types";
  36709. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36710. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36711. /**
  36712. * Manage the mouse wheel inputs to control a follow camera.
  36713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36714. */
  36715. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36716. /**
  36717. * Defines the camera the input is attached to.
  36718. */
  36719. camera: FollowCamera;
  36720. /**
  36721. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36722. */
  36723. axisControlRadius: boolean;
  36724. /**
  36725. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36726. */
  36727. axisControlHeight: boolean;
  36728. /**
  36729. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36730. */
  36731. axisControlRotation: boolean;
  36732. /**
  36733. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36734. * relation to mouseWheel events.
  36735. */
  36736. wheelPrecision: number;
  36737. /**
  36738. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36739. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36740. */
  36741. wheelDeltaPercentage: number;
  36742. private _wheel;
  36743. private _observer;
  36744. /**
  36745. * Attach the input controls to a specific dom element to get the input from.
  36746. * @param element Defines the element the controls should be listened from
  36747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36748. */
  36749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36750. /**
  36751. * Detach the current controls from the specified dom element.
  36752. * @param element Defines the element to stop listening the inputs from
  36753. */
  36754. detachControl(element: Nullable<HTMLElement>): void;
  36755. /**
  36756. * Gets the class name of the current intput.
  36757. * @returns the class name
  36758. */
  36759. getClassName(): string;
  36760. /**
  36761. * Get the friendly name associated with the input class.
  36762. * @returns the input friendly name
  36763. */
  36764. getSimpleName(): string;
  36765. }
  36766. }
  36767. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36768. import { Nullable } from "babylonjs/types";
  36769. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36770. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36771. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36772. /**
  36773. * Manage the pointers inputs to control an follow camera.
  36774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36775. */
  36776. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36777. /**
  36778. * Defines the camera the input is attached to.
  36779. */
  36780. camera: FollowCamera;
  36781. /**
  36782. * Gets the class name of the current input.
  36783. * @returns the class name
  36784. */
  36785. getClassName(): string;
  36786. /**
  36787. * Defines the pointer angular sensibility along the X axis or how fast is
  36788. * the camera rotating.
  36789. * A negative number will reverse the axis direction.
  36790. */
  36791. angularSensibilityX: number;
  36792. /**
  36793. * Defines the pointer angular sensibility along the Y axis or how fast is
  36794. * the camera rotating.
  36795. * A negative number will reverse the axis direction.
  36796. */
  36797. angularSensibilityY: number;
  36798. /**
  36799. * Defines the pointer pinch precision or how fast is the camera zooming.
  36800. * A negative number will reverse the axis direction.
  36801. */
  36802. pinchPrecision: number;
  36803. /**
  36804. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36805. * from 0.
  36806. * It defines the percentage of current camera.radius to use as delta when
  36807. * pinch zoom is used.
  36808. */
  36809. pinchDeltaPercentage: number;
  36810. /**
  36811. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36812. */
  36813. axisXControlRadius: boolean;
  36814. /**
  36815. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36816. */
  36817. axisXControlHeight: boolean;
  36818. /**
  36819. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36820. */
  36821. axisXControlRotation: boolean;
  36822. /**
  36823. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36824. */
  36825. axisYControlRadius: boolean;
  36826. /**
  36827. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36828. */
  36829. axisYControlHeight: boolean;
  36830. /**
  36831. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36832. */
  36833. axisYControlRotation: boolean;
  36834. /**
  36835. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36836. */
  36837. axisPinchControlRadius: boolean;
  36838. /**
  36839. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36840. */
  36841. axisPinchControlHeight: boolean;
  36842. /**
  36843. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36844. */
  36845. axisPinchControlRotation: boolean;
  36846. /**
  36847. * Log error messages if basic misconfiguration has occurred.
  36848. */
  36849. warningEnable: boolean;
  36850. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36851. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36852. private _warningCounter;
  36853. private _warning;
  36854. }
  36855. }
  36856. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36857. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36858. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36859. /**
  36860. * Default Inputs manager for the FollowCamera.
  36861. * It groups all the default supported inputs for ease of use.
  36862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36863. */
  36864. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36865. /**
  36866. * Instantiates a new FollowCameraInputsManager.
  36867. * @param camera Defines the camera the inputs belong to
  36868. */
  36869. constructor(camera: FollowCamera);
  36870. /**
  36871. * Add keyboard input support to the input manager.
  36872. * @returns the current input manager
  36873. */
  36874. addKeyboard(): FollowCameraInputsManager;
  36875. /**
  36876. * Add mouse wheel input support to the input manager.
  36877. * @returns the current input manager
  36878. */
  36879. addMouseWheel(): FollowCameraInputsManager;
  36880. /**
  36881. * Add pointers input support to the input manager.
  36882. * @returns the current input manager
  36883. */
  36884. addPointers(): FollowCameraInputsManager;
  36885. /**
  36886. * Add orientation input support to the input manager.
  36887. * @returns the current input manager
  36888. */
  36889. addVRDeviceOrientation(): FollowCameraInputsManager;
  36890. }
  36891. }
  36892. declare module "babylonjs/Cameras/followCamera" {
  36893. import { Nullable } from "babylonjs/types";
  36894. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36895. import { Scene } from "babylonjs/scene";
  36896. import { Vector3 } from "babylonjs/Maths/math";
  36897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36898. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36899. /**
  36900. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36901. * an arc rotate version arcFollowCamera are available.
  36902. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36903. */
  36904. export class FollowCamera extends TargetCamera {
  36905. /**
  36906. * Distance the follow camera should follow an object at
  36907. */
  36908. radius: number;
  36909. /**
  36910. * Minimum allowed distance of the camera to the axis of rotation
  36911. * (The camera can not get closer).
  36912. * This can help limiting how the Camera is able to move in the scene.
  36913. */
  36914. lowerRadiusLimit: Nullable<number>;
  36915. /**
  36916. * Maximum allowed distance of the camera to the axis of rotation
  36917. * (The camera can not get further).
  36918. * This can help limiting how the Camera is able to move in the scene.
  36919. */
  36920. upperRadiusLimit: Nullable<number>;
  36921. /**
  36922. * Define a rotation offset between the camera and the object it follows
  36923. */
  36924. rotationOffset: number;
  36925. /**
  36926. * Minimum allowed angle to camera position relative to target object.
  36927. * This can help limiting how the Camera is able to move in the scene.
  36928. */
  36929. lowerRotationOffsetLimit: Nullable<number>;
  36930. /**
  36931. * Maximum allowed angle to camera position relative to target object.
  36932. * This can help limiting how the Camera is able to move in the scene.
  36933. */
  36934. upperRotationOffsetLimit: Nullable<number>;
  36935. /**
  36936. * Define a height offset between the camera and the object it follows.
  36937. * It can help following an object from the top (like a car chaing a plane)
  36938. */
  36939. heightOffset: number;
  36940. /**
  36941. * Minimum allowed height of camera position relative to target object.
  36942. * This can help limiting how the Camera is able to move in the scene.
  36943. */
  36944. lowerHeightOffsetLimit: Nullable<number>;
  36945. /**
  36946. * Maximum allowed height of camera position relative to target object.
  36947. * This can help limiting how the Camera is able to move in the scene.
  36948. */
  36949. upperHeightOffsetLimit: Nullable<number>;
  36950. /**
  36951. * Define how fast the camera can accelerate to follow it s target.
  36952. */
  36953. cameraAcceleration: number;
  36954. /**
  36955. * Define the speed limit of the camera following an object.
  36956. */
  36957. maxCameraSpeed: number;
  36958. /**
  36959. * Define the target of the camera.
  36960. */
  36961. lockedTarget: Nullable<AbstractMesh>;
  36962. /**
  36963. * Defines the input associated with the camera.
  36964. */
  36965. inputs: FollowCameraInputsManager;
  36966. /**
  36967. * Instantiates the follow camera.
  36968. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36969. * @param name Define the name of the camera in the scene
  36970. * @param position Define the position of the camera
  36971. * @param scene Define the scene the camera belong to
  36972. * @param lockedTarget Define the target of the camera
  36973. */
  36974. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36975. private _follow;
  36976. /**
  36977. * Attached controls to the current camera.
  36978. * @param element Defines the element the controls should be listened from
  36979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36980. */
  36981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36982. /**
  36983. * Detach the current controls from the camera.
  36984. * The camera will stop reacting to inputs.
  36985. * @param element Defines the element to stop listening the inputs from
  36986. */
  36987. detachControl(element: HTMLElement): void;
  36988. /** @hidden */
  36989. _checkInputs(): void;
  36990. private _checkLimits;
  36991. /**
  36992. * Gets the camera class name.
  36993. * @returns the class name
  36994. */
  36995. getClassName(): string;
  36996. }
  36997. /**
  36998. * Arc Rotate version of the follow camera.
  36999. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37001. */
  37002. export class ArcFollowCamera extends TargetCamera {
  37003. /** The longitudinal angle of the camera */
  37004. alpha: number;
  37005. /** The latitudinal angle of the camera */
  37006. beta: number;
  37007. /** The radius of the camera from its target */
  37008. radius: number;
  37009. /** Define the camera target (the messh it should follow) */
  37010. target: Nullable<AbstractMesh>;
  37011. private _cartesianCoordinates;
  37012. /**
  37013. * Instantiates a new ArcFollowCamera
  37014. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37015. * @param name Define the name of the camera
  37016. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37017. * @param beta Define the rotation angle of the camera around the elevation axis
  37018. * @param radius Define the radius of the camera from its target point
  37019. * @param target Define the target of the camera
  37020. * @param scene Define the scene the camera belongs to
  37021. */
  37022. constructor(name: string,
  37023. /** The longitudinal angle of the camera */
  37024. alpha: number,
  37025. /** The latitudinal angle of the camera */
  37026. beta: number,
  37027. /** The radius of the camera from its target */
  37028. radius: number,
  37029. /** Define the camera target (the messh it should follow) */
  37030. target: Nullable<AbstractMesh>, scene: Scene);
  37031. private _follow;
  37032. /** @hidden */
  37033. _checkInputs(): void;
  37034. /**
  37035. * Returns the class name of the object.
  37036. * It is mostly used internally for serialization purposes.
  37037. */
  37038. getClassName(): string;
  37039. }
  37040. }
  37041. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37043. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37044. import { Nullable } from "babylonjs/types";
  37045. /**
  37046. * Manage the keyboard inputs to control the movement of a follow camera.
  37047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37048. */
  37049. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37050. /**
  37051. * Defines the camera the input is attached to.
  37052. */
  37053. camera: FollowCamera;
  37054. /**
  37055. * Defines the list of key codes associated with the up action (increase heightOffset)
  37056. */
  37057. keysHeightOffsetIncr: number[];
  37058. /**
  37059. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37060. */
  37061. keysHeightOffsetDecr: number[];
  37062. /**
  37063. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37064. */
  37065. keysHeightOffsetModifierAlt: boolean;
  37066. /**
  37067. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37068. */
  37069. keysHeightOffsetModifierCtrl: boolean;
  37070. /**
  37071. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37072. */
  37073. keysHeightOffsetModifierShift: boolean;
  37074. /**
  37075. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37076. */
  37077. keysRotationOffsetIncr: number[];
  37078. /**
  37079. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37080. */
  37081. keysRotationOffsetDecr: number[];
  37082. /**
  37083. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37084. */
  37085. keysRotationOffsetModifierAlt: boolean;
  37086. /**
  37087. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37088. */
  37089. keysRotationOffsetModifierCtrl: boolean;
  37090. /**
  37091. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37092. */
  37093. keysRotationOffsetModifierShift: boolean;
  37094. /**
  37095. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37096. */
  37097. keysRadiusIncr: number[];
  37098. /**
  37099. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37100. */
  37101. keysRadiusDecr: number[];
  37102. /**
  37103. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37104. */
  37105. keysRadiusModifierAlt: boolean;
  37106. /**
  37107. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37108. */
  37109. keysRadiusModifierCtrl: boolean;
  37110. /**
  37111. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37112. */
  37113. keysRadiusModifierShift: boolean;
  37114. /**
  37115. * Defines the rate of change of heightOffset.
  37116. */
  37117. heightSensibility: number;
  37118. /**
  37119. * Defines the rate of change of rotationOffset.
  37120. */
  37121. rotationSensibility: number;
  37122. /**
  37123. * Defines the rate of change of radius.
  37124. */
  37125. radiusSensibility: number;
  37126. private _keys;
  37127. private _ctrlPressed;
  37128. private _altPressed;
  37129. private _shiftPressed;
  37130. private _onCanvasBlurObserver;
  37131. private _onKeyboardObserver;
  37132. private _engine;
  37133. private _scene;
  37134. /**
  37135. * Attach the input controls to a specific dom element to get the input from.
  37136. * @param element Defines the element the controls should be listened from
  37137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37138. */
  37139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37140. /**
  37141. * Detach the current controls from the specified dom element.
  37142. * @param element Defines the element to stop listening the inputs from
  37143. */
  37144. detachControl(element: Nullable<HTMLElement>): void;
  37145. /**
  37146. * Update the current camera state depending on the inputs that have been used this frame.
  37147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37148. */
  37149. checkInputs(): void;
  37150. /**
  37151. * Gets the class name of the current input.
  37152. * @returns the class name
  37153. */
  37154. getClassName(): string;
  37155. /**
  37156. * Get the friendly name associated with the input class.
  37157. * @returns the input friendly name
  37158. */
  37159. getSimpleName(): string;
  37160. /**
  37161. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37162. * allow modification of the heightOffset value.
  37163. */
  37164. private _modifierHeightOffset;
  37165. /**
  37166. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37167. * allow modification of the rotationOffset value.
  37168. */
  37169. private _modifierRotationOffset;
  37170. /**
  37171. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37172. * allow modification of the radius value.
  37173. */
  37174. private _modifierRadius;
  37175. }
  37176. }
  37177. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37178. import { Nullable } from "babylonjs/types";
  37179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37180. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37181. module "babylonjs/Cameras/freeCameraInputsManager" {
  37182. interface FreeCameraInputsManager {
  37183. /**
  37184. * Add orientation input support to the input manager.
  37185. * @returns the current input manager
  37186. */
  37187. addDeviceOrientation(): FreeCameraInputsManager;
  37188. }
  37189. }
  37190. /**
  37191. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37192. * Screen rotation is taken into account.
  37193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37194. */
  37195. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37196. private _camera;
  37197. private _screenOrientationAngle;
  37198. private _constantTranform;
  37199. private _screenQuaternion;
  37200. private _alpha;
  37201. private _beta;
  37202. private _gamma;
  37203. /**
  37204. * Instantiates a new input
  37205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37206. */
  37207. constructor();
  37208. /**
  37209. * Define the camera controlled by the input.
  37210. */
  37211. camera: FreeCamera;
  37212. /**
  37213. * Attach the input controls to a specific dom element to get the input from.
  37214. * @param element Defines the element the controls should be listened from
  37215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37216. */
  37217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37218. private _orientationChanged;
  37219. private _deviceOrientation;
  37220. /**
  37221. * Detach the current controls from the specified dom element.
  37222. * @param element Defines the element to stop listening the inputs from
  37223. */
  37224. detachControl(element: Nullable<HTMLElement>): void;
  37225. /**
  37226. * Update the current camera state depending on the inputs that have been used this frame.
  37227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37228. */
  37229. checkInputs(): void;
  37230. /**
  37231. * Gets the class name of the current intput.
  37232. * @returns the class name
  37233. */
  37234. getClassName(): string;
  37235. /**
  37236. * Get the friendly name associated with the input class.
  37237. * @returns the input friendly name
  37238. */
  37239. getSimpleName(): string;
  37240. }
  37241. }
  37242. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37243. import { Nullable } from "babylonjs/types";
  37244. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37245. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37246. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37247. /**
  37248. * Manage the gamepad inputs to control a free camera.
  37249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37250. */
  37251. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37252. /**
  37253. * Define the camera the input is attached to.
  37254. */
  37255. camera: FreeCamera;
  37256. /**
  37257. * Define the Gamepad controlling the input
  37258. */
  37259. gamepad: Nullable<Gamepad>;
  37260. /**
  37261. * Defines the gamepad rotation sensiblity.
  37262. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37263. */
  37264. gamepadAngularSensibility: number;
  37265. /**
  37266. * Defines the gamepad move sensiblity.
  37267. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37268. */
  37269. gamepadMoveSensibility: number;
  37270. private _onGamepadConnectedObserver;
  37271. private _onGamepadDisconnectedObserver;
  37272. private _cameraTransform;
  37273. private _deltaTransform;
  37274. private _vector3;
  37275. private _vector2;
  37276. /**
  37277. * Attach the input controls to a specific dom element to get the input from.
  37278. * @param element Defines the element the controls should be listened from
  37279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37280. */
  37281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37282. /**
  37283. * Detach the current controls from the specified dom element.
  37284. * @param element Defines the element to stop listening the inputs from
  37285. */
  37286. detachControl(element: Nullable<HTMLElement>): void;
  37287. /**
  37288. * Update the current camera state depending on the inputs that have been used this frame.
  37289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37290. */
  37291. checkInputs(): void;
  37292. /**
  37293. * Gets the class name of the current intput.
  37294. * @returns the class name
  37295. */
  37296. getClassName(): string;
  37297. /**
  37298. * Get the friendly name associated with the input class.
  37299. * @returns the input friendly name
  37300. */
  37301. getSimpleName(): string;
  37302. }
  37303. }
  37304. declare module "babylonjs/Misc/virtualJoystick" {
  37305. import { Nullable } from "babylonjs/types";
  37306. import { Vector3 } from "babylonjs/Maths/math";
  37307. /**
  37308. * Defines the potential axis of a Joystick
  37309. */
  37310. export enum JoystickAxis {
  37311. /** X axis */
  37312. X = 0,
  37313. /** Y axis */
  37314. Y = 1,
  37315. /** Z axis */
  37316. Z = 2
  37317. }
  37318. /**
  37319. * Class used to define virtual joystick (used in touch mode)
  37320. */
  37321. export class VirtualJoystick {
  37322. /**
  37323. * Gets or sets a boolean indicating that left and right values must be inverted
  37324. */
  37325. reverseLeftRight: boolean;
  37326. /**
  37327. * Gets or sets a boolean indicating that up and down values must be inverted
  37328. */
  37329. reverseUpDown: boolean;
  37330. /**
  37331. * Gets the offset value for the position (ie. the change of the position value)
  37332. */
  37333. deltaPosition: Vector3;
  37334. /**
  37335. * Gets a boolean indicating if the virtual joystick was pressed
  37336. */
  37337. pressed: boolean;
  37338. /**
  37339. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37340. */
  37341. static Canvas: Nullable<HTMLCanvasElement>;
  37342. private static _globalJoystickIndex;
  37343. private static vjCanvasContext;
  37344. private static vjCanvasWidth;
  37345. private static vjCanvasHeight;
  37346. private static halfWidth;
  37347. private _action;
  37348. private _axisTargetedByLeftAndRight;
  37349. private _axisTargetedByUpAndDown;
  37350. private _joystickSensibility;
  37351. private _inversedSensibility;
  37352. private _joystickPointerID;
  37353. private _joystickColor;
  37354. private _joystickPointerPos;
  37355. private _joystickPreviousPointerPos;
  37356. private _joystickPointerStartPos;
  37357. private _deltaJoystickVector;
  37358. private _leftJoystick;
  37359. private _touches;
  37360. private _onPointerDownHandlerRef;
  37361. private _onPointerMoveHandlerRef;
  37362. private _onPointerUpHandlerRef;
  37363. private _onResize;
  37364. /**
  37365. * Creates a new virtual joystick
  37366. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37367. */
  37368. constructor(leftJoystick?: boolean);
  37369. /**
  37370. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37371. * @param newJoystickSensibility defines the new sensibility
  37372. */
  37373. setJoystickSensibility(newJoystickSensibility: number): void;
  37374. private _onPointerDown;
  37375. private _onPointerMove;
  37376. private _onPointerUp;
  37377. /**
  37378. * Change the color of the virtual joystick
  37379. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37380. */
  37381. setJoystickColor(newColor: string): void;
  37382. /**
  37383. * Defines a callback to call when the joystick is touched
  37384. * @param action defines the callback
  37385. */
  37386. setActionOnTouch(action: () => any): void;
  37387. /**
  37388. * Defines which axis you'd like to control for left & right
  37389. * @param axis defines the axis to use
  37390. */
  37391. setAxisForLeftRight(axis: JoystickAxis): void;
  37392. /**
  37393. * Defines which axis you'd like to control for up & down
  37394. * @param axis defines the axis to use
  37395. */
  37396. setAxisForUpDown(axis: JoystickAxis): void;
  37397. private _drawVirtualJoystick;
  37398. /**
  37399. * Release internal HTML canvas
  37400. */
  37401. releaseCanvas(): void;
  37402. }
  37403. }
  37404. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37405. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37406. import { Nullable } from "babylonjs/types";
  37407. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37408. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37409. module "babylonjs/Cameras/freeCameraInputsManager" {
  37410. interface FreeCameraInputsManager {
  37411. /**
  37412. * Add virtual joystick input support to the input manager.
  37413. * @returns the current input manager
  37414. */
  37415. addVirtualJoystick(): FreeCameraInputsManager;
  37416. }
  37417. }
  37418. /**
  37419. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37421. */
  37422. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37423. /**
  37424. * Defines the camera the input is attached to.
  37425. */
  37426. camera: FreeCamera;
  37427. private _leftjoystick;
  37428. private _rightjoystick;
  37429. /**
  37430. * Gets the left stick of the virtual joystick.
  37431. * @returns The virtual Joystick
  37432. */
  37433. getLeftJoystick(): VirtualJoystick;
  37434. /**
  37435. * Gets the right stick of the virtual joystick.
  37436. * @returns The virtual Joystick
  37437. */
  37438. getRightJoystick(): VirtualJoystick;
  37439. /**
  37440. * Update the current camera state depending on the inputs that have been used this frame.
  37441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37442. */
  37443. checkInputs(): void;
  37444. /**
  37445. * Attach the input controls to a specific dom element to get the input from.
  37446. * @param element Defines the element the controls should be listened from
  37447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37448. */
  37449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37450. /**
  37451. * Detach the current controls from the specified dom element.
  37452. * @param element Defines the element to stop listening the inputs from
  37453. */
  37454. detachControl(element: Nullable<HTMLElement>): void;
  37455. /**
  37456. * Gets the class name of the current intput.
  37457. * @returns the class name
  37458. */
  37459. getClassName(): string;
  37460. /**
  37461. * Get the friendly name associated with the input class.
  37462. * @returns the input friendly name
  37463. */
  37464. getSimpleName(): string;
  37465. }
  37466. }
  37467. declare module "babylonjs/Cameras/Inputs/index" {
  37468. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37469. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37470. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37471. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37472. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37473. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37474. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37475. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37476. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37477. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37478. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37479. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37480. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37481. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37482. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37483. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37484. }
  37485. declare module "babylonjs/Cameras/touchCamera" {
  37486. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37487. import { Scene } from "babylonjs/scene";
  37488. import { Vector3 } from "babylonjs/Maths/math";
  37489. /**
  37490. * This represents a FPS type of camera controlled by touch.
  37491. * This is like a universal camera minus the Gamepad controls.
  37492. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37493. */
  37494. export class TouchCamera extends FreeCamera {
  37495. /**
  37496. * Defines the touch sensibility for rotation.
  37497. * The higher the faster.
  37498. */
  37499. touchAngularSensibility: number;
  37500. /**
  37501. * Defines the touch sensibility for move.
  37502. * The higher the faster.
  37503. */
  37504. touchMoveSensibility: number;
  37505. /**
  37506. * Instantiates a new touch camera.
  37507. * This represents a FPS type of camera controlled by touch.
  37508. * This is like a universal camera minus the Gamepad controls.
  37509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37510. * @param name Define the name of the camera in the scene
  37511. * @param position Define the start position of the camera in the scene
  37512. * @param scene Define the scene the camera belongs to
  37513. */
  37514. constructor(name: string, position: Vector3, scene: Scene);
  37515. /**
  37516. * Gets the current object class name.
  37517. * @return the class name
  37518. */
  37519. getClassName(): string;
  37520. /** @hidden */
  37521. _setupInputs(): void;
  37522. }
  37523. }
  37524. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37526. import { Scene } from "babylonjs/scene";
  37527. import { Vector3, Axis } from "babylonjs/Maths/math";
  37528. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37529. /**
  37530. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37531. * being tilted forward or back and left or right.
  37532. */
  37533. export class DeviceOrientationCamera extends FreeCamera {
  37534. private _initialQuaternion;
  37535. private _quaternionCache;
  37536. /**
  37537. * Creates a new device orientation camera
  37538. * @param name The name of the camera
  37539. * @param position The start position camera
  37540. * @param scene The scene the camera belongs to
  37541. */
  37542. constructor(name: string, position: Vector3, scene: Scene);
  37543. /**
  37544. * Gets the current instance class name ("DeviceOrientationCamera").
  37545. * This helps avoiding instanceof at run time.
  37546. * @returns the class name
  37547. */
  37548. getClassName(): string;
  37549. /**
  37550. * @hidden
  37551. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37552. */
  37553. _checkInputs(): void;
  37554. /**
  37555. * Reset the camera to its default orientation on the specified axis only.
  37556. * @param axis The axis to reset
  37557. */
  37558. resetToCurrentRotation(axis?: Axis): void;
  37559. }
  37560. }
  37561. declare module "babylonjs/Cameras/universalCamera" {
  37562. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Vector3 } from "babylonjs/Maths/math";
  37565. /**
  37566. * 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,
  37567. * which still works and will still be found in many Playgrounds.
  37568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37569. */
  37570. export class UniversalCamera extends TouchCamera {
  37571. /**
  37572. * Defines the gamepad rotation sensiblity.
  37573. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37574. */
  37575. gamepadAngularSensibility: number;
  37576. /**
  37577. * Defines the gamepad move sensiblity.
  37578. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37579. */
  37580. gamepadMoveSensibility: number;
  37581. /**
  37582. * 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,
  37583. * which still works and will still be found in many Playgrounds.
  37584. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37585. * @param name Define the name of the camera in the scene
  37586. * @param position Define the start position of the camera in the scene
  37587. * @param scene Define the scene the camera belongs to
  37588. */
  37589. constructor(name: string, position: Vector3, scene: Scene);
  37590. /**
  37591. * Gets the current object class name.
  37592. * @return the class name
  37593. */
  37594. getClassName(): string;
  37595. }
  37596. }
  37597. declare module "babylonjs/Cameras/gamepadCamera" {
  37598. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37599. import { Scene } from "babylonjs/scene";
  37600. import { Vector3 } from "babylonjs/Maths/math";
  37601. /**
  37602. * This represents a FPS type of camera. This is only here for back compat purpose.
  37603. * Please use the UniversalCamera instead as both are identical.
  37604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37605. */
  37606. export class GamepadCamera extends UniversalCamera {
  37607. /**
  37608. * Instantiates a new Gamepad Camera
  37609. * This represents a FPS type of camera. This is only here for back compat purpose.
  37610. * Please use the UniversalCamera instead as both are identical.
  37611. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37612. * @param name Define the name of the camera in the scene
  37613. * @param position Define the start position of the camera in the scene
  37614. * @param scene Define the scene the camera belongs to
  37615. */
  37616. constructor(name: string, position: Vector3, scene: Scene);
  37617. /**
  37618. * Gets the current object class name.
  37619. * @return the class name
  37620. */
  37621. getClassName(): string;
  37622. }
  37623. }
  37624. declare module "babylonjs/Shaders/pass.fragment" {
  37625. /** @hidden */
  37626. export var passPixelShader: {
  37627. name: string;
  37628. shader: string;
  37629. };
  37630. }
  37631. declare module "babylonjs/Shaders/passCube.fragment" {
  37632. /** @hidden */
  37633. export var passCubePixelShader: {
  37634. name: string;
  37635. shader: string;
  37636. };
  37637. }
  37638. declare module "babylonjs/PostProcesses/passPostProcess" {
  37639. import { Nullable } from "babylonjs/types";
  37640. import { Camera } from "babylonjs/Cameras/camera";
  37641. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37642. import { Engine } from "babylonjs/Engines/engine";
  37643. import "babylonjs/Shaders/pass.fragment";
  37644. import "babylonjs/Shaders/passCube.fragment";
  37645. /**
  37646. * PassPostProcess which produces an output the same as it's input
  37647. */
  37648. export class PassPostProcess extends PostProcess {
  37649. /**
  37650. * Creates the PassPostProcess
  37651. * @param name The name of the effect.
  37652. * @param options The required width/height ratio to downsize to before computing the render pass.
  37653. * @param camera The camera to apply the render pass to.
  37654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37655. * @param engine The engine which the post process will be applied. (default: current engine)
  37656. * @param reusable If the post process can be reused on the same frame. (default: false)
  37657. * @param textureType The type of texture to be used when performing the post processing.
  37658. * @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)
  37659. */
  37660. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37661. }
  37662. /**
  37663. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37664. */
  37665. export class PassCubePostProcess extends PostProcess {
  37666. private _face;
  37667. /**
  37668. * Gets or sets the cube face to display.
  37669. * * 0 is +X
  37670. * * 1 is -X
  37671. * * 2 is +Y
  37672. * * 3 is -Y
  37673. * * 4 is +Z
  37674. * * 5 is -Z
  37675. */
  37676. face: number;
  37677. /**
  37678. * Creates the PassCubePostProcess
  37679. * @param name The name of the effect.
  37680. * @param options The required width/height ratio to downsize to before computing the render pass.
  37681. * @param camera The camera to apply the render pass to.
  37682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37683. * @param engine The engine which the post process will be applied. (default: current engine)
  37684. * @param reusable If the post process can be reused on the same frame. (default: false)
  37685. * @param textureType The type of texture to be used when performing the post processing.
  37686. * @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)
  37687. */
  37688. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37689. }
  37690. }
  37691. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37692. /** @hidden */
  37693. export var anaglyphPixelShader: {
  37694. name: string;
  37695. shader: string;
  37696. };
  37697. }
  37698. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37699. import { Engine } from "babylonjs/Engines/engine";
  37700. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37701. import { Camera } from "babylonjs/Cameras/camera";
  37702. import "babylonjs/Shaders/anaglyph.fragment";
  37703. /**
  37704. * Postprocess used to generate anaglyphic rendering
  37705. */
  37706. export class AnaglyphPostProcess extends PostProcess {
  37707. private _passedProcess;
  37708. /**
  37709. * Creates a new AnaglyphPostProcess
  37710. * @param name defines postprocess name
  37711. * @param options defines creation options or target ratio scale
  37712. * @param rigCameras defines cameras using this postprocess
  37713. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37714. * @param engine defines hosting engine
  37715. * @param reusable defines if the postprocess will be reused multiple times per frame
  37716. */
  37717. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37718. }
  37719. }
  37720. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37721. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37723. import { Scene } from "babylonjs/scene";
  37724. import { Vector3 } from "babylonjs/Maths/math";
  37725. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37726. /**
  37727. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37728. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37729. */
  37730. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37731. /**
  37732. * Creates a new AnaglyphArcRotateCamera
  37733. * @param name defines camera name
  37734. * @param alpha defines alpha angle (in radians)
  37735. * @param beta defines beta angle (in radians)
  37736. * @param radius defines radius
  37737. * @param target defines camera target
  37738. * @param interaxialDistance defines distance between each color axis
  37739. * @param scene defines the hosting scene
  37740. */
  37741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37742. /**
  37743. * Gets camera class name
  37744. * @returns AnaglyphArcRotateCamera
  37745. */
  37746. getClassName(): string;
  37747. }
  37748. }
  37749. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37750. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37751. import { Scene } from "babylonjs/scene";
  37752. import { Vector3 } from "babylonjs/Maths/math";
  37753. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37754. /**
  37755. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37756. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37757. */
  37758. export class AnaglyphFreeCamera extends FreeCamera {
  37759. /**
  37760. * Creates a new AnaglyphFreeCamera
  37761. * @param name defines camera name
  37762. * @param position defines initial position
  37763. * @param interaxialDistance defines distance between each color axis
  37764. * @param scene defines the hosting scene
  37765. */
  37766. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37767. /**
  37768. * Gets camera class name
  37769. * @returns AnaglyphFreeCamera
  37770. */
  37771. getClassName(): string;
  37772. }
  37773. }
  37774. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37775. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37776. import { Scene } from "babylonjs/scene";
  37777. import { Vector3 } from "babylonjs/Maths/math";
  37778. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37779. /**
  37780. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37781. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37782. */
  37783. export class AnaglyphGamepadCamera extends GamepadCamera {
  37784. /**
  37785. * Creates a new AnaglyphGamepadCamera
  37786. * @param name defines camera name
  37787. * @param position defines initial position
  37788. * @param interaxialDistance defines distance between each color axis
  37789. * @param scene defines the hosting scene
  37790. */
  37791. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37792. /**
  37793. * Gets camera class name
  37794. * @returns AnaglyphGamepadCamera
  37795. */
  37796. getClassName(): string;
  37797. }
  37798. }
  37799. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37800. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37801. import { Scene } from "babylonjs/scene";
  37802. import { Vector3 } from "babylonjs/Maths/math";
  37803. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37804. /**
  37805. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37806. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37807. */
  37808. export class AnaglyphUniversalCamera extends UniversalCamera {
  37809. /**
  37810. * Creates a new AnaglyphUniversalCamera
  37811. * @param name defines camera name
  37812. * @param position defines initial position
  37813. * @param interaxialDistance defines distance between each color axis
  37814. * @param scene defines the hosting scene
  37815. */
  37816. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37817. /**
  37818. * Gets camera class name
  37819. * @returns AnaglyphUniversalCamera
  37820. */
  37821. getClassName(): string;
  37822. }
  37823. }
  37824. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37825. /** @hidden */
  37826. export var stereoscopicInterlacePixelShader: {
  37827. name: string;
  37828. shader: string;
  37829. };
  37830. }
  37831. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37832. import { Camera } from "babylonjs/Cameras/camera";
  37833. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37834. import { Engine } from "babylonjs/Engines/engine";
  37835. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37836. /**
  37837. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37838. */
  37839. export class StereoscopicInterlacePostProcess extends PostProcess {
  37840. private _stepSize;
  37841. private _passedProcess;
  37842. /**
  37843. * Initializes a StereoscopicInterlacePostProcess
  37844. * @param name The name of the effect.
  37845. * @param rigCameras The rig cameras to be appled to the post process
  37846. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37848. * @param engine The engine which the post process will be applied. (default: current engine)
  37849. * @param reusable If the post process can be reused on the same frame. (default: false)
  37850. */
  37851. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37852. }
  37853. }
  37854. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37855. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37856. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37857. import { Scene } from "babylonjs/scene";
  37858. import { Vector3 } from "babylonjs/Maths/math";
  37859. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37860. /**
  37861. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37862. * @see http://doc.babylonjs.com/features/cameras
  37863. */
  37864. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37865. /**
  37866. * Creates a new StereoscopicArcRotateCamera
  37867. * @param name defines camera name
  37868. * @param alpha defines alpha angle (in radians)
  37869. * @param beta defines beta angle (in radians)
  37870. * @param radius defines radius
  37871. * @param target defines camera target
  37872. * @param interaxialDistance defines distance between each color axis
  37873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37874. * @param scene defines the hosting scene
  37875. */
  37876. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37877. /**
  37878. * Gets camera class name
  37879. * @returns StereoscopicArcRotateCamera
  37880. */
  37881. getClassName(): string;
  37882. }
  37883. }
  37884. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37885. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37886. import { Scene } from "babylonjs/scene";
  37887. import { Vector3 } from "babylonjs/Maths/math";
  37888. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37889. /**
  37890. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37891. * @see http://doc.babylonjs.com/features/cameras
  37892. */
  37893. export class StereoscopicFreeCamera extends FreeCamera {
  37894. /**
  37895. * Creates a new StereoscopicFreeCamera
  37896. * @param name defines camera name
  37897. * @param position defines initial position
  37898. * @param interaxialDistance defines distance between each color axis
  37899. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37900. * @param scene defines the hosting scene
  37901. */
  37902. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37903. /**
  37904. * Gets camera class name
  37905. * @returns StereoscopicFreeCamera
  37906. */
  37907. getClassName(): string;
  37908. }
  37909. }
  37910. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37911. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37912. import { Scene } from "babylonjs/scene";
  37913. import { Vector3 } from "babylonjs/Maths/math";
  37914. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37915. /**
  37916. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37917. * @see http://doc.babylonjs.com/features/cameras
  37918. */
  37919. export class StereoscopicGamepadCamera extends GamepadCamera {
  37920. /**
  37921. * Creates a new StereoscopicGamepadCamera
  37922. * @param name defines camera name
  37923. * @param position defines initial position
  37924. * @param interaxialDistance defines distance between each color axis
  37925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37926. * @param scene defines the hosting scene
  37927. */
  37928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37929. /**
  37930. * Gets camera class name
  37931. * @returns StereoscopicGamepadCamera
  37932. */
  37933. getClassName(): string;
  37934. }
  37935. }
  37936. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37937. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37938. import { Scene } from "babylonjs/scene";
  37939. import { Vector3 } from "babylonjs/Maths/math";
  37940. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37941. /**
  37942. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37943. * @see http://doc.babylonjs.com/features/cameras
  37944. */
  37945. export class StereoscopicUniversalCamera extends UniversalCamera {
  37946. /**
  37947. * Creates a new StereoscopicUniversalCamera
  37948. * @param name defines camera name
  37949. * @param position defines initial position
  37950. * @param interaxialDistance defines distance between each color axis
  37951. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37952. * @param scene defines the hosting scene
  37953. */
  37954. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37955. /**
  37956. * Gets camera class name
  37957. * @returns StereoscopicUniversalCamera
  37958. */
  37959. getClassName(): string;
  37960. }
  37961. }
  37962. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37964. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37965. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37966. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37968. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37969. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37970. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37971. }
  37972. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37974. import { Scene } from "babylonjs/scene";
  37975. import { Vector3 } from "babylonjs/Maths/math";
  37976. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37977. /**
  37978. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37979. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37980. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37981. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37982. */
  37983. export class VirtualJoysticksCamera extends FreeCamera {
  37984. /**
  37985. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37986. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37987. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37988. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37989. * @param name Define the name of the camera in the scene
  37990. * @param position Define the start position of the camera in the scene
  37991. * @param scene Define the scene the camera belongs to
  37992. */
  37993. constructor(name: string, position: Vector3, scene: Scene);
  37994. /**
  37995. * Gets the current object class name.
  37996. * @return the class name
  37997. */
  37998. getClassName(): string;
  37999. }
  38000. }
  38001. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38002. import { Matrix } from "babylonjs/Maths/math";
  38003. /**
  38004. * This represents all the required metrics to create a VR camera.
  38005. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38006. */
  38007. export class VRCameraMetrics {
  38008. /**
  38009. * Define the horizontal resolution off the screen.
  38010. */
  38011. hResolution: number;
  38012. /**
  38013. * Define the vertical resolution off the screen.
  38014. */
  38015. vResolution: number;
  38016. /**
  38017. * Define the horizontal screen size.
  38018. */
  38019. hScreenSize: number;
  38020. /**
  38021. * Define the vertical screen size.
  38022. */
  38023. vScreenSize: number;
  38024. /**
  38025. * Define the vertical screen center position.
  38026. */
  38027. vScreenCenter: number;
  38028. /**
  38029. * Define the distance of the eyes to the screen.
  38030. */
  38031. eyeToScreenDistance: number;
  38032. /**
  38033. * Define the distance between both lenses
  38034. */
  38035. lensSeparationDistance: number;
  38036. /**
  38037. * Define the distance between both viewer's eyes.
  38038. */
  38039. interpupillaryDistance: number;
  38040. /**
  38041. * Define the distortion factor of the VR postprocess.
  38042. * Please, touch with care.
  38043. */
  38044. distortionK: number[];
  38045. /**
  38046. * Define the chromatic aberration correction factors for the VR post process.
  38047. */
  38048. chromaAbCorrection: number[];
  38049. /**
  38050. * Define the scale factor of the post process.
  38051. * The smaller the better but the slower.
  38052. */
  38053. postProcessScaleFactor: number;
  38054. /**
  38055. * Define an offset for the lens center.
  38056. */
  38057. lensCenterOffset: number;
  38058. /**
  38059. * Define if the current vr camera should compensate the distortion of the lense or not.
  38060. */
  38061. compensateDistortion: boolean;
  38062. /**
  38063. * Gets the rendering aspect ratio based on the provided resolutions.
  38064. */
  38065. readonly aspectRatio: number;
  38066. /**
  38067. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38068. */
  38069. readonly aspectRatioFov: number;
  38070. /**
  38071. * @hidden
  38072. */
  38073. readonly leftHMatrix: Matrix;
  38074. /**
  38075. * @hidden
  38076. */
  38077. readonly rightHMatrix: Matrix;
  38078. /**
  38079. * @hidden
  38080. */
  38081. readonly leftPreViewMatrix: Matrix;
  38082. /**
  38083. * @hidden
  38084. */
  38085. readonly rightPreViewMatrix: Matrix;
  38086. /**
  38087. * Get the default VRMetrics based on the most generic setup.
  38088. * @returns the default vr metrics
  38089. */
  38090. static GetDefault(): VRCameraMetrics;
  38091. }
  38092. }
  38093. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38094. /** @hidden */
  38095. export var vrDistortionCorrectionPixelShader: {
  38096. name: string;
  38097. shader: string;
  38098. };
  38099. }
  38100. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38101. import { Camera } from "babylonjs/Cameras/camera";
  38102. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38104. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38105. /**
  38106. * VRDistortionCorrectionPostProcess used for mobile VR
  38107. */
  38108. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38109. private _isRightEye;
  38110. private _distortionFactors;
  38111. private _postProcessScaleFactor;
  38112. private _lensCenterOffset;
  38113. private _scaleIn;
  38114. private _scaleFactor;
  38115. private _lensCenter;
  38116. /**
  38117. * Initializes the VRDistortionCorrectionPostProcess
  38118. * @param name The name of the effect.
  38119. * @param camera The camera to apply the render pass to.
  38120. * @param isRightEye If this is for the right eye distortion
  38121. * @param vrMetrics All the required metrics for the VR camera
  38122. */
  38123. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38124. }
  38125. }
  38126. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38127. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38128. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38129. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38130. import { Scene } from "babylonjs/scene";
  38131. import { Vector3 } from "babylonjs/Maths/math";
  38132. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38133. import "babylonjs/Cameras/RigModes/vrRigMode";
  38134. /**
  38135. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38136. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38137. */
  38138. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38139. /**
  38140. * Creates a new VRDeviceOrientationArcRotateCamera
  38141. * @param name defines camera name
  38142. * @param alpha defines the camera rotation along the logitudinal axis
  38143. * @param beta defines the camera rotation along the latitudinal axis
  38144. * @param radius defines the camera distance from its target
  38145. * @param target defines the camera target
  38146. * @param scene defines the scene the camera belongs to
  38147. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38148. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38149. */
  38150. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38151. /**
  38152. * Gets camera class name
  38153. * @returns VRDeviceOrientationArcRotateCamera
  38154. */
  38155. getClassName(): string;
  38156. }
  38157. }
  38158. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38159. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38160. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38161. import { Scene } from "babylonjs/scene";
  38162. import { Vector3 } from "babylonjs/Maths/math";
  38163. import "babylonjs/Cameras/RigModes/vrRigMode";
  38164. /**
  38165. * Camera used to simulate VR rendering (based on FreeCamera)
  38166. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38167. */
  38168. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38169. /**
  38170. * Creates a new VRDeviceOrientationFreeCamera
  38171. * @param name defines camera name
  38172. * @param position defines the start position of the camera
  38173. * @param scene defines the scene the camera belongs to
  38174. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38175. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38176. */
  38177. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38178. /**
  38179. * Gets camera class name
  38180. * @returns VRDeviceOrientationFreeCamera
  38181. */
  38182. getClassName(): string;
  38183. }
  38184. }
  38185. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38186. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38187. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38188. import { Scene } from "babylonjs/scene";
  38189. import { Vector3 } from "babylonjs/Maths/math";
  38190. /**
  38191. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38192. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38193. */
  38194. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38195. /**
  38196. * Creates a new VRDeviceOrientationGamepadCamera
  38197. * @param name defines camera name
  38198. * @param position defines the start position of the camera
  38199. * @param scene defines the scene the camera belongs to
  38200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38202. */
  38203. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38204. /**
  38205. * Gets camera class name
  38206. * @returns VRDeviceOrientationGamepadCamera
  38207. */
  38208. getClassName(): string;
  38209. }
  38210. }
  38211. declare module "babylonjs/Gamepads/xboxGamepad" {
  38212. import { Observable } from "babylonjs/Misc/observable";
  38213. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38214. /**
  38215. * Defines supported buttons for XBox360 compatible gamepads
  38216. */
  38217. export enum Xbox360Button {
  38218. /** A */
  38219. A = 0,
  38220. /** B */
  38221. B = 1,
  38222. /** X */
  38223. X = 2,
  38224. /** Y */
  38225. Y = 3,
  38226. /** Start */
  38227. Start = 4,
  38228. /** Back */
  38229. Back = 5,
  38230. /** Left button */
  38231. LB = 6,
  38232. /** Right button */
  38233. RB = 7,
  38234. /** Left stick */
  38235. LeftStick = 8,
  38236. /** Right stick */
  38237. RightStick = 9
  38238. }
  38239. /** Defines values for XBox360 DPad */
  38240. export enum Xbox360Dpad {
  38241. /** Up */
  38242. Up = 0,
  38243. /** Down */
  38244. Down = 1,
  38245. /** Left */
  38246. Left = 2,
  38247. /** Right */
  38248. Right = 3
  38249. }
  38250. /**
  38251. * Defines a XBox360 gamepad
  38252. */
  38253. export class Xbox360Pad extends Gamepad {
  38254. private _leftTrigger;
  38255. private _rightTrigger;
  38256. private _onlefttriggerchanged;
  38257. private _onrighttriggerchanged;
  38258. private _onbuttondown;
  38259. private _onbuttonup;
  38260. private _ondpaddown;
  38261. private _ondpadup;
  38262. /** Observable raised when a button is pressed */
  38263. onButtonDownObservable: Observable<Xbox360Button>;
  38264. /** Observable raised when a button is released */
  38265. onButtonUpObservable: Observable<Xbox360Button>;
  38266. /** Observable raised when a pad is pressed */
  38267. onPadDownObservable: Observable<Xbox360Dpad>;
  38268. /** Observable raised when a pad is released */
  38269. onPadUpObservable: Observable<Xbox360Dpad>;
  38270. private _buttonA;
  38271. private _buttonB;
  38272. private _buttonX;
  38273. private _buttonY;
  38274. private _buttonBack;
  38275. private _buttonStart;
  38276. private _buttonLB;
  38277. private _buttonRB;
  38278. private _buttonLeftStick;
  38279. private _buttonRightStick;
  38280. private _dPadUp;
  38281. private _dPadDown;
  38282. private _dPadLeft;
  38283. private _dPadRight;
  38284. private _isXboxOnePad;
  38285. /**
  38286. * Creates a new XBox360 gamepad object
  38287. * @param id defines the id of this gamepad
  38288. * @param index defines its index
  38289. * @param gamepad defines the internal HTML gamepad object
  38290. * @param xboxOne defines if it is a XBox One gamepad
  38291. */
  38292. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38293. /**
  38294. * Defines the callback to call when left trigger is pressed
  38295. * @param callback defines the callback to use
  38296. */
  38297. onlefttriggerchanged(callback: (value: number) => void): void;
  38298. /**
  38299. * Defines the callback to call when right trigger is pressed
  38300. * @param callback defines the callback to use
  38301. */
  38302. onrighttriggerchanged(callback: (value: number) => void): void;
  38303. /**
  38304. * Gets the left trigger value
  38305. */
  38306. /**
  38307. * Sets the left trigger value
  38308. */
  38309. leftTrigger: number;
  38310. /**
  38311. * Gets the right trigger value
  38312. */
  38313. /**
  38314. * Sets the right trigger value
  38315. */
  38316. rightTrigger: number;
  38317. /**
  38318. * Defines the callback to call when a button is pressed
  38319. * @param callback defines the callback to use
  38320. */
  38321. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38322. /**
  38323. * Defines the callback to call when a button is released
  38324. * @param callback defines the callback to use
  38325. */
  38326. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38327. /**
  38328. * Defines the callback to call when a pad is pressed
  38329. * @param callback defines the callback to use
  38330. */
  38331. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38332. /**
  38333. * Defines the callback to call when a pad is released
  38334. * @param callback defines the callback to use
  38335. */
  38336. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38337. private _setButtonValue;
  38338. private _setDPadValue;
  38339. /**
  38340. * Gets the value of the `A` button
  38341. */
  38342. /**
  38343. * Sets the value of the `A` button
  38344. */
  38345. buttonA: number;
  38346. /**
  38347. * Gets the value of the `B` button
  38348. */
  38349. /**
  38350. * Sets the value of the `B` button
  38351. */
  38352. buttonB: number;
  38353. /**
  38354. * Gets the value of the `X` button
  38355. */
  38356. /**
  38357. * Sets the value of the `X` button
  38358. */
  38359. buttonX: number;
  38360. /**
  38361. * Gets the value of the `Y` button
  38362. */
  38363. /**
  38364. * Sets the value of the `Y` button
  38365. */
  38366. buttonY: number;
  38367. /**
  38368. * Gets the value of the `Start` button
  38369. */
  38370. /**
  38371. * Sets the value of the `Start` button
  38372. */
  38373. buttonStart: number;
  38374. /**
  38375. * Gets the value of the `Back` button
  38376. */
  38377. /**
  38378. * Sets the value of the `Back` button
  38379. */
  38380. buttonBack: number;
  38381. /**
  38382. * Gets the value of the `Left` button
  38383. */
  38384. /**
  38385. * Sets the value of the `Left` button
  38386. */
  38387. buttonLB: number;
  38388. /**
  38389. * Gets the value of the `Right` button
  38390. */
  38391. /**
  38392. * Sets the value of the `Right` button
  38393. */
  38394. buttonRB: number;
  38395. /**
  38396. * Gets the value of the Left joystick
  38397. */
  38398. /**
  38399. * Sets the value of the Left joystick
  38400. */
  38401. buttonLeftStick: number;
  38402. /**
  38403. * Gets the value of the Right joystick
  38404. */
  38405. /**
  38406. * Sets the value of the Right joystick
  38407. */
  38408. buttonRightStick: number;
  38409. /**
  38410. * Gets the value of D-pad up
  38411. */
  38412. /**
  38413. * Sets the value of D-pad up
  38414. */
  38415. dPadUp: number;
  38416. /**
  38417. * Gets the value of D-pad down
  38418. */
  38419. /**
  38420. * Sets the value of D-pad down
  38421. */
  38422. dPadDown: number;
  38423. /**
  38424. * Gets the value of D-pad left
  38425. */
  38426. /**
  38427. * Sets the value of D-pad left
  38428. */
  38429. dPadLeft: number;
  38430. /**
  38431. * Gets the value of D-pad right
  38432. */
  38433. /**
  38434. * Sets the value of D-pad right
  38435. */
  38436. dPadRight: number;
  38437. /**
  38438. * Force the gamepad to synchronize with device values
  38439. */
  38440. update(): void;
  38441. /**
  38442. * Disposes the gamepad
  38443. */
  38444. dispose(): void;
  38445. }
  38446. }
  38447. declare module "babylonjs/Materials/pushMaterial" {
  38448. import { Nullable } from "babylonjs/types";
  38449. import { Scene } from "babylonjs/scene";
  38450. import { Matrix } from "babylonjs/Maths/math";
  38451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38452. import { Mesh } from "babylonjs/Meshes/mesh";
  38453. import { Material } from "babylonjs/Materials/material";
  38454. import { Effect } from "babylonjs/Materials/effect";
  38455. /**
  38456. * Base class of materials working in push mode in babylon JS
  38457. * @hidden
  38458. */
  38459. export class PushMaterial extends Material {
  38460. protected _activeEffect: Effect;
  38461. protected _normalMatrix: Matrix;
  38462. /**
  38463. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38464. * This means that the material can keep using a previous shader while a new one is being compiled.
  38465. * This is mostly used when shader parallel compilation is supported (true by default)
  38466. */
  38467. allowShaderHotSwapping: boolean;
  38468. constructor(name: string, scene: Scene);
  38469. getEffect(): Effect;
  38470. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38471. /**
  38472. * Binds the given world matrix to the active effect
  38473. *
  38474. * @param world the matrix to bind
  38475. */
  38476. bindOnlyWorldMatrix(world: Matrix): void;
  38477. /**
  38478. * Binds the given normal matrix to the active effect
  38479. *
  38480. * @param normalMatrix the matrix to bind
  38481. */
  38482. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38483. bind(world: Matrix, mesh?: Mesh): void;
  38484. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38485. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38486. }
  38487. }
  38488. declare module "babylonjs/Materials/materialFlags" {
  38489. /**
  38490. * This groups all the flags used to control the materials channel.
  38491. */
  38492. export class MaterialFlags {
  38493. private static _DiffuseTextureEnabled;
  38494. /**
  38495. * Are diffuse textures enabled in the application.
  38496. */
  38497. static DiffuseTextureEnabled: boolean;
  38498. private static _AmbientTextureEnabled;
  38499. /**
  38500. * Are ambient textures enabled in the application.
  38501. */
  38502. static AmbientTextureEnabled: boolean;
  38503. private static _OpacityTextureEnabled;
  38504. /**
  38505. * Are opacity textures enabled in the application.
  38506. */
  38507. static OpacityTextureEnabled: boolean;
  38508. private static _ReflectionTextureEnabled;
  38509. /**
  38510. * Are reflection textures enabled in the application.
  38511. */
  38512. static ReflectionTextureEnabled: boolean;
  38513. private static _EmissiveTextureEnabled;
  38514. /**
  38515. * Are emissive textures enabled in the application.
  38516. */
  38517. static EmissiveTextureEnabled: boolean;
  38518. private static _SpecularTextureEnabled;
  38519. /**
  38520. * Are specular textures enabled in the application.
  38521. */
  38522. static SpecularTextureEnabled: boolean;
  38523. private static _BumpTextureEnabled;
  38524. /**
  38525. * Are bump textures enabled in the application.
  38526. */
  38527. static BumpTextureEnabled: boolean;
  38528. private static _LightmapTextureEnabled;
  38529. /**
  38530. * Are lightmap textures enabled in the application.
  38531. */
  38532. static LightmapTextureEnabled: boolean;
  38533. private static _RefractionTextureEnabled;
  38534. /**
  38535. * Are refraction textures enabled in the application.
  38536. */
  38537. static RefractionTextureEnabled: boolean;
  38538. private static _ColorGradingTextureEnabled;
  38539. /**
  38540. * Are color grading textures enabled in the application.
  38541. */
  38542. static ColorGradingTextureEnabled: boolean;
  38543. private static _FresnelEnabled;
  38544. /**
  38545. * Are fresnels enabled in the application.
  38546. */
  38547. static FresnelEnabled: boolean;
  38548. private static _ClearCoatTextureEnabled;
  38549. /**
  38550. * Are clear coat textures enabled in the application.
  38551. */
  38552. static ClearCoatTextureEnabled: boolean;
  38553. private static _ClearCoatBumpTextureEnabled;
  38554. /**
  38555. * Are clear coat bump textures enabled in the application.
  38556. */
  38557. static ClearCoatBumpTextureEnabled: boolean;
  38558. private static _ClearCoatTintTextureEnabled;
  38559. /**
  38560. * Are clear coat tint textures enabled in the application.
  38561. */
  38562. static ClearCoatTintTextureEnabled: boolean;
  38563. }
  38564. }
  38565. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38566. /** @hidden */
  38567. export var defaultFragmentDeclaration: {
  38568. name: string;
  38569. shader: string;
  38570. };
  38571. }
  38572. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38573. /** @hidden */
  38574. export var defaultUboDeclaration: {
  38575. name: string;
  38576. shader: string;
  38577. };
  38578. }
  38579. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38580. /** @hidden */
  38581. export var lightFragmentDeclaration: {
  38582. name: string;
  38583. shader: string;
  38584. };
  38585. }
  38586. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38587. /** @hidden */
  38588. export var lightUboDeclaration: {
  38589. name: string;
  38590. shader: string;
  38591. };
  38592. }
  38593. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38594. /** @hidden */
  38595. export var lightsFragmentFunctions: {
  38596. name: string;
  38597. shader: string;
  38598. };
  38599. }
  38600. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38601. /** @hidden */
  38602. export var shadowsFragmentFunctions: {
  38603. name: string;
  38604. shader: string;
  38605. };
  38606. }
  38607. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38608. /** @hidden */
  38609. export var fresnelFunction: {
  38610. name: string;
  38611. shader: string;
  38612. };
  38613. }
  38614. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38615. /** @hidden */
  38616. export var reflectionFunction: {
  38617. name: string;
  38618. shader: string;
  38619. };
  38620. }
  38621. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38622. /** @hidden */
  38623. export var bumpFragmentFunctions: {
  38624. name: string;
  38625. shader: string;
  38626. };
  38627. }
  38628. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38629. /** @hidden */
  38630. export var logDepthDeclaration: {
  38631. name: string;
  38632. shader: string;
  38633. };
  38634. }
  38635. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38636. /** @hidden */
  38637. export var bumpFragment: {
  38638. name: string;
  38639. shader: string;
  38640. };
  38641. }
  38642. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38643. /** @hidden */
  38644. export var depthPrePass: {
  38645. name: string;
  38646. shader: string;
  38647. };
  38648. }
  38649. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38650. /** @hidden */
  38651. export var lightFragment: {
  38652. name: string;
  38653. shader: string;
  38654. };
  38655. }
  38656. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38657. /** @hidden */
  38658. export var logDepthFragment: {
  38659. name: string;
  38660. shader: string;
  38661. };
  38662. }
  38663. declare module "babylonjs/Shaders/default.fragment" {
  38664. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38665. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38667. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38668. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38669. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38670. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38671. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38672. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38673. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38674. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38675. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38676. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38677. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38678. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38680. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38681. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38682. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38683. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38684. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38685. /** @hidden */
  38686. export var defaultPixelShader: {
  38687. name: string;
  38688. shader: string;
  38689. };
  38690. }
  38691. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38692. /** @hidden */
  38693. export var defaultVertexDeclaration: {
  38694. name: string;
  38695. shader: string;
  38696. };
  38697. }
  38698. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38699. /** @hidden */
  38700. export var bumpVertexDeclaration: {
  38701. name: string;
  38702. shader: string;
  38703. };
  38704. }
  38705. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38706. /** @hidden */
  38707. export var bumpVertex: {
  38708. name: string;
  38709. shader: string;
  38710. };
  38711. }
  38712. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38713. /** @hidden */
  38714. export var fogVertex: {
  38715. name: string;
  38716. shader: string;
  38717. };
  38718. }
  38719. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38720. /** @hidden */
  38721. export var shadowsVertex: {
  38722. name: string;
  38723. shader: string;
  38724. };
  38725. }
  38726. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38727. /** @hidden */
  38728. export var pointCloudVertex: {
  38729. name: string;
  38730. shader: string;
  38731. };
  38732. }
  38733. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38734. /** @hidden */
  38735. export var logDepthVertex: {
  38736. name: string;
  38737. shader: string;
  38738. };
  38739. }
  38740. declare module "babylonjs/Shaders/default.vertex" {
  38741. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38742. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38743. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38744. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38745. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38746. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38747. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38748. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38749. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38750. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38751. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38752. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38753. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38754. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38755. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38756. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38757. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38758. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38759. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38760. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38761. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38762. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38763. /** @hidden */
  38764. export var defaultVertexShader: {
  38765. name: string;
  38766. shader: string;
  38767. };
  38768. }
  38769. declare module "babylonjs/Materials/standardMaterial" {
  38770. import { SmartArray } from "babylonjs/Misc/smartArray";
  38771. import { IAnimatable } from "babylonjs/Misc/tools";
  38772. import { Nullable } from "babylonjs/types";
  38773. import { Scene } from "babylonjs/scene";
  38774. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38777. import { Mesh } from "babylonjs/Meshes/mesh";
  38778. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38779. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38780. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38781. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38782. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38784. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38785. import "babylonjs/Shaders/default.fragment";
  38786. import "babylonjs/Shaders/default.vertex";
  38787. /** @hidden */
  38788. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38789. MAINUV1: boolean;
  38790. MAINUV2: boolean;
  38791. DIFFUSE: boolean;
  38792. DIFFUSEDIRECTUV: number;
  38793. AMBIENT: boolean;
  38794. AMBIENTDIRECTUV: number;
  38795. OPACITY: boolean;
  38796. OPACITYDIRECTUV: number;
  38797. OPACITYRGB: boolean;
  38798. REFLECTION: boolean;
  38799. EMISSIVE: boolean;
  38800. EMISSIVEDIRECTUV: number;
  38801. SPECULAR: boolean;
  38802. SPECULARDIRECTUV: number;
  38803. BUMP: boolean;
  38804. BUMPDIRECTUV: number;
  38805. PARALLAX: boolean;
  38806. PARALLAXOCCLUSION: boolean;
  38807. SPECULAROVERALPHA: boolean;
  38808. CLIPPLANE: boolean;
  38809. CLIPPLANE2: boolean;
  38810. CLIPPLANE3: boolean;
  38811. CLIPPLANE4: boolean;
  38812. ALPHATEST: boolean;
  38813. DEPTHPREPASS: boolean;
  38814. ALPHAFROMDIFFUSE: boolean;
  38815. POINTSIZE: boolean;
  38816. FOG: boolean;
  38817. SPECULARTERM: boolean;
  38818. DIFFUSEFRESNEL: boolean;
  38819. OPACITYFRESNEL: boolean;
  38820. REFLECTIONFRESNEL: boolean;
  38821. REFRACTIONFRESNEL: boolean;
  38822. EMISSIVEFRESNEL: boolean;
  38823. FRESNEL: boolean;
  38824. NORMAL: boolean;
  38825. UV1: boolean;
  38826. UV2: boolean;
  38827. VERTEXCOLOR: boolean;
  38828. VERTEXALPHA: boolean;
  38829. NUM_BONE_INFLUENCERS: number;
  38830. BonesPerMesh: number;
  38831. BONETEXTURE: boolean;
  38832. INSTANCES: boolean;
  38833. GLOSSINESS: boolean;
  38834. ROUGHNESS: boolean;
  38835. EMISSIVEASILLUMINATION: boolean;
  38836. LINKEMISSIVEWITHDIFFUSE: boolean;
  38837. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38838. LIGHTMAP: boolean;
  38839. LIGHTMAPDIRECTUV: number;
  38840. OBJECTSPACE_NORMALMAP: boolean;
  38841. USELIGHTMAPASSHADOWMAP: boolean;
  38842. REFLECTIONMAP_3D: boolean;
  38843. REFLECTIONMAP_SPHERICAL: boolean;
  38844. REFLECTIONMAP_PLANAR: boolean;
  38845. REFLECTIONMAP_CUBIC: boolean;
  38846. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38847. REFLECTIONMAP_PROJECTION: boolean;
  38848. REFLECTIONMAP_SKYBOX: boolean;
  38849. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38850. REFLECTIONMAP_EXPLICIT: boolean;
  38851. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38852. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38853. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38854. INVERTCUBICMAP: boolean;
  38855. LOGARITHMICDEPTH: boolean;
  38856. REFRACTION: boolean;
  38857. REFRACTIONMAP_3D: boolean;
  38858. REFLECTIONOVERALPHA: boolean;
  38859. TWOSIDEDLIGHTING: boolean;
  38860. SHADOWFLOAT: boolean;
  38861. MORPHTARGETS: boolean;
  38862. MORPHTARGETS_NORMAL: boolean;
  38863. MORPHTARGETS_TANGENT: boolean;
  38864. NUM_MORPH_INFLUENCERS: number;
  38865. NONUNIFORMSCALING: boolean;
  38866. PREMULTIPLYALPHA: boolean;
  38867. IMAGEPROCESSING: boolean;
  38868. VIGNETTE: boolean;
  38869. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38870. VIGNETTEBLENDMODEOPAQUE: boolean;
  38871. TONEMAPPING: boolean;
  38872. TONEMAPPING_ACES: boolean;
  38873. CONTRAST: boolean;
  38874. COLORCURVES: boolean;
  38875. COLORGRADING: boolean;
  38876. COLORGRADING3D: boolean;
  38877. SAMPLER3DGREENDEPTH: boolean;
  38878. SAMPLER3DBGRMAP: boolean;
  38879. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38880. /**
  38881. * If the reflection texture on this material is in linear color space
  38882. * @hidden
  38883. */
  38884. IS_REFLECTION_LINEAR: boolean;
  38885. /**
  38886. * If the refraction texture on this material is in linear color space
  38887. * @hidden
  38888. */
  38889. IS_REFRACTION_LINEAR: boolean;
  38890. EXPOSURE: boolean;
  38891. constructor();
  38892. setReflectionMode(modeToEnable: string): void;
  38893. }
  38894. /**
  38895. * This is the default material used in Babylon. It is the best trade off between quality
  38896. * and performances.
  38897. * @see http://doc.babylonjs.com/babylon101/materials
  38898. */
  38899. export class StandardMaterial extends PushMaterial {
  38900. private _diffuseTexture;
  38901. /**
  38902. * The basic texture of the material as viewed under a light.
  38903. */
  38904. diffuseTexture: Nullable<BaseTexture>;
  38905. private _ambientTexture;
  38906. /**
  38907. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38908. */
  38909. ambientTexture: Nullable<BaseTexture>;
  38910. private _opacityTexture;
  38911. /**
  38912. * Define the transparency of the material from a texture.
  38913. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38914. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38915. */
  38916. opacityTexture: Nullable<BaseTexture>;
  38917. private _reflectionTexture;
  38918. /**
  38919. * Define the texture used to display the reflection.
  38920. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38921. */
  38922. reflectionTexture: Nullable<BaseTexture>;
  38923. private _emissiveTexture;
  38924. /**
  38925. * Define texture of the material as if self lit.
  38926. * This will be mixed in the final result even in the absence of light.
  38927. */
  38928. emissiveTexture: Nullable<BaseTexture>;
  38929. private _specularTexture;
  38930. /**
  38931. * Define how the color and intensity of the highlight given by the light in the material.
  38932. */
  38933. specularTexture: Nullable<BaseTexture>;
  38934. private _bumpTexture;
  38935. /**
  38936. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38937. * 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.
  38938. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38939. */
  38940. bumpTexture: Nullable<BaseTexture>;
  38941. private _lightmapTexture;
  38942. /**
  38943. * Complex lighting can be computationally expensive to compute at runtime.
  38944. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38945. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38946. */
  38947. lightmapTexture: Nullable<BaseTexture>;
  38948. private _refractionTexture;
  38949. /**
  38950. * Define the texture used to display the refraction.
  38951. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38952. */
  38953. refractionTexture: Nullable<BaseTexture>;
  38954. /**
  38955. * The color of the material lit by the environmental background lighting.
  38956. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38957. */
  38958. ambientColor: Color3;
  38959. /**
  38960. * The basic color of the material as viewed under a light.
  38961. */
  38962. diffuseColor: Color3;
  38963. /**
  38964. * Define how the color and intensity of the highlight given by the light in the material.
  38965. */
  38966. specularColor: Color3;
  38967. /**
  38968. * Define the color of the material as if self lit.
  38969. * This will be mixed in the final result even in the absence of light.
  38970. */
  38971. emissiveColor: Color3;
  38972. /**
  38973. * Defines how sharp are the highlights in the material.
  38974. * The bigger the value the sharper giving a more glossy feeling to the result.
  38975. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38976. */
  38977. specularPower: number;
  38978. private _useAlphaFromDiffuseTexture;
  38979. /**
  38980. * Does the transparency come from the diffuse texture alpha channel.
  38981. */
  38982. useAlphaFromDiffuseTexture: boolean;
  38983. private _useEmissiveAsIllumination;
  38984. /**
  38985. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38986. */
  38987. useEmissiveAsIllumination: boolean;
  38988. private _linkEmissiveWithDiffuse;
  38989. /**
  38990. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38991. * the emissive level when the final color is close to one.
  38992. */
  38993. linkEmissiveWithDiffuse: boolean;
  38994. private _useSpecularOverAlpha;
  38995. /**
  38996. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38997. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38998. */
  38999. useSpecularOverAlpha: boolean;
  39000. private _useReflectionOverAlpha;
  39001. /**
  39002. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39003. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39004. */
  39005. useReflectionOverAlpha: boolean;
  39006. private _disableLighting;
  39007. /**
  39008. * Does lights from the scene impacts this material.
  39009. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39010. */
  39011. disableLighting: boolean;
  39012. private _useObjectSpaceNormalMap;
  39013. /**
  39014. * Allows using an object space normal map (instead of tangent space).
  39015. */
  39016. useObjectSpaceNormalMap: boolean;
  39017. private _useParallax;
  39018. /**
  39019. * Is parallax enabled or not.
  39020. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39021. */
  39022. useParallax: boolean;
  39023. private _useParallaxOcclusion;
  39024. /**
  39025. * Is parallax occlusion enabled or not.
  39026. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39027. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39028. */
  39029. useParallaxOcclusion: boolean;
  39030. /**
  39031. * 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.
  39032. */
  39033. parallaxScaleBias: number;
  39034. private _roughness;
  39035. /**
  39036. * Helps to define how blurry the reflections should appears in the material.
  39037. */
  39038. roughness: number;
  39039. /**
  39040. * In case of refraction, define the value of the indice of refraction.
  39041. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39042. */
  39043. indexOfRefraction: number;
  39044. /**
  39045. * Invert the refraction texture alongside the y axis.
  39046. * It can be useful with procedural textures or probe for instance.
  39047. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39048. */
  39049. invertRefractionY: boolean;
  39050. /**
  39051. * Defines the alpha limits in alpha test mode.
  39052. */
  39053. alphaCutOff: number;
  39054. private _useLightmapAsShadowmap;
  39055. /**
  39056. * In case of light mapping, define whether the map contains light or shadow informations.
  39057. */
  39058. useLightmapAsShadowmap: boolean;
  39059. private _diffuseFresnelParameters;
  39060. /**
  39061. * Define the diffuse fresnel parameters of the material.
  39062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39063. */
  39064. diffuseFresnelParameters: FresnelParameters;
  39065. private _opacityFresnelParameters;
  39066. /**
  39067. * Define the opacity fresnel parameters of the material.
  39068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39069. */
  39070. opacityFresnelParameters: FresnelParameters;
  39071. private _reflectionFresnelParameters;
  39072. /**
  39073. * Define the reflection fresnel parameters of the material.
  39074. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39075. */
  39076. reflectionFresnelParameters: FresnelParameters;
  39077. private _refractionFresnelParameters;
  39078. /**
  39079. * Define the refraction fresnel parameters of the material.
  39080. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39081. */
  39082. refractionFresnelParameters: FresnelParameters;
  39083. private _emissiveFresnelParameters;
  39084. /**
  39085. * Define the emissive fresnel parameters of the material.
  39086. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39087. */
  39088. emissiveFresnelParameters: FresnelParameters;
  39089. private _useReflectionFresnelFromSpecular;
  39090. /**
  39091. * If true automatically deducts the fresnels values from the material specularity.
  39092. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39093. */
  39094. useReflectionFresnelFromSpecular: boolean;
  39095. private _useGlossinessFromSpecularMapAlpha;
  39096. /**
  39097. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39098. */
  39099. useGlossinessFromSpecularMapAlpha: boolean;
  39100. private _maxSimultaneousLights;
  39101. /**
  39102. * Defines the maximum number of lights that can be used in the material
  39103. */
  39104. maxSimultaneousLights: number;
  39105. private _invertNormalMapX;
  39106. /**
  39107. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39108. */
  39109. invertNormalMapX: boolean;
  39110. private _invertNormalMapY;
  39111. /**
  39112. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39113. */
  39114. invertNormalMapY: boolean;
  39115. private _twoSidedLighting;
  39116. /**
  39117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39118. */
  39119. twoSidedLighting: boolean;
  39120. /**
  39121. * Default configuration related to image processing available in the standard Material.
  39122. */
  39123. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39124. /**
  39125. * Gets the image processing configuration used either in this material.
  39126. */
  39127. /**
  39128. * Sets the Default image processing configuration used either in the this material.
  39129. *
  39130. * If sets to null, the scene one is in use.
  39131. */
  39132. imageProcessingConfiguration: ImageProcessingConfiguration;
  39133. /**
  39134. * Keep track of the image processing observer to allow dispose and replace.
  39135. */
  39136. private _imageProcessingObserver;
  39137. /**
  39138. * Attaches a new image processing configuration to the Standard Material.
  39139. * @param configuration
  39140. */
  39141. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39142. /**
  39143. * Gets wether the color curves effect is enabled.
  39144. */
  39145. /**
  39146. * Sets wether the color curves effect is enabled.
  39147. */
  39148. cameraColorCurvesEnabled: boolean;
  39149. /**
  39150. * Gets wether the color grading effect is enabled.
  39151. */
  39152. /**
  39153. * Gets wether the color grading effect is enabled.
  39154. */
  39155. cameraColorGradingEnabled: boolean;
  39156. /**
  39157. * Gets wether tonemapping is enabled or not.
  39158. */
  39159. /**
  39160. * Sets wether tonemapping is enabled or not
  39161. */
  39162. cameraToneMappingEnabled: boolean;
  39163. /**
  39164. * The camera exposure used on this material.
  39165. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39166. * This corresponds to a photographic exposure.
  39167. */
  39168. /**
  39169. * The camera exposure used on this material.
  39170. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39171. * This corresponds to a photographic exposure.
  39172. */
  39173. cameraExposure: number;
  39174. /**
  39175. * Gets The camera contrast used on this material.
  39176. */
  39177. /**
  39178. * Sets The camera contrast used on this material.
  39179. */
  39180. cameraContrast: number;
  39181. /**
  39182. * Gets the Color Grading 2D Lookup Texture.
  39183. */
  39184. /**
  39185. * Sets the Color Grading 2D Lookup Texture.
  39186. */
  39187. cameraColorGradingTexture: Nullable<BaseTexture>;
  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. /**
  39195. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39196. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39197. * 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;
  39198. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39199. */
  39200. cameraColorCurves: Nullable<ColorCurves>;
  39201. /**
  39202. * Custom callback helping to override the default shader used in the material.
  39203. */
  39204. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39205. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39206. protected _worldViewProjectionMatrix: Matrix;
  39207. protected _globalAmbientColor: Color3;
  39208. protected _useLogarithmicDepth: boolean;
  39209. /**
  39210. * Instantiates a new standard material.
  39211. * This is the default material used in Babylon. It is the best trade off between quality
  39212. * and performances.
  39213. * @see http://doc.babylonjs.com/babylon101/materials
  39214. * @param name Define the name of the material in the scene
  39215. * @param scene Define the scene the material belong to
  39216. */
  39217. constructor(name: string, scene: Scene);
  39218. /**
  39219. * Gets a boolean indicating that current material needs to register RTT
  39220. */
  39221. readonly hasRenderTargetTextures: boolean;
  39222. /**
  39223. * Gets the current class name of the material e.g. "StandardMaterial"
  39224. * Mainly use in serialization.
  39225. * @returns the class name
  39226. */
  39227. getClassName(): string;
  39228. /**
  39229. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39230. * You can try switching to logarithmic depth.
  39231. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39232. */
  39233. useLogarithmicDepth: boolean;
  39234. /**
  39235. * Specifies if the material will require alpha blending
  39236. * @returns a boolean specifying if alpha blending is needed
  39237. */
  39238. needAlphaBlending(): boolean;
  39239. /**
  39240. * Specifies if this material should be rendered in alpha test mode
  39241. * @returns a boolean specifying if an alpha test is needed.
  39242. */
  39243. needAlphaTesting(): boolean;
  39244. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39245. /**
  39246. * Get the texture used for alpha test purpose.
  39247. * @returns the diffuse texture in case of the standard material.
  39248. */
  39249. getAlphaTestTexture(): Nullable<BaseTexture>;
  39250. /**
  39251. * Get if the submesh is ready to be used and all its information available.
  39252. * Child classes can use it to update shaders
  39253. * @param mesh defines the mesh to check
  39254. * @param subMesh defines which submesh to check
  39255. * @param useInstances specifies that instances should be used
  39256. * @returns a boolean indicating that the submesh is ready or not
  39257. */
  39258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39259. /**
  39260. * Builds the material UBO layouts.
  39261. * Used internally during the effect preparation.
  39262. */
  39263. buildUniformLayout(): void;
  39264. /**
  39265. * Unbinds the material from the mesh
  39266. */
  39267. unbind(): void;
  39268. /**
  39269. * Binds the submesh to this material by preparing the effect and shader to draw
  39270. * @param world defines the world transformation matrix
  39271. * @param mesh defines the mesh containing the submesh
  39272. * @param subMesh defines the submesh to bind the material to
  39273. */
  39274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39275. /**
  39276. * Get the list of animatables in the material.
  39277. * @returns the list of animatables object used in the material
  39278. */
  39279. getAnimatables(): IAnimatable[];
  39280. /**
  39281. * Gets the active textures from the material
  39282. * @returns an array of textures
  39283. */
  39284. getActiveTextures(): BaseTexture[];
  39285. /**
  39286. * Specifies if the material uses a texture
  39287. * @param texture defines the texture to check against the material
  39288. * @returns a boolean specifying if the material uses the texture
  39289. */
  39290. hasTexture(texture: BaseTexture): boolean;
  39291. /**
  39292. * Disposes the material
  39293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39295. */
  39296. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39297. /**
  39298. * Makes a duplicate of the material, and gives it a new name
  39299. * @param name defines the new name for the duplicated material
  39300. * @returns the cloned material
  39301. */
  39302. clone(name: string): StandardMaterial;
  39303. /**
  39304. * Serializes this material in a JSON representation
  39305. * @returns the serialized material object
  39306. */
  39307. serialize(): any;
  39308. /**
  39309. * Creates a standard material from parsed material data
  39310. * @param source defines the JSON representation of the material
  39311. * @param scene defines the hosting scene
  39312. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39313. * @returns a new standard material
  39314. */
  39315. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39316. /**
  39317. * Are diffuse textures enabled in the application.
  39318. */
  39319. static DiffuseTextureEnabled: boolean;
  39320. /**
  39321. * Are ambient textures enabled in the application.
  39322. */
  39323. static AmbientTextureEnabled: boolean;
  39324. /**
  39325. * Are opacity textures enabled in the application.
  39326. */
  39327. static OpacityTextureEnabled: boolean;
  39328. /**
  39329. * Are reflection textures enabled in the application.
  39330. */
  39331. static ReflectionTextureEnabled: boolean;
  39332. /**
  39333. * Are emissive textures enabled in the application.
  39334. */
  39335. static EmissiveTextureEnabled: boolean;
  39336. /**
  39337. * Are specular textures enabled in the application.
  39338. */
  39339. static SpecularTextureEnabled: boolean;
  39340. /**
  39341. * Are bump textures enabled in the application.
  39342. */
  39343. static BumpTextureEnabled: boolean;
  39344. /**
  39345. * Are lightmap textures enabled in the application.
  39346. */
  39347. static LightmapTextureEnabled: boolean;
  39348. /**
  39349. * Are refraction textures enabled in the application.
  39350. */
  39351. static RefractionTextureEnabled: boolean;
  39352. /**
  39353. * Are color grading textures enabled in the application.
  39354. */
  39355. static ColorGradingTextureEnabled: boolean;
  39356. /**
  39357. * Are fresnels enabled in the application.
  39358. */
  39359. static FresnelEnabled: boolean;
  39360. }
  39361. }
  39362. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39363. import { Scene } from "babylonjs/scene";
  39364. import { Texture } from "babylonjs/Materials/Textures/texture";
  39365. /**
  39366. * A class extending Texture allowing drawing on a texture
  39367. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39368. */
  39369. export class DynamicTexture extends Texture {
  39370. private _generateMipMaps;
  39371. private _canvas;
  39372. private _context;
  39373. private _engine;
  39374. /**
  39375. * Creates a DynamicTexture
  39376. * @param name defines the name of the texture
  39377. * @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
  39378. * @param scene defines the scene where you want the texture
  39379. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39380. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39381. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39382. */
  39383. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39384. /**
  39385. * Get the current class name of the texture useful for serialization or dynamic coding.
  39386. * @returns "DynamicTexture"
  39387. */
  39388. getClassName(): string;
  39389. /**
  39390. * Gets the current state of canRescale
  39391. */
  39392. readonly canRescale: boolean;
  39393. private _recreate;
  39394. /**
  39395. * Scales the texture
  39396. * @param ratio the scale factor to apply to both width and height
  39397. */
  39398. scale(ratio: number): void;
  39399. /**
  39400. * Resizes the texture
  39401. * @param width the new width
  39402. * @param height the new height
  39403. */
  39404. scaleTo(width: number, height: number): void;
  39405. /**
  39406. * Gets the context of the canvas used by the texture
  39407. * @returns the canvas context of the dynamic texture
  39408. */
  39409. getContext(): CanvasRenderingContext2D;
  39410. /**
  39411. * Clears the texture
  39412. */
  39413. clear(): void;
  39414. /**
  39415. * Updates the texture
  39416. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39417. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39418. */
  39419. update(invertY?: boolean, premulAlpha?: boolean): void;
  39420. /**
  39421. * Draws text onto the texture
  39422. * @param text defines the text to be drawn
  39423. * @param x defines the placement of the text from the left
  39424. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39425. * @param font defines the font to be used with font-style, font-size, font-name
  39426. * @param color defines the color used for the text
  39427. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39428. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39429. * @param update defines whether texture is immediately update (default is true)
  39430. */
  39431. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39432. /**
  39433. * Clones the texture
  39434. * @returns the clone of the texture.
  39435. */
  39436. clone(): DynamicTexture;
  39437. /**
  39438. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39439. * @returns a serialized dynamic texture object
  39440. */
  39441. serialize(): any;
  39442. /** @hidden */
  39443. _rebuild(): void;
  39444. }
  39445. }
  39446. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39447. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39448. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39449. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39450. /** @hidden */
  39451. export var imageProcessingPixelShader: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39457. import { Nullable } from "babylonjs/types";
  39458. import { Color4 } from "babylonjs/Maths/math";
  39459. import { Camera } from "babylonjs/Cameras/camera";
  39460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39461. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39462. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39464. import { Engine } from "babylonjs/Engines/engine";
  39465. import "babylonjs/Shaders/imageProcessing.fragment";
  39466. import "babylonjs/Shaders/postprocess.vertex";
  39467. /**
  39468. * ImageProcessingPostProcess
  39469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39470. */
  39471. export class ImageProcessingPostProcess extends PostProcess {
  39472. /**
  39473. * Default configuration related to image processing available in the PBR Material.
  39474. */
  39475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39476. /**
  39477. * Gets the image processing configuration used either in this material.
  39478. */
  39479. /**
  39480. * Sets the Default image processing configuration used either in the this material.
  39481. *
  39482. * If sets to null, the scene one is in use.
  39483. */
  39484. imageProcessingConfiguration: ImageProcessingConfiguration;
  39485. /**
  39486. * Keep track of the image processing observer to allow dispose and replace.
  39487. */
  39488. private _imageProcessingObserver;
  39489. /**
  39490. * Attaches a new image processing configuration to the PBR Material.
  39491. * @param configuration
  39492. */
  39493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39494. /**
  39495. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39496. */
  39497. /**
  39498. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39499. */
  39500. colorCurves: Nullable<ColorCurves>;
  39501. /**
  39502. * Gets wether the color curves effect is enabled.
  39503. */
  39504. /**
  39505. * Sets wether the color curves effect is enabled.
  39506. */
  39507. colorCurvesEnabled: boolean;
  39508. /**
  39509. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39510. */
  39511. /**
  39512. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39513. */
  39514. colorGradingTexture: Nullable<BaseTexture>;
  39515. /**
  39516. * Gets wether the color grading effect is enabled.
  39517. */
  39518. /**
  39519. * Gets wether the color grading effect is enabled.
  39520. */
  39521. colorGradingEnabled: boolean;
  39522. /**
  39523. * Gets exposure used in the effect.
  39524. */
  39525. /**
  39526. * Sets exposure used in the effect.
  39527. */
  39528. exposure: number;
  39529. /**
  39530. * Gets wether tonemapping is enabled or not.
  39531. */
  39532. /**
  39533. * Sets wether tonemapping is enabled or not
  39534. */
  39535. toneMappingEnabled: boolean;
  39536. /**
  39537. * Gets the type of tone mapping effect.
  39538. */
  39539. /**
  39540. * Sets the type of tone mapping effect.
  39541. */
  39542. toneMappingType: number;
  39543. /**
  39544. * Gets contrast used in the effect.
  39545. */
  39546. /**
  39547. * Sets contrast used in the effect.
  39548. */
  39549. contrast: number;
  39550. /**
  39551. * Gets Vignette stretch size.
  39552. */
  39553. /**
  39554. * Sets Vignette stretch size.
  39555. */
  39556. vignetteStretch: number;
  39557. /**
  39558. * Gets Vignette centre X Offset.
  39559. */
  39560. /**
  39561. * Sets Vignette centre X Offset.
  39562. */
  39563. vignetteCentreX: number;
  39564. /**
  39565. * Gets Vignette centre Y Offset.
  39566. */
  39567. /**
  39568. * Sets Vignette centre Y Offset.
  39569. */
  39570. vignetteCentreY: number;
  39571. /**
  39572. * Gets Vignette weight or intensity of the vignette effect.
  39573. */
  39574. /**
  39575. * Sets Vignette weight or intensity of the vignette effect.
  39576. */
  39577. vignetteWeight: number;
  39578. /**
  39579. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39580. * if vignetteEnabled is set to true.
  39581. */
  39582. /**
  39583. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39584. * if vignetteEnabled is set to true.
  39585. */
  39586. vignetteColor: Color4;
  39587. /**
  39588. * Gets Camera field of view used by the Vignette effect.
  39589. */
  39590. /**
  39591. * Sets Camera field of view used by the Vignette effect.
  39592. */
  39593. vignetteCameraFov: number;
  39594. /**
  39595. * Gets the vignette blend mode allowing different kind of effect.
  39596. */
  39597. /**
  39598. * Sets the vignette blend mode allowing different kind of effect.
  39599. */
  39600. vignetteBlendMode: number;
  39601. /**
  39602. * Gets wether the vignette effect is enabled.
  39603. */
  39604. /**
  39605. * Sets wether the vignette effect is enabled.
  39606. */
  39607. vignetteEnabled: boolean;
  39608. private _fromLinearSpace;
  39609. /**
  39610. * Gets wether the input of the processing is in Gamma or Linear Space.
  39611. */
  39612. /**
  39613. * Sets wether the input of the processing is in Gamma or Linear Space.
  39614. */
  39615. fromLinearSpace: boolean;
  39616. /**
  39617. * Defines cache preventing GC.
  39618. */
  39619. private _defines;
  39620. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39621. /**
  39622. * "ImageProcessingPostProcess"
  39623. * @returns "ImageProcessingPostProcess"
  39624. */
  39625. getClassName(): string;
  39626. protected _updateParameters(): void;
  39627. dispose(camera?: Camera): void;
  39628. }
  39629. }
  39630. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39631. import { Scene } from "babylonjs/scene";
  39632. import { Color3 } from "babylonjs/Maths/math";
  39633. import { Mesh } from "babylonjs/Meshes/mesh";
  39634. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39635. /**
  39636. * Class containing static functions to help procedurally build meshes
  39637. */
  39638. export class GroundBuilder {
  39639. /**
  39640. * Creates a ground mesh
  39641. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39642. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39644. * @param name defines the name of the mesh
  39645. * @param options defines the options used to create the mesh
  39646. * @param scene defines the hosting scene
  39647. * @returns the ground mesh
  39648. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39649. */
  39650. static CreateGround(name: string, options: {
  39651. width?: number;
  39652. height?: number;
  39653. subdivisions?: number;
  39654. subdivisionsX?: number;
  39655. subdivisionsY?: number;
  39656. updatable?: boolean;
  39657. }, scene: any): Mesh;
  39658. /**
  39659. * Creates a tiled ground mesh
  39660. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39661. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39662. * * 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
  39663. * * 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
  39664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39665. * @param name defines the name of the mesh
  39666. * @param options defines the options used to create the mesh
  39667. * @param scene defines the hosting scene
  39668. * @returns the tiled ground mesh
  39669. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39670. */
  39671. static CreateTiledGround(name: string, options: {
  39672. xmin: number;
  39673. zmin: number;
  39674. xmax: number;
  39675. zmax: number;
  39676. subdivisions?: {
  39677. w: number;
  39678. h: number;
  39679. };
  39680. precision?: {
  39681. w: number;
  39682. h: number;
  39683. };
  39684. updatable?: boolean;
  39685. }, scene: Scene): Mesh;
  39686. /**
  39687. * Creates a ground mesh from a height map
  39688. * * The parameter `url` sets the URL of the height map image resource.
  39689. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39690. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39691. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39692. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39693. * * 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.
  39694. * * 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).
  39695. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39697. * @param name defines the name of the mesh
  39698. * @param url defines the url to the height map
  39699. * @param options defines the options used to create the mesh
  39700. * @param scene defines the hosting scene
  39701. * @returns the ground mesh
  39702. * @see https://doc.babylonjs.com/babylon101/height_map
  39703. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39704. */
  39705. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39706. width?: number;
  39707. height?: number;
  39708. subdivisions?: number;
  39709. minHeight?: number;
  39710. maxHeight?: number;
  39711. colorFilter?: Color3;
  39712. alphaFilter?: number;
  39713. updatable?: boolean;
  39714. onReady?: (mesh: GroundMesh) => void;
  39715. }, scene: Scene): GroundMesh;
  39716. }
  39717. }
  39718. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39719. import { Vector4 } from "babylonjs/Maths/math";
  39720. import { Mesh } from "babylonjs/Meshes/mesh";
  39721. /**
  39722. * Class containing static functions to help procedurally build meshes
  39723. */
  39724. export class TorusBuilder {
  39725. /**
  39726. * Creates a torus mesh
  39727. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39728. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39729. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39731. * * If you create a double-sided mesh, you can choose what parts of 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
  39732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39733. * @param name defines the name of the mesh
  39734. * @param options defines the options used to create the mesh
  39735. * @param scene defines the hosting scene
  39736. * @returns the torus mesh
  39737. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39738. */
  39739. static CreateTorus(name: string, options: {
  39740. diameter?: number;
  39741. thickness?: number;
  39742. tessellation?: number;
  39743. updatable?: boolean;
  39744. sideOrientation?: number;
  39745. frontUVs?: Vector4;
  39746. backUVs?: Vector4;
  39747. }, scene: any): Mesh;
  39748. }
  39749. }
  39750. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39751. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39752. import { Mesh } from "babylonjs/Meshes/mesh";
  39753. /**
  39754. * Class containing static functions to help procedurally build meshes
  39755. */
  39756. export class CylinderBuilder {
  39757. /**
  39758. * Creates a cylinder or a cone mesh
  39759. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39760. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39761. * * 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.
  39762. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39763. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39764. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39765. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39766. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39767. * * 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).
  39768. * * 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
  39769. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39770. * * 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
  39771. * * 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.
  39772. * * If `enclose` is false, a ring surface is one element.
  39773. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39774. * * 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
  39775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39776. * * If you create a double-sided mesh, you can choose what parts of 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
  39777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39778. * @param name defines the name of the mesh
  39779. * @param options defines the options used to create the mesh
  39780. * @param scene defines the hosting scene
  39781. * @returns the cylinder mesh
  39782. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39783. */
  39784. static CreateCylinder(name: string, options: {
  39785. height?: number;
  39786. diameterTop?: number;
  39787. diameterBottom?: number;
  39788. diameter?: number;
  39789. tessellation?: number;
  39790. subdivisions?: number;
  39791. arc?: number;
  39792. faceColors?: Color4[];
  39793. faceUV?: Vector4[];
  39794. updatable?: boolean;
  39795. hasRings?: boolean;
  39796. enclose?: boolean;
  39797. sideOrientation?: number;
  39798. frontUVs?: Vector4;
  39799. backUVs?: Vector4;
  39800. }, scene: any): Mesh;
  39801. }
  39802. }
  39803. declare module "babylonjs/Gamepads/gamepadManager" {
  39804. import { Observable } from "babylonjs/Misc/observable";
  39805. import { Nullable } from "babylonjs/types";
  39806. import { Scene } from "babylonjs/scene";
  39807. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39808. /**
  39809. * Manager for handling gamepads
  39810. */
  39811. export class GamepadManager {
  39812. private _scene?;
  39813. private _babylonGamepads;
  39814. private _oneGamepadConnected;
  39815. /** @hidden */
  39816. _isMonitoring: boolean;
  39817. private _gamepadEventSupported;
  39818. private _gamepadSupport;
  39819. /**
  39820. * observable to be triggered when the gamepad controller has been connected
  39821. */
  39822. onGamepadConnectedObservable: Observable<Gamepad>;
  39823. /**
  39824. * observable to be triggered when the gamepad controller has been disconnected
  39825. */
  39826. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39827. private _onGamepadConnectedEvent;
  39828. private _onGamepadDisconnectedEvent;
  39829. /**
  39830. * Initializes the gamepad manager
  39831. * @param _scene BabylonJS scene
  39832. */
  39833. constructor(_scene?: Scene | undefined);
  39834. /**
  39835. * The gamepads in the game pad manager
  39836. */
  39837. readonly gamepads: Gamepad[];
  39838. /**
  39839. * Get the gamepad controllers based on type
  39840. * @param type The type of gamepad controller
  39841. * @returns Nullable gamepad
  39842. */
  39843. getGamepadByType(type?: number): Nullable<Gamepad>;
  39844. /**
  39845. * Disposes the gamepad manager
  39846. */
  39847. dispose(): void;
  39848. private _addNewGamepad;
  39849. private _startMonitoringGamepads;
  39850. private _stopMonitoringGamepads;
  39851. /** @hidden */
  39852. _checkGamepadsStatus(): void;
  39853. private _updateGamepadObjects;
  39854. }
  39855. }
  39856. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39857. import { Nullable } from "babylonjs/types";
  39858. import { Scene } from "babylonjs/scene";
  39859. import { ISceneComponent } from "babylonjs/sceneComponent";
  39860. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39861. module "babylonjs/scene" {
  39862. interface Scene {
  39863. /** @hidden */
  39864. _gamepadManager: Nullable<GamepadManager>;
  39865. /**
  39866. * Gets the gamepad manager associated with the scene
  39867. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39868. */
  39869. gamepadManager: GamepadManager;
  39870. }
  39871. }
  39872. module "babylonjs/Cameras/freeCameraInputsManager" {
  39873. /**
  39874. * Interface representing a free camera inputs manager
  39875. */
  39876. interface FreeCameraInputsManager {
  39877. /**
  39878. * Adds gamepad input support to the FreeCameraInputsManager.
  39879. * @returns the FreeCameraInputsManager
  39880. */
  39881. addGamepad(): FreeCameraInputsManager;
  39882. }
  39883. }
  39884. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39885. /**
  39886. * Interface representing an arc rotate camera inputs manager
  39887. */
  39888. interface ArcRotateCameraInputsManager {
  39889. /**
  39890. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39891. * @returns the camera inputs manager
  39892. */
  39893. addGamepad(): ArcRotateCameraInputsManager;
  39894. }
  39895. }
  39896. /**
  39897. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39898. */
  39899. export class GamepadSystemSceneComponent implements ISceneComponent {
  39900. /**
  39901. * The component name helpfull to identify the component in the list of scene components.
  39902. */
  39903. readonly name: string;
  39904. /**
  39905. * The scene the component belongs to.
  39906. */
  39907. scene: Scene;
  39908. /**
  39909. * Creates a new instance of the component for the given scene
  39910. * @param scene Defines the scene to register the component in
  39911. */
  39912. constructor(scene: Scene);
  39913. /**
  39914. * Registers the component in a given scene
  39915. */
  39916. register(): void;
  39917. /**
  39918. * Rebuilds the elements related to this component in case of
  39919. * context lost for instance.
  39920. */
  39921. rebuild(): void;
  39922. /**
  39923. * Disposes the component and the associated ressources
  39924. */
  39925. dispose(): void;
  39926. private _beforeCameraUpdate;
  39927. }
  39928. }
  39929. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39930. import { Observable } from "babylonjs/Misc/observable";
  39931. import { Nullable } from "babylonjs/types";
  39932. import { Camera } from "babylonjs/Cameras/camera";
  39933. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39934. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39935. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39936. import { Scene } from "babylonjs/scene";
  39937. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39938. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39940. import { Mesh } from "babylonjs/Meshes/mesh";
  39941. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39942. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39943. import "babylonjs/Meshes/Builders/groundBuilder";
  39944. import "babylonjs/Meshes/Builders/torusBuilder";
  39945. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39946. import "babylonjs/Gamepads/gamepadSceneComponent";
  39947. import "babylonjs/Animations/animatable";
  39948. /**
  39949. * Options to modify the vr teleportation behavior.
  39950. */
  39951. export interface VRTeleportationOptions {
  39952. /**
  39953. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39954. */
  39955. floorMeshName?: string;
  39956. /**
  39957. * A list of meshes to be used as the teleportation floor. (default: empty)
  39958. */
  39959. floorMeshes?: Mesh[];
  39960. }
  39961. /**
  39962. * Options to modify the vr experience helper's behavior.
  39963. */
  39964. export interface VRExperienceHelperOptions extends WebVROptions {
  39965. /**
  39966. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39967. */
  39968. createDeviceOrientationCamera?: boolean;
  39969. /**
  39970. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39971. */
  39972. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39973. /**
  39974. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39975. */
  39976. laserToggle?: boolean;
  39977. /**
  39978. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39979. */
  39980. floorMeshes?: Mesh[];
  39981. /**
  39982. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39983. */
  39984. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39985. }
  39986. /**
  39987. * Event containing information after VR has been entered
  39988. */
  39989. export class OnAfterEnteringVRObservableEvent {
  39990. /**
  39991. * If entering vr was successful
  39992. */
  39993. success: boolean;
  39994. }
  39995. /**
  39996. * Helps to quickly add VR support to an existing scene.
  39997. * See http://doc.babylonjs.com/how_to/webvr_helper
  39998. */
  39999. export class VRExperienceHelper {
  40000. /** Options to modify the vr experience helper's behavior. */
  40001. webVROptions: VRExperienceHelperOptions;
  40002. private _scene;
  40003. private _position;
  40004. private _btnVR;
  40005. private _btnVRDisplayed;
  40006. private _webVRsupported;
  40007. private _webVRready;
  40008. private _webVRrequesting;
  40009. private _webVRpresenting;
  40010. private _hasEnteredVR;
  40011. private _fullscreenVRpresenting;
  40012. private _canvas;
  40013. private _webVRCamera;
  40014. private _vrDeviceOrientationCamera;
  40015. private _deviceOrientationCamera;
  40016. private _existingCamera;
  40017. private _onKeyDown;
  40018. private _onVrDisplayPresentChange;
  40019. private _onVRDisplayChanged;
  40020. private _onVRRequestPresentStart;
  40021. private _onVRRequestPresentComplete;
  40022. /**
  40023. * Observable raised right before entering VR.
  40024. */
  40025. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40026. /**
  40027. * Observable raised when entering VR has completed.
  40028. */
  40029. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40030. /**
  40031. * Observable raised when exiting VR.
  40032. */
  40033. onExitingVRObservable: Observable<VRExperienceHelper>;
  40034. /**
  40035. * Observable raised when controller mesh is loaded.
  40036. */
  40037. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40038. /** Return this.onEnteringVRObservable
  40039. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40040. */
  40041. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40042. /** Return this.onExitingVRObservable
  40043. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40044. */
  40045. readonly onExitingVR: Observable<VRExperienceHelper>;
  40046. /** Return this.onControllerMeshLoadedObservable
  40047. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40048. */
  40049. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40050. private _rayLength;
  40051. private _useCustomVRButton;
  40052. private _teleportationRequested;
  40053. private _teleportActive;
  40054. private _floorMeshName;
  40055. private _floorMeshesCollection;
  40056. private _rotationAllowed;
  40057. private _teleportBackwardsVector;
  40058. private _teleportationTarget;
  40059. private _isDefaultTeleportationTarget;
  40060. private _postProcessMove;
  40061. private _teleportationFillColor;
  40062. private _teleportationBorderColor;
  40063. private _rotationAngle;
  40064. private _haloCenter;
  40065. private _cameraGazer;
  40066. private _padSensibilityUp;
  40067. private _padSensibilityDown;
  40068. private _leftController;
  40069. private _rightController;
  40070. /**
  40071. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40072. */
  40073. onNewMeshSelected: Observable<AbstractMesh>;
  40074. /**
  40075. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40076. */
  40077. onNewMeshPicked: Observable<PickingInfo>;
  40078. private _circleEase;
  40079. /**
  40080. * Observable raised before camera teleportation
  40081. */
  40082. onBeforeCameraTeleport: Observable<Vector3>;
  40083. /**
  40084. * Observable raised after camera teleportation
  40085. */
  40086. onAfterCameraTeleport: Observable<Vector3>;
  40087. /**
  40088. * Observable raised when current selected mesh gets unselected
  40089. */
  40090. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40091. private _raySelectionPredicate;
  40092. /**
  40093. * To be optionaly changed by user to define custom ray selection
  40094. */
  40095. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40096. /**
  40097. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40098. */
  40099. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40100. /**
  40101. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40102. */
  40103. teleportationEnabled: boolean;
  40104. private _defaultHeight;
  40105. private _teleportationInitialized;
  40106. private _interactionsEnabled;
  40107. private _interactionsRequested;
  40108. private _displayGaze;
  40109. private _displayLaserPointer;
  40110. /**
  40111. * The mesh used to display where the user is going to teleport.
  40112. */
  40113. /**
  40114. * Sets the mesh to be used to display where the user is going to teleport.
  40115. */
  40116. teleportationTarget: Mesh;
  40117. /**
  40118. * 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
  40119. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40120. * See http://doc.babylonjs.com/resources/baking_transformations
  40121. */
  40122. gazeTrackerMesh: Mesh;
  40123. /**
  40124. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40125. */
  40126. updateGazeTrackerScale: boolean;
  40127. /**
  40128. * If the gaze trackers color should be updated when selecting meshes
  40129. */
  40130. updateGazeTrackerColor: boolean;
  40131. /**
  40132. * The gaze tracking mesh corresponding to the left controller
  40133. */
  40134. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40135. /**
  40136. * The gaze tracking mesh corresponding to the right controller
  40137. */
  40138. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40139. /**
  40140. * If the ray of the gaze should be displayed.
  40141. */
  40142. /**
  40143. * Sets if the ray of the gaze should be displayed.
  40144. */
  40145. displayGaze: boolean;
  40146. /**
  40147. * If the ray of the LaserPointer should be displayed.
  40148. */
  40149. /**
  40150. * Sets if the ray of the LaserPointer should be displayed.
  40151. */
  40152. displayLaserPointer: boolean;
  40153. /**
  40154. * The deviceOrientationCamera used as the camera when not in VR.
  40155. */
  40156. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40157. /**
  40158. * Based on the current WebVR support, returns the current VR camera used.
  40159. */
  40160. readonly currentVRCamera: Nullable<Camera>;
  40161. /**
  40162. * The webVRCamera which is used when in VR.
  40163. */
  40164. readonly webVRCamera: WebVRFreeCamera;
  40165. /**
  40166. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40167. */
  40168. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40169. private readonly _teleportationRequestInitiated;
  40170. /**
  40171. * Defines wether or not Pointer lock should be requested when switching to
  40172. * full screen.
  40173. */
  40174. requestPointerLockOnFullScreen: boolean;
  40175. /**
  40176. * Instantiates a VRExperienceHelper.
  40177. * Helps to quickly add VR support to an existing scene.
  40178. * @param scene The scene the VRExperienceHelper belongs to.
  40179. * @param webVROptions Options to modify the vr experience helper's behavior.
  40180. */
  40181. constructor(scene: Scene,
  40182. /** Options to modify the vr experience helper's behavior. */
  40183. webVROptions?: VRExperienceHelperOptions);
  40184. private _onDefaultMeshLoaded;
  40185. private _onResize;
  40186. private _onFullscreenChange;
  40187. /**
  40188. * Gets a value indicating if we are currently in VR mode.
  40189. */
  40190. readonly isInVRMode: boolean;
  40191. private onVrDisplayPresentChange;
  40192. private onVRDisplayChanged;
  40193. private moveButtonToBottomRight;
  40194. private displayVRButton;
  40195. private updateButtonVisibility;
  40196. private _cachedAngularSensibility;
  40197. /**
  40198. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40199. * Otherwise, will use the fullscreen API.
  40200. */
  40201. enterVR(): void;
  40202. /**
  40203. * Attempt to exit VR, or fullscreen.
  40204. */
  40205. exitVR(): void;
  40206. /**
  40207. * The position of the vr experience helper.
  40208. */
  40209. /**
  40210. * Sets the position of the vr experience helper.
  40211. */
  40212. position: Vector3;
  40213. /**
  40214. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40215. */
  40216. enableInteractions(): void;
  40217. private readonly _noControllerIsActive;
  40218. private beforeRender;
  40219. private _isTeleportationFloor;
  40220. /**
  40221. * Adds a floor mesh to be used for teleportation.
  40222. * @param floorMesh the mesh to be used for teleportation.
  40223. */
  40224. addFloorMesh(floorMesh: Mesh): void;
  40225. /**
  40226. * Removes a floor mesh from being used for teleportation.
  40227. * @param floorMesh the mesh to be removed.
  40228. */
  40229. removeFloorMesh(floorMesh: Mesh): void;
  40230. /**
  40231. * Enables interactions and teleportation using the VR controllers and gaze.
  40232. * @param vrTeleportationOptions options to modify teleportation behavior.
  40233. */
  40234. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40235. private _onNewGamepadConnected;
  40236. private _tryEnableInteractionOnController;
  40237. private _onNewGamepadDisconnected;
  40238. private _enableInteractionOnController;
  40239. private _checkTeleportWithRay;
  40240. private _checkRotate;
  40241. private _checkTeleportBackwards;
  40242. private _enableTeleportationOnController;
  40243. private _createTeleportationCircles;
  40244. private _displayTeleportationTarget;
  40245. private _hideTeleportationTarget;
  40246. private _rotateCamera;
  40247. private _moveTeleportationSelectorTo;
  40248. private _workingVector;
  40249. private _workingQuaternion;
  40250. private _workingMatrix;
  40251. /**
  40252. * Teleports the users feet to the desired location
  40253. * @param location The location where the user's feet should be placed
  40254. */
  40255. teleportCamera(location: Vector3): void;
  40256. private _convertNormalToDirectionOfRay;
  40257. private _castRayAndSelectObject;
  40258. private _notifySelectedMeshUnselected;
  40259. /**
  40260. * Sets the color of the laser ray from the vr controllers.
  40261. * @param color new color for the ray.
  40262. */
  40263. changeLaserColor(color: Color3): void;
  40264. /**
  40265. * Sets the color of the ray from the vr headsets gaze.
  40266. * @param color new color for the ray.
  40267. */
  40268. changeGazeColor(color: Color3): void;
  40269. /**
  40270. * Exits VR and disposes of the vr experience helper
  40271. */
  40272. dispose(): void;
  40273. /**
  40274. * Gets the name of the VRExperienceHelper class
  40275. * @returns "VRExperienceHelper"
  40276. */
  40277. getClassName(): string;
  40278. }
  40279. }
  40280. declare module "babylonjs/Cameras/VR/index" {
  40281. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40282. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40283. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40284. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40285. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40286. export * from "babylonjs/Cameras/VR/webVRCamera";
  40287. }
  40288. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40289. import { Observable } from "babylonjs/Misc/observable";
  40290. import { Nullable } from "babylonjs/types";
  40291. import { IDisposable, Scene } from "babylonjs/scene";
  40292. import { Vector3 } from "babylonjs/Maths/math";
  40293. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40294. import { Ray } from "babylonjs/Culling/ray";
  40295. /**
  40296. * Manages an XRSession
  40297. * @see https://doc.babylonjs.com/how_to/webxr
  40298. */
  40299. export class WebXRSessionManager implements IDisposable {
  40300. private scene;
  40301. /**
  40302. * Fires every time a new xrFrame arrives which can be used to update the camera
  40303. */
  40304. onXRFrameObservable: Observable<any>;
  40305. /**
  40306. * Fires when the xr session is ended either by the device or manually done
  40307. */
  40308. onXRSessionEnded: Observable<any>;
  40309. /** @hidden */
  40310. _xrSession: XRSession;
  40311. /** @hidden */
  40312. _frameOfReference: XRFrameOfReference;
  40313. /** @hidden */
  40314. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40315. /** @hidden */
  40316. _currentXRFrame: Nullable<XRFrame>;
  40317. private _xrNavigator;
  40318. private _xrDevice;
  40319. private _tmpMatrix;
  40320. /**
  40321. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40322. * @param scene The scene which the session should be created for
  40323. */
  40324. constructor(scene: Scene);
  40325. /**
  40326. * Initializes the manager
  40327. * After initialization enterXR can be called to start an XR session
  40328. * @returns Promise which resolves after it is initialized
  40329. */
  40330. initializeAsync(): Promise<void>;
  40331. /**
  40332. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40333. * @param sessionCreationOptions xr options to create the session with
  40334. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40335. * @returns Promise which resolves after it enters XR
  40336. */
  40337. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40338. /**
  40339. * Stops the xrSession and restores the renderloop
  40340. * @returns Promise which resolves after it exits XR
  40341. */
  40342. exitXRAsync(): Promise<void>;
  40343. /**
  40344. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40345. * @param ray ray to cast into the environment
  40346. * @returns Promise which resolves with a collision point in the environment if it exists
  40347. */
  40348. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40349. /**
  40350. * Checks if a session would be supported for the creation options specified
  40351. * @param options creation options to check if they are supported
  40352. * @returns true if supported
  40353. */
  40354. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40355. /**
  40356. * @hidden
  40357. * Converts the render layer of xrSession to a render target
  40358. * @param session session to create render target for
  40359. * @param scene scene the new render target should be created for
  40360. */
  40361. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40362. /**
  40363. * Disposes of the session manager
  40364. */
  40365. dispose(): void;
  40366. }
  40367. }
  40368. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40369. import { Scene } from "babylonjs/scene";
  40370. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40371. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40372. /**
  40373. * WebXR Camera which holds the views for the xrSession
  40374. * @see https://doc.babylonjs.com/how_to/webxr
  40375. */
  40376. export class WebXRCamera extends FreeCamera {
  40377. private static _TmpMatrix;
  40378. /**
  40379. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40380. * @param name the name of the camera
  40381. * @param scene the scene to add the camera to
  40382. */
  40383. constructor(name: string, scene: Scene);
  40384. private _updateNumberOfRigCameras;
  40385. /** @hidden */
  40386. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40387. /**
  40388. * Updates the cameras position from the current pose information of the XR session
  40389. * @param xrSessionManager the session containing pose information
  40390. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40391. */
  40392. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40393. }
  40394. }
  40395. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40396. import { Nullable } from "babylonjs/types";
  40397. import { Observable } from "babylonjs/Misc/observable";
  40398. import { IDisposable, Scene } from "babylonjs/scene";
  40399. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40401. import { Ray } from "babylonjs/Culling/ray";
  40402. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40403. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40404. /**
  40405. * States of the webXR experience
  40406. */
  40407. export enum WebXRState {
  40408. /**
  40409. * Transitioning to being in XR mode
  40410. */
  40411. ENTERING_XR = 0,
  40412. /**
  40413. * Transitioning to non XR mode
  40414. */
  40415. EXITING_XR = 1,
  40416. /**
  40417. * In XR mode and presenting
  40418. */
  40419. IN_XR = 2,
  40420. /**
  40421. * Not entered XR mode
  40422. */
  40423. NOT_IN_XR = 3
  40424. }
  40425. /**
  40426. * Helper class used to enable XR
  40427. * @see https://doc.babylonjs.com/how_to/webxr
  40428. */
  40429. export class WebXRExperienceHelper implements IDisposable {
  40430. private scene;
  40431. /**
  40432. * 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
  40433. */
  40434. container: AbstractMesh;
  40435. /**
  40436. * Camera used to render xr content
  40437. */
  40438. camera: WebXRCamera;
  40439. /**
  40440. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40441. */
  40442. state: WebXRState;
  40443. private _setState;
  40444. private static _TmpVector;
  40445. /**
  40446. * Fires when the state of the experience helper has changed
  40447. */
  40448. onStateChangedObservable: Observable<WebXRState>;
  40449. /** @hidden */
  40450. _sessionManager: WebXRSessionManager;
  40451. private _nonVRCamera;
  40452. private _originalSceneAutoClear;
  40453. private _supported;
  40454. /**
  40455. * Creates the experience helper
  40456. * @param scene the scene to attach the experience helper to
  40457. * @returns a promise for the experience helper
  40458. */
  40459. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40460. /**
  40461. * Creates a WebXRExperienceHelper
  40462. * @param scene The scene the helper should be created in
  40463. */
  40464. private constructor();
  40465. /**
  40466. * Exits XR mode and returns the scene to its original state
  40467. * @returns promise that resolves after xr mode has exited
  40468. */
  40469. exitXRAsync(): Promise<void>;
  40470. /**
  40471. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40472. * @param sessionCreationOptions options for the XR session
  40473. * @param frameOfReference frame of reference of the XR session
  40474. * @returns promise that resolves after xr mode has entered
  40475. */
  40476. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40477. /**
  40478. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40479. * @param ray ray to cast into the environment
  40480. * @returns Promise which resolves with a collision point in the environment if it exists
  40481. */
  40482. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40483. /**
  40484. * Updates the global position of the camera by moving the camera's container
  40485. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40486. * @param position The desired global position of the camera
  40487. */
  40488. setPositionOfCameraUsingContainer(position: Vector3): void;
  40489. /**
  40490. * Rotates the xr camera by rotating the camera's container around the camera's position
  40491. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40492. * @param rotation the desired quaternion rotation to apply to the camera
  40493. */
  40494. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40495. /**
  40496. * Checks if the creation options are supported by the xr session
  40497. * @param options creation options
  40498. * @returns true if supported
  40499. */
  40500. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40501. /**
  40502. * Disposes of the experience helper
  40503. */
  40504. dispose(): void;
  40505. }
  40506. }
  40507. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40508. import { Nullable } from "babylonjs/types";
  40509. import { Observable } from "babylonjs/Misc/observable";
  40510. import { IDisposable, Scene } from "babylonjs/scene";
  40511. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40512. /**
  40513. * Button which can be used to enter a different mode of XR
  40514. */
  40515. export class WebXREnterExitUIButton {
  40516. /** button element */
  40517. element: HTMLElement;
  40518. /** XR initialization options for the button */
  40519. initializationOptions: XRSessionCreationOptions;
  40520. /**
  40521. * Creates a WebXREnterExitUIButton
  40522. * @param element button element
  40523. * @param initializationOptions XR initialization options for the button
  40524. */
  40525. constructor(
  40526. /** button element */
  40527. element: HTMLElement,
  40528. /** XR initialization options for the button */
  40529. initializationOptions: XRSessionCreationOptions);
  40530. /**
  40531. * Overwritable function which can be used to update the button's visuals when the state changes
  40532. * @param activeButton the current active button in the UI
  40533. */
  40534. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40535. }
  40536. /**
  40537. * Options to create the webXR UI
  40538. */
  40539. export class WebXREnterExitUIOptions {
  40540. /**
  40541. * Context to enter xr with
  40542. */
  40543. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40544. /**
  40545. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40546. */
  40547. customButtons?: Array<WebXREnterExitUIButton>;
  40548. }
  40549. /**
  40550. * UI to allow the user to enter/exit XR mode
  40551. */
  40552. export class WebXREnterExitUI implements IDisposable {
  40553. private scene;
  40554. private _overlay;
  40555. private _buttons;
  40556. private _activeButton;
  40557. /**
  40558. * Fired every time the active button is changed.
  40559. *
  40560. * When xr is entered via a button that launches xr that button will be the callback parameter
  40561. *
  40562. * When exiting xr the callback parameter will be null)
  40563. */
  40564. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40565. /**
  40566. * Creates UI to allow the user to enter/exit XR mode
  40567. * @param scene the scene to add the ui to
  40568. * @param helper the xr experience helper to enter/exit xr with
  40569. * @param options options to configure the UI
  40570. * @returns the created ui
  40571. */
  40572. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40573. private constructor();
  40574. private _updateButtons;
  40575. /**
  40576. * Disposes of the object
  40577. */
  40578. dispose(): void;
  40579. }
  40580. }
  40581. declare module "babylonjs/Cameras/XR/webXRInput" {
  40582. import { IDisposable, Scene } from "babylonjs/scene";
  40583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40584. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40585. /**
  40586. * Represents an XR input
  40587. */
  40588. export class WebXRController {
  40589. /**
  40590. * 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
  40591. */
  40592. grip?: AbstractMesh;
  40593. /**
  40594. * Pointer which can be used to select objects or attach a visible laser to
  40595. */
  40596. pointer: AbstractMesh;
  40597. /**
  40598. * Creates the controller
  40599. * @see https://doc.babylonjs.com/how_to/webxr
  40600. * @param scene the scene which the controller should be associated to
  40601. */
  40602. constructor(scene: Scene);
  40603. /**
  40604. * Disposes of the object
  40605. */
  40606. dispose(): void;
  40607. }
  40608. /**
  40609. * XR input used to track XR inputs such as controllers/rays
  40610. */
  40611. export class WebXRInput implements IDisposable {
  40612. private helper;
  40613. /**
  40614. * XR controllers being tracked
  40615. */
  40616. controllers: Array<WebXRController>;
  40617. private _tmpMatrix;
  40618. private _frameObserver;
  40619. /**
  40620. * Initializes the WebXRInput
  40621. * @param helper experience helper which the input should be created for
  40622. */
  40623. constructor(helper: WebXRExperienceHelper);
  40624. /**
  40625. * Disposes of the object
  40626. */
  40627. dispose(): void;
  40628. }
  40629. }
  40630. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40631. import { Nullable } from "babylonjs/types";
  40632. import { IDisposable } from "babylonjs/scene";
  40633. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40634. /**
  40635. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40636. */
  40637. export class WebXRManagedOutputCanvas implements IDisposable {
  40638. private _canvas;
  40639. /**
  40640. * xrpresent context of the canvas which can be used to display/mirror xr content
  40641. */
  40642. canvasContext: Nullable<WebGLRenderingContext>;
  40643. /**
  40644. * Initializes the canvas to be added/removed upon entering/exiting xr
  40645. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40646. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40647. */
  40648. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40649. /**
  40650. * Disposes of the object
  40651. */
  40652. dispose(): void;
  40653. private _setManagedOutputCanvas;
  40654. private _addCanvas;
  40655. private _removeCanvas;
  40656. }
  40657. }
  40658. declare module "babylonjs/Cameras/XR/index" {
  40659. export * from "babylonjs/Cameras/XR/webXRCamera";
  40660. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40661. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40662. export * from "babylonjs/Cameras/XR/webXRInput";
  40663. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40664. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40665. }
  40666. declare module "babylonjs/Cameras/RigModes/index" {
  40667. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40668. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40669. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40670. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40671. }
  40672. declare module "babylonjs/Cameras/index" {
  40673. export * from "babylonjs/Cameras/Inputs/index";
  40674. export * from "babylonjs/Cameras/cameraInputsManager";
  40675. export * from "babylonjs/Cameras/camera";
  40676. export * from "babylonjs/Cameras/targetCamera";
  40677. export * from "babylonjs/Cameras/freeCamera";
  40678. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40679. export * from "babylonjs/Cameras/touchCamera";
  40680. export * from "babylonjs/Cameras/arcRotateCamera";
  40681. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40682. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40683. export * from "babylonjs/Cameras/flyCamera";
  40684. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40685. export * from "babylonjs/Cameras/followCamera";
  40686. export * from "babylonjs/Cameras/gamepadCamera";
  40687. export * from "babylonjs/Cameras/Stereoscopic/index";
  40688. export * from "babylonjs/Cameras/universalCamera";
  40689. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40690. export * from "babylonjs/Cameras/VR/index";
  40691. export * from "babylonjs/Cameras/XR/index";
  40692. export * from "babylonjs/Cameras/RigModes/index";
  40693. }
  40694. declare module "babylonjs/Collisions/index" {
  40695. export * from "babylonjs/Collisions/collider";
  40696. export * from "babylonjs/Collisions/collisionCoordinator";
  40697. export * from "babylonjs/Collisions/pickingInfo";
  40698. export * from "babylonjs/Collisions/intersectionInfo";
  40699. }
  40700. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40701. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40702. import { Vector3, Plane } from "babylonjs/Maths/math";
  40703. import { Ray } from "babylonjs/Culling/ray";
  40704. /**
  40705. * Contains an array of blocks representing the octree
  40706. */
  40707. export interface IOctreeContainer<T> {
  40708. /**
  40709. * Blocks within the octree
  40710. */
  40711. blocks: Array<OctreeBlock<T>>;
  40712. }
  40713. /**
  40714. * Class used to store a cell in an octree
  40715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40716. */
  40717. export class OctreeBlock<T> {
  40718. /**
  40719. * Gets the content of the current block
  40720. */
  40721. entries: T[];
  40722. /**
  40723. * Gets the list of block children
  40724. */
  40725. blocks: Array<OctreeBlock<T>>;
  40726. private _depth;
  40727. private _maxDepth;
  40728. private _capacity;
  40729. private _minPoint;
  40730. private _maxPoint;
  40731. private _boundingVectors;
  40732. private _creationFunc;
  40733. /**
  40734. * Creates a new block
  40735. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40736. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40737. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40738. * @param depth defines the current depth of this block in the octree
  40739. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40740. * @param creationFunc defines a callback to call when an element is added to the block
  40741. */
  40742. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40743. /**
  40744. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40745. */
  40746. readonly capacity: number;
  40747. /**
  40748. * Gets the minimum vector (in world space) of the block's bounding box
  40749. */
  40750. readonly minPoint: Vector3;
  40751. /**
  40752. * Gets the maximum vector (in world space) of the block's bounding box
  40753. */
  40754. readonly maxPoint: Vector3;
  40755. /**
  40756. * Add a new element to this block
  40757. * @param entry defines the element to add
  40758. */
  40759. addEntry(entry: T): void;
  40760. /**
  40761. * Remove an element from this block
  40762. * @param entry defines the element to remove
  40763. */
  40764. removeEntry(entry: T): void;
  40765. /**
  40766. * Add an array of elements to this block
  40767. * @param entries defines the array of elements to add
  40768. */
  40769. addEntries(entries: T[]): void;
  40770. /**
  40771. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40772. * @param frustumPlanes defines the frustum planes to test
  40773. * @param selection defines the array to store current content if selection is positive
  40774. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40775. */
  40776. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40777. /**
  40778. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40779. * @param sphereCenter defines the bounding sphere center
  40780. * @param sphereRadius defines the bounding sphere radius
  40781. * @param selection defines the array to store current content if selection is positive
  40782. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40783. */
  40784. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40785. /**
  40786. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40787. * @param ray defines the ray to test with
  40788. * @param selection defines the array to store current content if selection is positive
  40789. */
  40790. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40791. /**
  40792. * Subdivide the content into child blocks (this block will then be empty)
  40793. */
  40794. createInnerBlocks(): void;
  40795. /**
  40796. * @hidden
  40797. */
  40798. 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;
  40799. }
  40800. }
  40801. declare module "babylonjs/Culling/Octrees/octree" {
  40802. import { SmartArray } from "babylonjs/Misc/smartArray";
  40803. import { Vector3, Plane } from "babylonjs/Maths/math";
  40804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40806. import { Ray } from "babylonjs/Culling/ray";
  40807. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40808. /**
  40809. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40811. */
  40812. export class Octree<T> {
  40813. /** 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.) */
  40814. maxDepth: number;
  40815. /**
  40816. * Blocks within the octree containing objects
  40817. */
  40818. blocks: Array<OctreeBlock<T>>;
  40819. /**
  40820. * Content stored in the octree
  40821. */
  40822. dynamicContent: T[];
  40823. private _maxBlockCapacity;
  40824. private _selectionContent;
  40825. private _creationFunc;
  40826. /**
  40827. * Creates a octree
  40828. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40829. * @param creationFunc function to be used to instatiate the octree
  40830. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40831. * @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.)
  40832. */
  40833. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40834. /** 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.) */
  40835. maxDepth?: number);
  40836. /**
  40837. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40838. * @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);
  40839. * @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);
  40840. * @param entries meshes to be added to the octree blocks
  40841. */
  40842. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40843. /**
  40844. * Adds a mesh to the octree
  40845. * @param entry Mesh to add to the octree
  40846. */
  40847. addMesh(entry: T): void;
  40848. /**
  40849. * Remove an element from the octree
  40850. * @param entry defines the element to remove
  40851. */
  40852. removeMesh(entry: T): void;
  40853. /**
  40854. * Selects an array of meshes within the frustum
  40855. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40856. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40857. * @returns array of meshes within the frustum
  40858. */
  40859. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40860. /**
  40861. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40862. * @param sphereCenter defines the bounding sphere center
  40863. * @param sphereRadius defines the bounding sphere radius
  40864. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40865. * @returns an array of objects that intersect the sphere
  40866. */
  40867. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40868. /**
  40869. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40870. * @param ray defines the ray to test with
  40871. * @returns array of intersected objects
  40872. */
  40873. intersectsRay(ray: Ray): SmartArray<T>;
  40874. /**
  40875. * Adds a mesh into the octree block if it intersects the block
  40876. */
  40877. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40878. /**
  40879. * Adds a submesh into the octree block if it intersects the block
  40880. */
  40881. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40882. }
  40883. }
  40884. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40885. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40886. import { Scene } from "babylonjs/scene";
  40887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40889. import { Ray } from "babylonjs/Culling/ray";
  40890. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40891. import { Collider } from "babylonjs/Collisions/collider";
  40892. module "babylonjs/scene" {
  40893. interface Scene {
  40894. /**
  40895. * @hidden
  40896. * Backing Filed
  40897. */
  40898. _selectionOctree: Octree<AbstractMesh>;
  40899. /**
  40900. * Gets the octree used to boost mesh selection (picking)
  40901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40902. */
  40903. selectionOctree: Octree<AbstractMesh>;
  40904. /**
  40905. * Creates or updates the octree used to boost selection (picking)
  40906. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40907. * @param maxCapacity defines the maximum capacity per leaf
  40908. * @param maxDepth defines the maximum depth of the octree
  40909. * @returns an octree of AbstractMesh
  40910. */
  40911. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40912. }
  40913. }
  40914. module "babylonjs/Meshes/abstractMesh" {
  40915. interface AbstractMesh {
  40916. /**
  40917. * @hidden
  40918. * Backing Field
  40919. */
  40920. _submeshesOctree: Octree<SubMesh>;
  40921. /**
  40922. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40923. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40924. * @param maxCapacity defines the maximum size of each block (64 by default)
  40925. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40926. * @returns the new octree
  40927. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40929. */
  40930. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40931. }
  40932. }
  40933. /**
  40934. * Defines the octree scene component responsible to manage any octrees
  40935. * in a given scene.
  40936. */
  40937. export class OctreeSceneComponent {
  40938. /**
  40939. * The component name helpfull to identify the component in the list of scene components.
  40940. */
  40941. readonly name: string;
  40942. /**
  40943. * The scene the component belongs to.
  40944. */
  40945. scene: Scene;
  40946. /**
  40947. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40948. */
  40949. readonly checksIsEnabled: boolean;
  40950. /**
  40951. * Creates a new instance of the component for the given scene
  40952. * @param scene Defines the scene to register the component in
  40953. */
  40954. constructor(scene: Scene);
  40955. /**
  40956. * Registers the component in a given scene
  40957. */
  40958. register(): void;
  40959. /**
  40960. * Return the list of active meshes
  40961. * @returns the list of active meshes
  40962. */
  40963. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40964. /**
  40965. * Return the list of active sub meshes
  40966. * @param mesh The mesh to get the candidates sub meshes from
  40967. * @returns the list of active sub meshes
  40968. */
  40969. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40970. private _tempRay;
  40971. /**
  40972. * Return the list of sub meshes intersecting with a given local ray
  40973. * @param mesh defines the mesh to find the submesh for
  40974. * @param localRay defines the ray in local space
  40975. * @returns the list of intersecting sub meshes
  40976. */
  40977. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40978. /**
  40979. * Return the list of sub meshes colliding with a collider
  40980. * @param mesh defines the mesh to find the submesh for
  40981. * @param collider defines the collider to evaluate the collision against
  40982. * @returns the list of colliding sub meshes
  40983. */
  40984. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40985. /**
  40986. * Rebuilds the elements related to this component in case of
  40987. * context lost for instance.
  40988. */
  40989. rebuild(): void;
  40990. /**
  40991. * Disposes the component and the associated ressources.
  40992. */
  40993. dispose(): void;
  40994. }
  40995. }
  40996. declare module "babylonjs/Culling/Octrees/index" {
  40997. export * from "babylonjs/Culling/Octrees/octree";
  40998. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40999. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41000. }
  41001. declare module "babylonjs/Culling/index" {
  41002. export * from "babylonjs/Culling/boundingBox";
  41003. export * from "babylonjs/Culling/boundingInfo";
  41004. export * from "babylonjs/Culling/boundingSphere";
  41005. export * from "babylonjs/Culling/Octrees/index";
  41006. export * from "babylonjs/Culling/ray";
  41007. }
  41008. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41009. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41010. import { Nullable } from "babylonjs/types";
  41011. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41012. import { Scene } from "babylonjs/scene";
  41013. /**
  41014. * Class containing static functions to help procedurally build meshes
  41015. */
  41016. export class LinesBuilder {
  41017. /**
  41018. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41019. * * 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
  41020. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41021. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41022. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41023. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41025. * * 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
  41026. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41029. * @param name defines the name of the new line system
  41030. * @param options defines the options used to create the line system
  41031. * @param scene defines the hosting scene
  41032. * @returns a new line system mesh
  41033. */
  41034. static CreateLineSystem(name: string, options: {
  41035. lines: Vector3[][];
  41036. updatable?: boolean;
  41037. instance?: Nullable<LinesMesh>;
  41038. colors?: Nullable<Color4[][]>;
  41039. useVertexAlpha?: boolean;
  41040. }, scene: Nullable<Scene>): LinesMesh;
  41041. /**
  41042. * Creates a line mesh
  41043. * 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
  41044. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41045. * * The parameter `points` is an array successive Vector3
  41046. * * 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
  41047. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41049. * * When updating an instance, remember that only point positions can change, not the number of points
  41050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41052. * @param name defines the name of the new line system
  41053. * @param options defines the options used to create the line system
  41054. * @param scene defines the hosting scene
  41055. * @returns a new line mesh
  41056. */
  41057. static CreateLines(name: string, options: {
  41058. points: Vector3[];
  41059. updatable?: boolean;
  41060. instance?: Nullable<LinesMesh>;
  41061. colors?: Color4[];
  41062. useVertexAlpha?: boolean;
  41063. }, scene?: Nullable<Scene>): LinesMesh;
  41064. /**
  41065. * Creates a dashed line mesh
  41066. * * 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
  41067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41068. * * The parameter `points` is an array successive Vector3
  41069. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41070. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41071. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41072. * * 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
  41073. * * When updating an instance, remember that only point positions can change, not the number of points
  41074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41075. * @param name defines the name of the mesh
  41076. * @param options defines the options used to create the mesh
  41077. * @param scene defines the hosting scene
  41078. * @returns the dashed line mesh
  41079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41080. */
  41081. static CreateDashedLines(name: string, options: {
  41082. points: Vector3[];
  41083. dashSize?: number;
  41084. gapSize?: number;
  41085. dashNb?: number;
  41086. updatable?: boolean;
  41087. instance?: LinesMesh;
  41088. }, scene?: Nullable<Scene>): LinesMesh;
  41089. }
  41090. }
  41091. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41092. import { IDisposable, Scene } from "babylonjs/scene";
  41093. import { Nullable } from "babylonjs/types";
  41094. import { Observable } from "babylonjs/Misc/observable";
  41095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41096. /**
  41097. * Renders a layer on top of an existing scene
  41098. */
  41099. export class UtilityLayerRenderer implements IDisposable {
  41100. /** the original scene that will be rendered on top of */
  41101. originalScene: Scene;
  41102. private _pointerCaptures;
  41103. private _lastPointerEvents;
  41104. private static _DefaultUtilityLayer;
  41105. private static _DefaultKeepDepthUtilityLayer;
  41106. /**
  41107. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41108. */
  41109. pickUtilitySceneFirst: boolean;
  41110. /**
  41111. * 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)
  41112. */
  41113. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41114. /**
  41115. * 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)
  41116. */
  41117. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41118. /**
  41119. * The scene that is rendered on top of the original scene
  41120. */
  41121. utilityLayerScene: Scene;
  41122. /**
  41123. * If the utility layer should automatically be rendered on top of existing scene
  41124. */
  41125. shouldRender: boolean;
  41126. /**
  41127. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41128. */
  41129. onlyCheckPointerDownEvents: boolean;
  41130. /**
  41131. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41132. */
  41133. processAllEvents: boolean;
  41134. /**
  41135. * Observable raised when the pointer move from the utility layer scene to the main scene
  41136. */
  41137. onPointerOutObservable: Observable<number>;
  41138. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41139. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41140. private _afterRenderObserver;
  41141. private _sceneDisposeObserver;
  41142. private _originalPointerObserver;
  41143. /**
  41144. * Instantiates a UtilityLayerRenderer
  41145. * @param originalScene the original scene that will be rendered on top of
  41146. * @param handleEvents boolean indicating if the utility layer should handle events
  41147. */
  41148. constructor(
  41149. /** the original scene that will be rendered on top of */
  41150. originalScene: Scene, handleEvents?: boolean);
  41151. private _notifyObservers;
  41152. /**
  41153. * Renders the utility layers scene on top of the original scene
  41154. */
  41155. render(): void;
  41156. /**
  41157. * Disposes of the renderer
  41158. */
  41159. dispose(): void;
  41160. private _updateCamera;
  41161. }
  41162. }
  41163. declare module "babylonjs/Gizmos/gizmo" {
  41164. import { Nullable } from "babylonjs/types";
  41165. import { IDisposable } from "babylonjs/scene";
  41166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41167. import { Mesh } from "babylonjs/Meshes/mesh";
  41168. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41169. /**
  41170. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41171. */
  41172. export class Gizmo implements IDisposable {
  41173. /** The utility layer the gizmo will be added to */
  41174. gizmoLayer: UtilityLayerRenderer;
  41175. /**
  41176. * The root mesh of the gizmo
  41177. */
  41178. _rootMesh: Mesh;
  41179. private _attachedMesh;
  41180. /**
  41181. * Ratio for the scale of the gizmo (Default: 1)
  41182. */
  41183. scaleRatio: number;
  41184. private _tmpMatrix;
  41185. /**
  41186. * If a custom mesh has been set (Default: false)
  41187. */
  41188. protected _customMeshSet: boolean;
  41189. /**
  41190. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41191. * * When set, interactions will be enabled
  41192. */
  41193. attachedMesh: Nullable<AbstractMesh>;
  41194. /**
  41195. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41196. * @param mesh The mesh to replace the default mesh of the gizmo
  41197. */
  41198. setCustomMesh(mesh: Mesh): void;
  41199. /**
  41200. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41201. */
  41202. updateGizmoRotationToMatchAttachedMesh: boolean;
  41203. /**
  41204. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41205. */
  41206. updateGizmoPositionToMatchAttachedMesh: boolean;
  41207. /**
  41208. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41209. */
  41210. protected _updateScale: boolean;
  41211. protected _interactionsEnabled: boolean;
  41212. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41213. private _beforeRenderObserver;
  41214. /**
  41215. * Creates a gizmo
  41216. * @param gizmoLayer The utility layer the gizmo will be added to
  41217. */
  41218. constructor(
  41219. /** The utility layer the gizmo will be added to */
  41220. gizmoLayer?: UtilityLayerRenderer);
  41221. private _tempVector;
  41222. /**
  41223. * @hidden
  41224. * Updates the gizmo to match the attached mesh's position/rotation
  41225. */
  41226. protected _update(): void;
  41227. /**
  41228. * Disposes of the gizmo
  41229. */
  41230. dispose(): void;
  41231. }
  41232. }
  41233. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41234. import { Observable } from "babylonjs/Misc/observable";
  41235. import { Nullable } from "babylonjs/types";
  41236. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41237. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41239. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41240. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41241. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41242. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41243. import { Scene } from "babylonjs/scene";
  41244. /**
  41245. * Single axis drag gizmo
  41246. */
  41247. export class AxisDragGizmo extends Gizmo {
  41248. /**
  41249. * Drag behavior responsible for the gizmos dragging interactions
  41250. */
  41251. dragBehavior: PointerDragBehavior;
  41252. private _pointerObserver;
  41253. /**
  41254. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41255. */
  41256. snapDistance: number;
  41257. /**
  41258. * Event that fires each time the gizmo snaps to a new location.
  41259. * * snapDistance is the the change in distance
  41260. */
  41261. onSnapObservable: Observable<{
  41262. snapDistance: number;
  41263. }>;
  41264. /** @hidden */
  41265. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41266. /** @hidden */
  41267. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41268. /**
  41269. * Creates an AxisDragGizmo
  41270. * @param gizmoLayer The utility layer the gizmo will be added to
  41271. * @param dragAxis The axis which the gizmo will be able to drag on
  41272. * @param color The color of the gizmo
  41273. */
  41274. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41275. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41276. /**
  41277. * Disposes of the gizmo
  41278. */
  41279. dispose(): void;
  41280. }
  41281. }
  41282. declare module "babylonjs/Debug/axesViewer" {
  41283. import { Vector3 } from "babylonjs/Maths/math";
  41284. import { Nullable } from "babylonjs/types";
  41285. import { Scene } from "babylonjs/scene";
  41286. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41287. /**
  41288. * The Axes viewer will show 3 axes in a specific point in space
  41289. */
  41290. export class AxesViewer {
  41291. private _xAxis;
  41292. private _yAxis;
  41293. private _zAxis;
  41294. private _scaleLinesFactor;
  41295. private _instanced;
  41296. /**
  41297. * Gets the hosting scene
  41298. */
  41299. scene: Scene;
  41300. /**
  41301. * Gets or sets a number used to scale line length
  41302. */
  41303. scaleLines: number;
  41304. /** Gets the node hierarchy used to render x-axis */
  41305. readonly xAxis: TransformNode;
  41306. /** Gets the node hierarchy used to render y-axis */
  41307. readonly yAxis: TransformNode;
  41308. /** Gets the node hierarchy used to render z-axis */
  41309. readonly zAxis: TransformNode;
  41310. /**
  41311. * Creates a new AxesViewer
  41312. * @param scene defines the hosting scene
  41313. * @param scaleLines defines a number used to scale line length (1 by default)
  41314. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41315. * @param xAxis defines the node hierarchy used to render the x-axis
  41316. * @param yAxis defines the node hierarchy used to render the y-axis
  41317. * @param zAxis defines the node hierarchy used to render the z-axis
  41318. */
  41319. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41320. /**
  41321. * Force the viewer to update
  41322. * @param position defines the position of the viewer
  41323. * @param xaxis defines the x axis of the viewer
  41324. * @param yaxis defines the y axis of the viewer
  41325. * @param zaxis defines the z axis of the viewer
  41326. */
  41327. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41328. /**
  41329. * Creates an instance of this axes viewer.
  41330. * @returns a new axes viewer with instanced meshes
  41331. */
  41332. createInstance(): AxesViewer;
  41333. /** Releases resources */
  41334. dispose(): void;
  41335. private static _SetRenderingGroupId;
  41336. }
  41337. }
  41338. declare module "babylonjs/Debug/boneAxesViewer" {
  41339. import { Nullable } from "babylonjs/types";
  41340. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41341. import { Vector3 } from "babylonjs/Maths/math";
  41342. import { Mesh } from "babylonjs/Meshes/mesh";
  41343. import { Bone } from "babylonjs/Bones/bone";
  41344. import { Scene } from "babylonjs/scene";
  41345. /**
  41346. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41347. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41348. */
  41349. export class BoneAxesViewer extends AxesViewer {
  41350. /**
  41351. * Gets or sets the target mesh where to display the axes viewer
  41352. */
  41353. mesh: Nullable<Mesh>;
  41354. /**
  41355. * Gets or sets the target bone where to display the axes viewer
  41356. */
  41357. bone: Nullable<Bone>;
  41358. /** Gets current position */
  41359. pos: Vector3;
  41360. /** Gets direction of X axis */
  41361. xaxis: Vector3;
  41362. /** Gets direction of Y axis */
  41363. yaxis: Vector3;
  41364. /** Gets direction of Z axis */
  41365. zaxis: Vector3;
  41366. /**
  41367. * Creates a new BoneAxesViewer
  41368. * @param scene defines the hosting scene
  41369. * @param bone defines the target bone
  41370. * @param mesh defines the target mesh
  41371. * @param scaleLines defines a scaling factor for line length (1 by default)
  41372. */
  41373. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41374. /**
  41375. * Force the viewer to update
  41376. */
  41377. update(): void;
  41378. /** Releases resources */
  41379. dispose(): void;
  41380. }
  41381. }
  41382. declare module "babylonjs/Debug/debugLayer" {
  41383. import { Observable } from "babylonjs/Misc/observable";
  41384. import { Scene } from "babylonjs/scene";
  41385. /**
  41386. * Interface used to define scene explorer extensibility option
  41387. */
  41388. export interface IExplorerExtensibilityOption {
  41389. /**
  41390. * Define the option label
  41391. */
  41392. label: string;
  41393. /**
  41394. * Defines the action to execute on click
  41395. */
  41396. action: (entity: any) => void;
  41397. }
  41398. /**
  41399. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41400. */
  41401. export interface IExplorerExtensibilityGroup {
  41402. /**
  41403. * Defines a predicate to test if a given type mut be extended
  41404. */
  41405. predicate: (entity: any) => boolean;
  41406. /**
  41407. * Gets the list of options added to a type
  41408. */
  41409. entries: IExplorerExtensibilityOption[];
  41410. }
  41411. /**
  41412. * Interface used to define the options to use to create the Inspector
  41413. */
  41414. export interface IInspectorOptions {
  41415. /**
  41416. * Display in overlay mode (default: false)
  41417. */
  41418. overlay?: boolean;
  41419. /**
  41420. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41421. */
  41422. globalRoot?: HTMLElement;
  41423. /**
  41424. * Display the Scene explorer
  41425. */
  41426. showExplorer?: boolean;
  41427. /**
  41428. * Display the property inspector
  41429. */
  41430. showInspector?: boolean;
  41431. /**
  41432. * Display in embed mode (both panes on the right)
  41433. */
  41434. embedMode?: boolean;
  41435. /**
  41436. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41437. */
  41438. handleResize?: boolean;
  41439. /**
  41440. * Allow the panes to popup (default: true)
  41441. */
  41442. enablePopup?: boolean;
  41443. /**
  41444. * Allow the panes to be closed by users (default: true)
  41445. */
  41446. enableClose?: boolean;
  41447. /**
  41448. * Optional list of extensibility entries
  41449. */
  41450. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41451. /**
  41452. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41453. */
  41454. inspectorURL?: string;
  41455. }
  41456. module "babylonjs/scene" {
  41457. interface Scene {
  41458. /**
  41459. * @hidden
  41460. * Backing field
  41461. */
  41462. _debugLayer: DebugLayer;
  41463. /**
  41464. * Gets the debug layer (aka Inspector) associated with the scene
  41465. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41466. */
  41467. debugLayer: DebugLayer;
  41468. }
  41469. }
  41470. /**
  41471. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41472. * what is happening in your scene
  41473. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41474. */
  41475. export class DebugLayer {
  41476. /**
  41477. * Define the url to get the inspector script from.
  41478. * By default it uses the babylonjs CDN.
  41479. * @ignoreNaming
  41480. */
  41481. static InspectorURL: string;
  41482. private _scene;
  41483. private BJSINSPECTOR;
  41484. /**
  41485. * Observable triggered when a property is changed through the inspector.
  41486. */
  41487. onPropertyChangedObservable: Observable<{
  41488. object: any;
  41489. property: string;
  41490. value: any;
  41491. initialValue: any;
  41492. }>;
  41493. /**
  41494. * Instantiates a new debug layer.
  41495. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41496. * what is happening in your scene
  41497. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41498. * @param scene Defines the scene to inspect
  41499. */
  41500. constructor(scene: Scene);
  41501. /** Creates the inspector window. */
  41502. private _createInspector;
  41503. /**
  41504. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41505. * @param entity defines the entity to select
  41506. * @param lineContainerTitle defines the specific block to highlight
  41507. */
  41508. select(entity: any, lineContainerTitle?: string): void;
  41509. /** Get the inspector from bundle or global */
  41510. private _getGlobalInspector;
  41511. /**
  41512. * Get if the inspector is visible or not.
  41513. * @returns true if visible otherwise, false
  41514. */
  41515. isVisible(): boolean;
  41516. /**
  41517. * Hide the inspector and close its window.
  41518. */
  41519. hide(): void;
  41520. /**
  41521. * Launch the debugLayer.
  41522. * @param config Define the configuration of the inspector
  41523. * @return a promise fulfilled when the debug layer is visible
  41524. */
  41525. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41526. }
  41527. }
  41528. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41529. import { Nullable } from "babylonjs/types";
  41530. import { Scene } from "babylonjs/scene";
  41531. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41532. import { Mesh } from "babylonjs/Meshes/mesh";
  41533. /**
  41534. * Class containing static functions to help procedurally build meshes
  41535. */
  41536. export class BoxBuilder {
  41537. /**
  41538. * Creates a box mesh
  41539. * * The parameter `size` sets the size (float) of each box side (default 1)
  41540. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41541. * * 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)
  41542. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41544. * * If you create a double-sided mesh, you can choose what parts of 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
  41545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41546. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41547. * @param name defines the name of the mesh
  41548. * @param options defines the options used to create the mesh
  41549. * @param scene defines the hosting scene
  41550. * @returns the box mesh
  41551. */
  41552. static CreateBox(name: string, options: {
  41553. size?: number;
  41554. width?: number;
  41555. height?: number;
  41556. depth?: number;
  41557. faceUV?: Vector4[];
  41558. faceColors?: Color4[];
  41559. sideOrientation?: number;
  41560. frontUVs?: Vector4;
  41561. backUVs?: Vector4;
  41562. updatable?: boolean;
  41563. }, scene?: Nullable<Scene>): Mesh;
  41564. }
  41565. }
  41566. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41567. import { Vector4 } from "babylonjs/Maths/math";
  41568. import { Mesh } from "babylonjs/Meshes/mesh";
  41569. /**
  41570. * Class containing static functions to help procedurally build meshes
  41571. */
  41572. export class SphereBuilder {
  41573. /**
  41574. * Creates a sphere mesh
  41575. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41576. * * 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`)
  41577. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41578. * * 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
  41579. * * 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)
  41580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41581. * * If you create a double-sided mesh, you can choose what parts of 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
  41582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41583. * @param name defines the name of the mesh
  41584. * @param options defines the options used to create the mesh
  41585. * @param scene defines the hosting scene
  41586. * @returns the sphere mesh
  41587. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41588. */
  41589. static CreateSphere(name: string, options: {
  41590. segments?: number;
  41591. diameter?: number;
  41592. diameterX?: number;
  41593. diameterY?: number;
  41594. diameterZ?: number;
  41595. arc?: number;
  41596. slice?: number;
  41597. sideOrientation?: number;
  41598. frontUVs?: Vector4;
  41599. backUVs?: Vector4;
  41600. updatable?: boolean;
  41601. }, scene: any): Mesh;
  41602. }
  41603. }
  41604. declare module "babylonjs/Debug/physicsViewer" {
  41605. import { Nullable } from "babylonjs/types";
  41606. import { Scene } from "babylonjs/scene";
  41607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41608. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41609. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41610. /**
  41611. * Used to show the physics impostor around the specific mesh
  41612. */
  41613. export class PhysicsViewer {
  41614. /** @hidden */
  41615. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41616. /** @hidden */
  41617. protected _meshes: Array<Nullable<AbstractMesh>>;
  41618. /** @hidden */
  41619. protected _scene: Nullable<Scene>;
  41620. /** @hidden */
  41621. protected _numMeshes: number;
  41622. /** @hidden */
  41623. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41624. private _renderFunction;
  41625. private _utilityLayer;
  41626. private _debugBoxMesh;
  41627. private _debugSphereMesh;
  41628. private _debugMaterial;
  41629. /**
  41630. * Creates a new PhysicsViewer
  41631. * @param scene defines the hosting scene
  41632. */
  41633. constructor(scene: Scene);
  41634. /** @hidden */
  41635. protected _updateDebugMeshes(): void;
  41636. /**
  41637. * Renders a specified physic impostor
  41638. * @param impostor defines the impostor to render
  41639. * @returns the new debug mesh used to render the impostor
  41640. */
  41641. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41642. /**
  41643. * Hides a specified physic impostor
  41644. * @param impostor defines the impostor to hide
  41645. */
  41646. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41647. private _getDebugMaterial;
  41648. private _getDebugBoxMesh;
  41649. private _getDebugSphereMesh;
  41650. private _getDebugMesh;
  41651. /** Releases all resources */
  41652. dispose(): void;
  41653. }
  41654. }
  41655. declare module "babylonjs/Debug/rayHelper" {
  41656. import { Nullable } from "babylonjs/types";
  41657. import { Ray } from "babylonjs/Culling/ray";
  41658. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41659. import { Scene } from "babylonjs/scene";
  41660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41661. import "babylonjs/Meshes/Builders/linesBuilder";
  41662. /**
  41663. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41664. * in order to better appreciate the issue one might have.
  41665. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41666. */
  41667. export class RayHelper {
  41668. /**
  41669. * Defines the ray we are currently tryin to visualize.
  41670. */
  41671. ray: Nullable<Ray>;
  41672. private _renderPoints;
  41673. private _renderLine;
  41674. private _renderFunction;
  41675. private _scene;
  41676. private _updateToMeshFunction;
  41677. private _attachedToMesh;
  41678. private _meshSpaceDirection;
  41679. private _meshSpaceOrigin;
  41680. /**
  41681. * Helper function to create a colored helper in a scene in one line.
  41682. * @param ray Defines the ray we are currently tryin to visualize
  41683. * @param scene Defines the scene the ray is used in
  41684. * @param color Defines the color we want to see the ray in
  41685. * @returns The newly created ray helper.
  41686. */
  41687. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41688. /**
  41689. * Instantiate a new ray helper.
  41690. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41691. * in order to better appreciate the issue one might have.
  41692. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41693. * @param ray Defines the ray we are currently tryin to visualize
  41694. */
  41695. constructor(ray: Ray);
  41696. /**
  41697. * Shows the ray we are willing to debug.
  41698. * @param scene Defines the scene the ray needs to be rendered in
  41699. * @param color Defines the color the ray needs to be rendered in
  41700. */
  41701. show(scene: Scene, color?: Color3): void;
  41702. /**
  41703. * Hides the ray we are debugging.
  41704. */
  41705. hide(): void;
  41706. private _render;
  41707. /**
  41708. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41709. * @param mesh Defines the mesh we want the helper attached to
  41710. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41711. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41712. * @param length Defines the length of the ray
  41713. */
  41714. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41715. /**
  41716. * Detach the ray helper from the mesh it has previously been attached to.
  41717. */
  41718. detachFromMesh(): void;
  41719. private _updateToMesh;
  41720. /**
  41721. * Dispose the helper and release its associated resources.
  41722. */
  41723. dispose(): void;
  41724. }
  41725. }
  41726. declare module "babylonjs/Debug/skeletonViewer" {
  41727. import { Color3 } from "babylonjs/Maths/math";
  41728. import { Scene } from "babylonjs/scene";
  41729. import { Nullable } from "babylonjs/types";
  41730. import { Skeleton } from "babylonjs/Bones/skeleton";
  41731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41732. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41733. /**
  41734. * Class used to render a debug view of a given skeleton
  41735. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41736. */
  41737. export class SkeletonViewer {
  41738. /** defines the skeleton to render */
  41739. skeleton: Skeleton;
  41740. /** defines the mesh attached to the skeleton */
  41741. mesh: AbstractMesh;
  41742. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41743. autoUpdateBonesMatrices: boolean;
  41744. /** defines the rendering group id to use with the viewer */
  41745. renderingGroupId: number;
  41746. /** Gets or sets the color used to render the skeleton */
  41747. color: Color3;
  41748. private _scene;
  41749. private _debugLines;
  41750. private _debugMesh;
  41751. private _isEnabled;
  41752. private _renderFunction;
  41753. private _utilityLayer;
  41754. /**
  41755. * Returns the mesh used to render the bones
  41756. */
  41757. readonly debugMesh: Nullable<LinesMesh>;
  41758. /**
  41759. * Creates a new SkeletonViewer
  41760. * @param skeleton defines the skeleton to render
  41761. * @param mesh defines the mesh attached to the skeleton
  41762. * @param scene defines the hosting scene
  41763. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41764. * @param renderingGroupId defines the rendering group id to use with the viewer
  41765. */
  41766. constructor(
  41767. /** defines the skeleton to render */
  41768. skeleton: Skeleton,
  41769. /** defines the mesh attached to the skeleton */
  41770. mesh: AbstractMesh, scene: Scene,
  41771. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41772. autoUpdateBonesMatrices?: boolean,
  41773. /** defines the rendering group id to use with the viewer */
  41774. renderingGroupId?: number);
  41775. /** Gets or sets a boolean indicating if the viewer is enabled */
  41776. isEnabled: boolean;
  41777. private _getBonePosition;
  41778. private _getLinesForBonesWithLength;
  41779. private _getLinesForBonesNoLength;
  41780. /** Update the viewer to sync with current skeleton state */
  41781. update(): void;
  41782. /** Release associated resources */
  41783. dispose(): void;
  41784. }
  41785. }
  41786. declare module "babylonjs/Debug/index" {
  41787. export * from "babylonjs/Debug/axesViewer";
  41788. export * from "babylonjs/Debug/boneAxesViewer";
  41789. export * from "babylonjs/Debug/debugLayer";
  41790. export * from "babylonjs/Debug/physicsViewer";
  41791. export * from "babylonjs/Debug/rayHelper";
  41792. export * from "babylonjs/Debug/skeletonViewer";
  41793. }
  41794. declare module "babylonjs/Engines/nullEngine" {
  41795. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41796. import { Scene } from "babylonjs/scene";
  41797. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41798. import { Engine } from "babylonjs/Engines/engine";
  41799. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41800. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41802. import { Effect } from "babylonjs/Materials/effect";
  41803. /**
  41804. * Options to create the null engine
  41805. */
  41806. export class NullEngineOptions {
  41807. /**
  41808. * Render width (Default: 512)
  41809. */
  41810. renderWidth: number;
  41811. /**
  41812. * Render height (Default: 256)
  41813. */
  41814. renderHeight: number;
  41815. /**
  41816. * Texture size (Default: 512)
  41817. */
  41818. textureSize: number;
  41819. /**
  41820. * If delta time between frames should be constant
  41821. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41822. */
  41823. deterministicLockstep: boolean;
  41824. /**
  41825. * Maximum about of steps between frames (Default: 4)
  41826. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41827. */
  41828. lockstepMaxSteps: number;
  41829. }
  41830. /**
  41831. * The null engine class provides support for headless version of babylon.js.
  41832. * This can be used in server side scenario or for testing purposes
  41833. */
  41834. export class NullEngine extends Engine {
  41835. private _options;
  41836. /**
  41837. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41838. */
  41839. isDeterministicLockStep(): boolean;
  41840. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41841. getLockstepMaxSteps(): number;
  41842. /**
  41843. * Sets hardware scaling, used to save performance if needed
  41844. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41845. */
  41846. getHardwareScalingLevel(): number;
  41847. constructor(options?: NullEngineOptions);
  41848. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41849. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41850. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41851. getRenderWidth(useScreen?: boolean): number;
  41852. getRenderHeight(useScreen?: boolean): number;
  41853. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41854. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41855. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41856. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41857. bindSamplers(effect: Effect): void;
  41858. enableEffect(effect: Effect): void;
  41859. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41860. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41861. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41862. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41863. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41864. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41865. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41866. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41867. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41868. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41869. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41870. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41871. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41872. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41873. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41874. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41875. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41876. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41877. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41878. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41879. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41880. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41881. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41882. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41883. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41884. bindBuffers(vertexBuffers: {
  41885. [key: string]: VertexBuffer;
  41886. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41887. wipeCaches(bruteForce?: boolean): void;
  41888. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41889. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41890. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41891. /** @hidden */
  41892. _createTexture(): WebGLTexture;
  41893. /** @hidden */
  41894. _releaseTexture(texture: InternalTexture): void;
  41895. 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;
  41896. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41897. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41898. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41899. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41900. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41901. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41902. areAllEffectsReady(): boolean;
  41903. /**
  41904. * @hidden
  41905. * Get the current error code of the webGL context
  41906. * @returns the error code
  41907. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41908. */
  41909. getError(): number;
  41910. /** @hidden */
  41911. _getUnpackAlignement(): number;
  41912. /** @hidden */
  41913. _unpackFlipY(value: boolean): void;
  41914. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41915. /**
  41916. * Updates a dynamic vertex buffer.
  41917. * @param vertexBuffer the vertex buffer to update
  41918. * @param data the data used to update the vertex buffer
  41919. * @param byteOffset the byte offset of the data (optional)
  41920. * @param byteLength the byte length of the data (optional)
  41921. */
  41922. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41923. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41924. /** @hidden */
  41925. _bindTexture(channel: number, texture: InternalTexture): void;
  41926. /** @hidden */
  41927. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41928. releaseEffects(): void;
  41929. displayLoadingUI(): void;
  41930. hideLoadingUI(): void;
  41931. /** @hidden */
  41932. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41933. /** @hidden */
  41934. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41935. /** @hidden */
  41936. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41937. /** @hidden */
  41938. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41939. }
  41940. }
  41941. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41942. import { Nullable, int } from "babylonjs/types";
  41943. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41944. /** @hidden */
  41945. export class _OcclusionDataStorage {
  41946. /** @hidden */
  41947. occlusionInternalRetryCounter: number;
  41948. /** @hidden */
  41949. isOcclusionQueryInProgress: boolean;
  41950. /** @hidden */
  41951. isOccluded: boolean;
  41952. /** @hidden */
  41953. occlusionRetryCount: number;
  41954. /** @hidden */
  41955. occlusionType: number;
  41956. /** @hidden */
  41957. occlusionQueryAlgorithmType: number;
  41958. }
  41959. module "babylonjs/Engines/engine" {
  41960. interface Engine {
  41961. /**
  41962. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41963. * @return the new query
  41964. */
  41965. createQuery(): WebGLQuery;
  41966. /**
  41967. * Delete and release a webGL query
  41968. * @param query defines the query to delete
  41969. * @return the current engine
  41970. */
  41971. deleteQuery(query: WebGLQuery): Engine;
  41972. /**
  41973. * Check if a given query has resolved and got its value
  41974. * @param query defines the query to check
  41975. * @returns true if the query got its value
  41976. */
  41977. isQueryResultAvailable(query: WebGLQuery): boolean;
  41978. /**
  41979. * Gets the value of a given query
  41980. * @param query defines the query to check
  41981. * @returns the value of the query
  41982. */
  41983. getQueryResult(query: WebGLQuery): number;
  41984. /**
  41985. * Initiates an occlusion query
  41986. * @param algorithmType defines the algorithm to use
  41987. * @param query defines the query to use
  41988. * @returns the current engine
  41989. * @see http://doc.babylonjs.com/features/occlusionquery
  41990. */
  41991. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41992. /**
  41993. * Ends an occlusion query
  41994. * @see http://doc.babylonjs.com/features/occlusionquery
  41995. * @param algorithmType defines the algorithm to use
  41996. * @returns the current engine
  41997. */
  41998. endOcclusionQuery(algorithmType: number): Engine;
  41999. /**
  42000. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42001. * Please note that only one query can be issued at a time
  42002. * @returns a time token used to track the time span
  42003. */
  42004. startTimeQuery(): Nullable<_TimeToken>;
  42005. /**
  42006. * Ends a time query
  42007. * @param token defines the token used to measure the time span
  42008. * @returns the time spent (in ns)
  42009. */
  42010. endTimeQuery(token: _TimeToken): int;
  42011. /** @hidden */
  42012. _currentNonTimestampToken: Nullable<_TimeToken>;
  42013. /** @hidden */
  42014. _createTimeQuery(): WebGLQuery;
  42015. /** @hidden */
  42016. _deleteTimeQuery(query: WebGLQuery): void;
  42017. /** @hidden */
  42018. _getGlAlgorithmType(algorithmType: number): number;
  42019. /** @hidden */
  42020. _getTimeQueryResult(query: WebGLQuery): any;
  42021. /** @hidden */
  42022. _getTimeQueryAvailability(query: WebGLQuery): any;
  42023. }
  42024. }
  42025. module "babylonjs/Meshes/abstractMesh" {
  42026. interface AbstractMesh {
  42027. /**
  42028. * Backing filed
  42029. * @hidden
  42030. */
  42031. __occlusionDataStorage: _OcclusionDataStorage;
  42032. /**
  42033. * Access property
  42034. * @hidden
  42035. */
  42036. _occlusionDataStorage: _OcclusionDataStorage;
  42037. /**
  42038. * 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.
  42039. * The default value is -1 which means don't break the query and wait till the result
  42040. * @see http://doc.babylonjs.com/features/occlusionquery
  42041. */
  42042. occlusionRetryCount: number;
  42043. /**
  42044. * 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:
  42045. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42046. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42047. * * 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.
  42048. * @see http://doc.babylonjs.com/features/occlusionquery
  42049. */
  42050. occlusionType: number;
  42051. /**
  42052. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42053. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42054. * * 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.
  42055. * @see http://doc.babylonjs.com/features/occlusionquery
  42056. */
  42057. occlusionQueryAlgorithmType: number;
  42058. /**
  42059. * 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
  42060. * @see http://doc.babylonjs.com/features/occlusionquery
  42061. */
  42062. isOccluded: boolean;
  42063. /**
  42064. * Flag to check the progress status of the query
  42065. * @see http://doc.babylonjs.com/features/occlusionquery
  42066. */
  42067. isOcclusionQueryInProgress: boolean;
  42068. }
  42069. }
  42070. }
  42071. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42072. import { Nullable } from "babylonjs/types";
  42073. /** @hidden */
  42074. export var _forceTransformFeedbackToBundle: boolean;
  42075. module "babylonjs/Engines/engine" {
  42076. interface Engine {
  42077. /**
  42078. * Creates a webGL transform feedback object
  42079. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42080. * @returns the webGL transform feedback object
  42081. */
  42082. createTransformFeedback(): WebGLTransformFeedback;
  42083. /**
  42084. * Delete a webGL transform feedback object
  42085. * @param value defines the webGL transform feedback object to delete
  42086. */
  42087. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42088. /**
  42089. * Bind a webGL transform feedback object to the webgl context
  42090. * @param value defines the webGL transform feedback object to bind
  42091. */
  42092. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42093. /**
  42094. * Begins a transform feedback operation
  42095. * @param usePoints defines if points or triangles must be used
  42096. */
  42097. beginTransformFeedback(usePoints: boolean): void;
  42098. /**
  42099. * Ends a transform feedback operation
  42100. */
  42101. endTransformFeedback(): void;
  42102. /**
  42103. * Specify the varyings to use with transform feedback
  42104. * @param program defines the associated webGL program
  42105. * @param value defines the list of strings representing the varying names
  42106. */
  42107. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42108. /**
  42109. * Bind a webGL buffer for a transform feedback operation
  42110. * @param value defines the webGL buffer to bind
  42111. */
  42112. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42113. }
  42114. }
  42115. }
  42116. declare module "babylonjs/Engines/Extensions/index" {
  42117. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42118. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42119. }
  42120. declare module "babylonjs/Engines/index" {
  42121. export * from "babylonjs/Engines/constants";
  42122. export * from "babylonjs/Engines/engine";
  42123. export * from "babylonjs/Engines/engineStore";
  42124. export * from "babylonjs/Engines/nullEngine";
  42125. export * from "babylonjs/Engines/Extensions/index";
  42126. }
  42127. declare module "babylonjs/Events/clipboardEvents" {
  42128. /**
  42129. * Gather the list of clipboard event types as constants.
  42130. */
  42131. export class ClipboardEventTypes {
  42132. /**
  42133. * The clipboard event is fired when a copy command is active (pressed).
  42134. */
  42135. static readonly COPY: number;
  42136. /**
  42137. * The clipboard event is fired when a cut command is active (pressed).
  42138. */
  42139. static readonly CUT: number;
  42140. /**
  42141. * The clipboard event is fired when a paste command is active (pressed).
  42142. */
  42143. static readonly PASTE: number;
  42144. }
  42145. /**
  42146. * This class is used to store clipboard related info for the onClipboardObservable event.
  42147. */
  42148. export class ClipboardInfo {
  42149. /**
  42150. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42151. */
  42152. type: number;
  42153. /**
  42154. * Defines the related dom event
  42155. */
  42156. event: ClipboardEvent;
  42157. /**
  42158. *Creates an instance of ClipboardInfo.
  42159. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42160. * @param event Defines the related dom event
  42161. */
  42162. constructor(
  42163. /**
  42164. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42165. */
  42166. type: number,
  42167. /**
  42168. * Defines the related dom event
  42169. */
  42170. event: ClipboardEvent);
  42171. /**
  42172. * Get the clipboard event's type from the keycode.
  42173. * @param keyCode Defines the keyCode for the current keyboard event.
  42174. * @return {number}
  42175. */
  42176. static GetTypeFromCharacter(keyCode: number): number;
  42177. }
  42178. }
  42179. declare module "babylonjs/Events/index" {
  42180. export * from "babylonjs/Events/keyboardEvents";
  42181. export * from "babylonjs/Events/pointerEvents";
  42182. export * from "babylonjs/Events/clipboardEvents";
  42183. }
  42184. declare module "babylonjs/Loading/sceneLoader" {
  42185. import { Observable } from "babylonjs/Misc/observable";
  42186. import { Nullable } from "babylonjs/types";
  42187. import { Scene } from "babylonjs/scene";
  42188. import { Engine } from "babylonjs/Engines/engine";
  42189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42190. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42191. import { AssetContainer } from "babylonjs/assetContainer";
  42192. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42193. import { Skeleton } from "babylonjs/Bones/skeleton";
  42194. /**
  42195. * Class used to represent data loading progression
  42196. */
  42197. export class SceneLoaderProgressEvent {
  42198. /** defines if data length to load can be evaluated */
  42199. readonly lengthComputable: boolean;
  42200. /** defines the loaded data length */
  42201. readonly loaded: number;
  42202. /** defines the data length to load */
  42203. readonly total: number;
  42204. /**
  42205. * Create a new progress event
  42206. * @param lengthComputable defines if data length to load can be evaluated
  42207. * @param loaded defines the loaded data length
  42208. * @param total defines the data length to load
  42209. */
  42210. constructor(
  42211. /** defines if data length to load can be evaluated */
  42212. lengthComputable: boolean,
  42213. /** defines the loaded data length */
  42214. loaded: number,
  42215. /** defines the data length to load */
  42216. total: number);
  42217. /**
  42218. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42219. * @param event defines the source event
  42220. * @returns a new SceneLoaderProgressEvent
  42221. */
  42222. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42223. }
  42224. /**
  42225. * Interface used by SceneLoader plugins to define supported file extensions
  42226. */
  42227. export interface ISceneLoaderPluginExtensions {
  42228. /**
  42229. * Defines the list of supported extensions
  42230. */
  42231. [extension: string]: {
  42232. isBinary: boolean;
  42233. };
  42234. }
  42235. /**
  42236. * Interface used by SceneLoader plugin factory
  42237. */
  42238. export interface ISceneLoaderPluginFactory {
  42239. /**
  42240. * Defines the name of the factory
  42241. */
  42242. name: string;
  42243. /**
  42244. * Function called to create a new plugin
  42245. * @return the new plugin
  42246. */
  42247. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42248. /**
  42249. * Boolean indicating if the plugin can direct load specific data
  42250. */
  42251. canDirectLoad?: (data: string) => boolean;
  42252. }
  42253. /**
  42254. * Interface used to define a SceneLoader plugin
  42255. */
  42256. export interface ISceneLoaderPlugin {
  42257. /**
  42258. * The friendly name of this plugin.
  42259. */
  42260. name: string;
  42261. /**
  42262. * The file extensions supported by this plugin.
  42263. */
  42264. extensions: string | ISceneLoaderPluginExtensions;
  42265. /**
  42266. * Import meshes into a scene.
  42267. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42268. * @param scene The scene to import into
  42269. * @param data The data to import
  42270. * @param rootUrl The root url for scene and resources
  42271. * @param meshes The meshes array to import into
  42272. * @param particleSystems The particle systems array to import into
  42273. * @param skeletons The skeletons array to import into
  42274. * @param onError The callback when import fails
  42275. * @returns True if successful or false otherwise
  42276. */
  42277. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42278. /**
  42279. * Load into a scene.
  42280. * @param scene The scene to load into
  42281. * @param data The data to import
  42282. * @param rootUrl The root url for scene and resources
  42283. * @param onError The callback when import fails
  42284. * @returns true if successful or false otherwise
  42285. */
  42286. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42287. /**
  42288. * The callback that returns true if the data can be directly loaded.
  42289. */
  42290. canDirectLoad?: (data: string) => boolean;
  42291. /**
  42292. * The callback that allows custom handling of the root url based on the response url.
  42293. */
  42294. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42295. /**
  42296. * Load into an asset container.
  42297. * @param scene The scene to load into
  42298. * @param data The data to import
  42299. * @param rootUrl The root url for scene and resources
  42300. * @param onError The callback when import fails
  42301. * @returns The loaded asset container
  42302. */
  42303. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42304. }
  42305. /**
  42306. * Interface used to define an async SceneLoader plugin
  42307. */
  42308. export interface ISceneLoaderPluginAsync {
  42309. /**
  42310. * The friendly name of this plugin.
  42311. */
  42312. name: string;
  42313. /**
  42314. * The file extensions supported by this plugin.
  42315. */
  42316. extensions: string | ISceneLoaderPluginExtensions;
  42317. /**
  42318. * Import meshes into a scene.
  42319. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42320. * @param scene The scene to import into
  42321. * @param data The data to import
  42322. * @param rootUrl The root url for scene and resources
  42323. * @param onProgress The callback when the load progresses
  42324. * @param fileName Defines the name of the file to load
  42325. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42326. */
  42327. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42328. meshes: AbstractMesh[];
  42329. particleSystems: IParticleSystem[];
  42330. skeletons: Skeleton[];
  42331. animationGroups: AnimationGroup[];
  42332. }>;
  42333. /**
  42334. * Load into a scene.
  42335. * @param scene The scene to load into
  42336. * @param data The data to import
  42337. * @param rootUrl The root url for scene and resources
  42338. * @param onProgress The callback when the load progresses
  42339. * @param fileName Defines the name of the file to load
  42340. * @returns Nothing
  42341. */
  42342. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42343. /**
  42344. * The callback that returns true if the data can be directly loaded.
  42345. */
  42346. canDirectLoad?: (data: string) => boolean;
  42347. /**
  42348. * The callback that allows custom handling of the root url based on the response url.
  42349. */
  42350. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42351. /**
  42352. * Load into an asset container.
  42353. * @param scene The scene to load into
  42354. * @param data The data to import
  42355. * @param rootUrl The root url for scene and resources
  42356. * @param onProgress The callback when the load progresses
  42357. * @param fileName Defines the name of the file to load
  42358. * @returns The loaded asset container
  42359. */
  42360. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42361. }
  42362. /**
  42363. * Class used to load scene from various file formats using registered plugins
  42364. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42365. */
  42366. export class SceneLoader {
  42367. /**
  42368. * No logging while loading
  42369. */
  42370. static readonly NO_LOGGING: number;
  42371. /**
  42372. * Minimal logging while loading
  42373. */
  42374. static readonly MINIMAL_LOGGING: number;
  42375. /**
  42376. * Summary logging while loading
  42377. */
  42378. static readonly SUMMARY_LOGGING: number;
  42379. /**
  42380. * Detailled logging while loading
  42381. */
  42382. static readonly DETAILED_LOGGING: number;
  42383. /**
  42384. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42385. */
  42386. static ForceFullSceneLoadingForIncremental: boolean;
  42387. /**
  42388. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42389. */
  42390. static ShowLoadingScreen: boolean;
  42391. /**
  42392. * Defines the current logging level (while loading the scene)
  42393. * @ignorenaming
  42394. */
  42395. static loggingLevel: number;
  42396. /**
  42397. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42398. */
  42399. static CleanBoneMatrixWeights: boolean;
  42400. /**
  42401. * Event raised when a plugin is used to load a scene
  42402. */
  42403. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42404. private static _registeredPlugins;
  42405. private static _getDefaultPlugin;
  42406. private static _getPluginForExtension;
  42407. private static _getPluginForDirectLoad;
  42408. private static _getPluginForFilename;
  42409. private static _getDirectLoad;
  42410. private static _loadData;
  42411. private static _getFileInfo;
  42412. /**
  42413. * Gets a plugin that can load the given extension
  42414. * @param extension defines the extension to load
  42415. * @returns a plugin or null if none works
  42416. */
  42417. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42418. /**
  42419. * Gets a boolean indicating that the given extension can be loaded
  42420. * @param extension defines the extension to load
  42421. * @returns true if the extension is supported
  42422. */
  42423. static IsPluginForExtensionAvailable(extension: string): boolean;
  42424. /**
  42425. * Adds a new plugin to the list of registered plugins
  42426. * @param plugin defines the plugin to add
  42427. */
  42428. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42429. /**
  42430. * Import meshes into a scene
  42431. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42432. * @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)
  42433. * @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)
  42434. * @param scene the instance of BABYLON.Scene to append to
  42435. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42436. * @param onProgress a callback with a progress event for each file being loaded
  42437. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42438. * @param pluginExtension the extension used to determine the plugin
  42439. * @returns The loaded plugin
  42440. */
  42441. 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>;
  42442. /**
  42443. * Import meshes into a scene
  42444. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42445. * @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)
  42446. * @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)
  42447. * @param scene the instance of BABYLON.Scene to append to
  42448. * @param onProgress a callback with a progress event for each file being loaded
  42449. * @param pluginExtension the extension used to determine the plugin
  42450. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42451. */
  42452. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42453. meshes: AbstractMesh[];
  42454. particleSystems: IParticleSystem[];
  42455. skeletons: Skeleton[];
  42456. animationGroups: AnimationGroup[];
  42457. }>;
  42458. /**
  42459. * Load a scene
  42460. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42461. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42462. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42463. * @param onSuccess a callback with the scene when import succeeds
  42464. * @param onProgress a callback with a progress event for each file being loaded
  42465. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42466. * @param pluginExtension the extension used to determine the plugin
  42467. * @returns The loaded plugin
  42468. */
  42469. 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>;
  42470. /**
  42471. * Load a scene
  42472. * @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)
  42473. * @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)
  42474. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42475. * @param onProgress a callback with a progress event for each file being loaded
  42476. * @param pluginExtension the extension used to determine the plugin
  42477. * @returns The loaded scene
  42478. */
  42479. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42480. /**
  42481. * Append a scene
  42482. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42483. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42484. * @param scene is the instance of BABYLON.Scene to append to
  42485. * @param onSuccess a callback with the scene when import succeeds
  42486. * @param onProgress a callback with a progress event for each file being loaded
  42487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42488. * @param pluginExtension the extension used to determine the plugin
  42489. * @returns The loaded plugin
  42490. */
  42491. 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>;
  42492. /**
  42493. * Append a scene
  42494. * @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)
  42495. * @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)
  42496. * @param scene is the instance of BABYLON.Scene to append to
  42497. * @param onProgress a callback with a progress event for each file being loaded
  42498. * @param pluginExtension the extension used to determine the plugin
  42499. * @returns The given scene
  42500. */
  42501. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42502. /**
  42503. * Load a scene into an asset container
  42504. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  42505. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  42506. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42507. * @param onSuccess a callback with the scene when import succeeds
  42508. * @param onProgress a callback with a progress event for each file being loaded
  42509. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42510. * @param pluginExtension the extension used to determine the plugin
  42511. * @returns The loaded plugin
  42512. */
  42513. 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>;
  42514. /**
  42515. * Load a scene into an asset container
  42516. * @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)
  42517. * @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)
  42518. * @param scene is the instance of Scene to append to
  42519. * @param onProgress a callback with a progress event for each file being loaded
  42520. * @param pluginExtension the extension used to determine the plugin
  42521. * @returns The loaded asset container
  42522. */
  42523. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42524. }
  42525. }
  42526. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42527. import { Scene } from "babylonjs/scene";
  42528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42529. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42530. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42531. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42532. /**
  42533. * Google Daydream controller
  42534. */
  42535. export class DaydreamController extends WebVRController {
  42536. /**
  42537. * Base Url for the controller model.
  42538. */
  42539. static MODEL_BASE_URL: string;
  42540. /**
  42541. * File name for the controller model.
  42542. */
  42543. static MODEL_FILENAME: string;
  42544. /**
  42545. * Gamepad Id prefix used to identify Daydream Controller.
  42546. */
  42547. static readonly GAMEPAD_ID_PREFIX: string;
  42548. /**
  42549. * Creates a new DaydreamController from a gamepad
  42550. * @param vrGamepad the gamepad that the controller should be created from
  42551. */
  42552. constructor(vrGamepad: any);
  42553. /**
  42554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42555. * @param scene scene in which to add meshes
  42556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42557. */
  42558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42559. /**
  42560. * Called once for each button that changed state since the last frame
  42561. * @param buttonIdx Which button index changed
  42562. * @param state New state of the button
  42563. * @param changes Which properties on the state changed since last frame
  42564. */
  42565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42566. }
  42567. }
  42568. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42569. import { Scene } from "babylonjs/scene";
  42570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42571. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42572. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42573. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42574. /**
  42575. * Gear VR Controller
  42576. */
  42577. export class GearVRController extends WebVRController {
  42578. /**
  42579. * Base Url for the controller model.
  42580. */
  42581. static MODEL_BASE_URL: string;
  42582. /**
  42583. * File name for the controller model.
  42584. */
  42585. static MODEL_FILENAME: string;
  42586. /**
  42587. * Gamepad Id prefix used to identify this controller.
  42588. */
  42589. static readonly GAMEPAD_ID_PREFIX: string;
  42590. private readonly _buttonIndexToObservableNameMap;
  42591. /**
  42592. * Creates a new GearVRController from a gamepad
  42593. * @param vrGamepad the gamepad that the controller should be created from
  42594. */
  42595. constructor(vrGamepad: any);
  42596. /**
  42597. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42598. * @param scene scene in which to add meshes
  42599. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42600. */
  42601. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42602. /**
  42603. * Called once for each button that changed state since the last frame
  42604. * @param buttonIdx Which button index changed
  42605. * @param state New state of the button
  42606. * @param changes Which properties on the state changed since last frame
  42607. */
  42608. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42609. }
  42610. }
  42611. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42612. import { Scene } from "babylonjs/scene";
  42613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42614. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42615. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42616. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42617. /**
  42618. * Generic Controller
  42619. */
  42620. export class GenericController extends WebVRController {
  42621. /**
  42622. * Base Url for the controller model.
  42623. */
  42624. static readonly MODEL_BASE_URL: string;
  42625. /**
  42626. * File name for the controller model.
  42627. */
  42628. static readonly MODEL_FILENAME: string;
  42629. /**
  42630. * Creates a new GenericController from a gamepad
  42631. * @param vrGamepad the gamepad that the controller should be created from
  42632. */
  42633. constructor(vrGamepad: any);
  42634. /**
  42635. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42636. * @param scene scene in which to add meshes
  42637. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42638. */
  42639. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42640. /**
  42641. * Called once for each button that changed state since the last frame
  42642. * @param buttonIdx Which button index changed
  42643. * @param state New state of the button
  42644. * @param changes Which properties on the state changed since last frame
  42645. */
  42646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42647. }
  42648. }
  42649. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42650. import { Observable } from "babylonjs/Misc/observable";
  42651. import { Scene } from "babylonjs/scene";
  42652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42653. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42654. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42655. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42656. /**
  42657. * Oculus Touch Controller
  42658. */
  42659. export class OculusTouchController extends WebVRController {
  42660. /**
  42661. * Base Url for the controller model.
  42662. */
  42663. static MODEL_BASE_URL: string;
  42664. /**
  42665. * File name for the left controller model.
  42666. */
  42667. static MODEL_LEFT_FILENAME: string;
  42668. /**
  42669. * File name for the right controller model.
  42670. */
  42671. static MODEL_RIGHT_FILENAME: string;
  42672. /**
  42673. * Fired when the secondary trigger on this controller is modified
  42674. */
  42675. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42676. /**
  42677. * Fired when the thumb rest on this controller is modified
  42678. */
  42679. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42680. /**
  42681. * Creates a new OculusTouchController from a gamepad
  42682. * @param vrGamepad the gamepad that the controller should be created from
  42683. */
  42684. constructor(vrGamepad: any);
  42685. /**
  42686. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42687. * @param scene scene in which to add meshes
  42688. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42689. */
  42690. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42691. /**
  42692. * Fired when the A button on this controller is modified
  42693. */
  42694. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42695. /**
  42696. * Fired when the B button on this controller is modified
  42697. */
  42698. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42699. /**
  42700. * Fired when the X button on this controller is modified
  42701. */
  42702. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42703. /**
  42704. * Fired when the Y button on this controller is modified
  42705. */
  42706. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42707. /**
  42708. * Called once for each button that changed state since the last frame
  42709. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42710. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42711. * 2) secondary trigger (same)
  42712. * 3) A (right) X (left), touch, pressed = value
  42713. * 4) B / Y
  42714. * 5) thumb rest
  42715. * @param buttonIdx Which button index changed
  42716. * @param state New state of the button
  42717. * @param changes Which properties on the state changed since last frame
  42718. */
  42719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42720. }
  42721. }
  42722. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42723. import { Scene } from "babylonjs/scene";
  42724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42725. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42726. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42727. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42728. import { Observable } from "babylonjs/Misc/observable";
  42729. /**
  42730. * Vive Controller
  42731. */
  42732. export class ViveController extends WebVRController {
  42733. /**
  42734. * Base Url for the controller model.
  42735. */
  42736. static MODEL_BASE_URL: string;
  42737. /**
  42738. * File name for the controller model.
  42739. */
  42740. static MODEL_FILENAME: string;
  42741. /**
  42742. * Creates a new ViveController from a gamepad
  42743. * @param vrGamepad the gamepad that the controller should be created from
  42744. */
  42745. constructor(vrGamepad: any);
  42746. /**
  42747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42748. * @param scene scene in which to add meshes
  42749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42750. */
  42751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42752. /**
  42753. * Fired when the left button on this controller is modified
  42754. */
  42755. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42756. /**
  42757. * Fired when the right button on this controller is modified
  42758. */
  42759. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42760. /**
  42761. * Fired when the menu button on this controller is modified
  42762. */
  42763. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42764. /**
  42765. * Called once for each button that changed state since the last frame
  42766. * Vive mapping:
  42767. * 0: touchpad
  42768. * 1: trigger
  42769. * 2: left AND right buttons
  42770. * 3: menu button
  42771. * @param buttonIdx Which button index changed
  42772. * @param state New state of the button
  42773. * @param changes Which properties on the state changed since last frame
  42774. */
  42775. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42776. }
  42777. }
  42778. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42779. import { Observable } from "babylonjs/Misc/observable";
  42780. import { Scene } from "babylonjs/scene";
  42781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42782. import { Ray } from "babylonjs/Culling/ray";
  42783. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42784. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42785. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42786. /**
  42787. * Defines the WindowsMotionController object that the state of the windows motion controller
  42788. */
  42789. export class WindowsMotionController extends WebVRController {
  42790. /**
  42791. * The base url used to load the left and right controller models
  42792. */
  42793. static MODEL_BASE_URL: string;
  42794. /**
  42795. * The name of the left controller model file
  42796. */
  42797. static MODEL_LEFT_FILENAME: string;
  42798. /**
  42799. * The name of the right controller model file
  42800. */
  42801. static MODEL_RIGHT_FILENAME: string;
  42802. /**
  42803. * The controller name prefix for this controller type
  42804. */
  42805. static readonly GAMEPAD_ID_PREFIX: string;
  42806. /**
  42807. * The controller id pattern for this controller type
  42808. */
  42809. private static readonly GAMEPAD_ID_PATTERN;
  42810. private _loadedMeshInfo;
  42811. private readonly _mapping;
  42812. /**
  42813. * Fired when the trackpad on this controller is clicked
  42814. */
  42815. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42816. /**
  42817. * Fired when the trackpad on this controller is modified
  42818. */
  42819. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42820. /**
  42821. * The current x and y values of this controller's trackpad
  42822. */
  42823. trackpad: StickValues;
  42824. /**
  42825. * Creates a new WindowsMotionController from a gamepad
  42826. * @param vrGamepad the gamepad that the controller should be created from
  42827. */
  42828. constructor(vrGamepad: any);
  42829. /**
  42830. * Fired when the trigger on this controller is modified
  42831. */
  42832. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42833. /**
  42834. * Fired when the menu button on this controller is modified
  42835. */
  42836. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42837. /**
  42838. * Fired when the grip button on this controller is modified
  42839. */
  42840. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42841. /**
  42842. * Fired when the thumbstick button on this controller is modified
  42843. */
  42844. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42845. /**
  42846. * Fired when the touchpad button on this controller is modified
  42847. */
  42848. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42849. /**
  42850. * Fired when the touchpad values on this controller are modified
  42851. */
  42852. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42853. private _updateTrackpad;
  42854. /**
  42855. * Called once per frame by the engine.
  42856. */
  42857. update(): void;
  42858. /**
  42859. * Called once for each button that changed state since the last frame
  42860. * @param buttonIdx Which button index changed
  42861. * @param state New state of the button
  42862. * @param changes Which properties on the state changed since last frame
  42863. */
  42864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42865. /**
  42866. * Moves the buttons on the controller mesh based on their current state
  42867. * @param buttonName the name of the button to move
  42868. * @param buttonValue the value of the button which determines the buttons new position
  42869. */
  42870. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42871. /**
  42872. * Moves the axis on the controller mesh based on its current state
  42873. * @param axis the index of the axis
  42874. * @param axisValue the value of the axis which determines the meshes new position
  42875. * @hidden
  42876. */
  42877. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42878. /**
  42879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42880. * @param scene scene in which to add meshes
  42881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42882. */
  42883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42884. /**
  42885. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42886. * can be transformed by button presses and axes values, based on this._mapping.
  42887. *
  42888. * @param scene scene in which the meshes exist
  42889. * @param meshes list of meshes that make up the controller model to process
  42890. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42891. */
  42892. private processModel;
  42893. private createMeshInfo;
  42894. /**
  42895. * Gets the ray of the controller in the direction the controller is pointing
  42896. * @param length the length the resulting ray should be
  42897. * @returns a ray in the direction the controller is pointing
  42898. */
  42899. getForwardRay(length?: number): Ray;
  42900. /**
  42901. * Disposes of the controller
  42902. */
  42903. dispose(): void;
  42904. }
  42905. }
  42906. declare module "babylonjs/Gamepads/Controllers/index" {
  42907. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42908. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42909. export * from "babylonjs/Gamepads/Controllers/genericController";
  42910. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42911. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42912. export * from "babylonjs/Gamepads/Controllers/viveController";
  42913. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42914. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42915. }
  42916. declare module "babylonjs/Gamepads/index" {
  42917. export * from "babylonjs/Gamepads/Controllers/index";
  42918. export * from "babylonjs/Gamepads/gamepad";
  42919. export * from "babylonjs/Gamepads/gamepadManager";
  42920. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42921. export * from "babylonjs/Gamepads/xboxGamepad";
  42922. }
  42923. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42924. import { Observable } from "babylonjs/Misc/observable";
  42925. import { Nullable } from "babylonjs/types";
  42926. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42928. import { Mesh } from "babylonjs/Meshes/mesh";
  42929. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42930. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42931. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42932. /**
  42933. * Single axis scale gizmo
  42934. */
  42935. export class AxisScaleGizmo extends Gizmo {
  42936. private _coloredMaterial;
  42937. /**
  42938. * Drag behavior responsible for the gizmos dragging interactions
  42939. */
  42940. dragBehavior: PointerDragBehavior;
  42941. private _pointerObserver;
  42942. /**
  42943. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42944. */
  42945. snapDistance: number;
  42946. /**
  42947. * Event that fires each time the gizmo snaps to a new location.
  42948. * * snapDistance is the the change in distance
  42949. */
  42950. onSnapObservable: Observable<{
  42951. snapDistance: number;
  42952. }>;
  42953. /**
  42954. * If the scaling operation should be done on all axis (default: false)
  42955. */
  42956. uniformScaling: boolean;
  42957. /**
  42958. * Creates an AxisScaleGizmo
  42959. * @param gizmoLayer The utility layer the gizmo will be added to
  42960. * @param dragAxis The axis which the gizmo will be able to scale on
  42961. * @param color The color of the gizmo
  42962. */
  42963. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42964. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42965. /**
  42966. * Disposes of the gizmo
  42967. */
  42968. dispose(): void;
  42969. /**
  42970. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42971. * @param mesh The mesh to replace the default mesh of the gizmo
  42972. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42973. */
  42974. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42975. }
  42976. }
  42977. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42978. import { Observable } from "babylonjs/Misc/observable";
  42979. import { Nullable } from "babylonjs/types";
  42980. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42982. import { Mesh } from "babylonjs/Meshes/mesh";
  42983. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42984. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42985. import "babylonjs/Meshes/Builders/boxBuilder";
  42986. /**
  42987. * Bounding box gizmo
  42988. */
  42989. export class BoundingBoxGizmo extends Gizmo {
  42990. private _lineBoundingBox;
  42991. private _rotateSpheresParent;
  42992. private _scaleBoxesParent;
  42993. private _boundingDimensions;
  42994. private _renderObserver;
  42995. private _pointerObserver;
  42996. private _scaleDragSpeed;
  42997. private _tmpQuaternion;
  42998. private _tmpVector;
  42999. private _tmpRotationMatrix;
  43000. /**
  43001. * 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)
  43002. */
  43003. ignoreChildren: boolean;
  43004. /**
  43005. * 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)
  43006. */
  43007. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43008. /**
  43009. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43010. */
  43011. rotationSphereSize: number;
  43012. /**
  43013. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43014. */
  43015. scaleBoxSize: number;
  43016. /**
  43017. * 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)
  43018. */
  43019. fixedDragMeshScreenSize: boolean;
  43020. /**
  43021. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43022. */
  43023. fixedDragMeshScreenSizeDistanceFactor: number;
  43024. /**
  43025. * Fired when a rotation sphere or scale box is dragged
  43026. */
  43027. onDragStartObservable: Observable<{}>;
  43028. /**
  43029. * Fired when a scale box is dragged
  43030. */
  43031. onScaleBoxDragObservable: Observable<{}>;
  43032. /**
  43033. * Fired when a scale box drag is ended
  43034. */
  43035. onScaleBoxDragEndObservable: Observable<{}>;
  43036. /**
  43037. * Fired when a rotation sphere is dragged
  43038. */
  43039. onRotationSphereDragObservable: Observable<{}>;
  43040. /**
  43041. * Fired when a rotation sphere drag is ended
  43042. */
  43043. onRotationSphereDragEndObservable: Observable<{}>;
  43044. /**
  43045. * 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)
  43046. */
  43047. scalePivot: Nullable<Vector3>;
  43048. private _anchorMesh;
  43049. private _existingMeshScale;
  43050. private _dragMesh;
  43051. private pointerDragBehavior;
  43052. private coloredMaterial;
  43053. private hoverColoredMaterial;
  43054. /**
  43055. * Sets the color of the bounding box gizmo
  43056. * @param color the color to set
  43057. */
  43058. setColor(color: Color3): void;
  43059. /**
  43060. * Creates an BoundingBoxGizmo
  43061. * @param gizmoLayer The utility layer the gizmo will be added to
  43062. * @param color The color of the gizmo
  43063. */
  43064. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43065. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43066. private _selectNode;
  43067. /**
  43068. * Updates the bounding box information for the Gizmo
  43069. */
  43070. updateBoundingBox(): void;
  43071. private _updateRotationSpheres;
  43072. private _updateScaleBoxes;
  43073. /**
  43074. * Enables rotation on the specified axis and disables rotation on the others
  43075. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43076. */
  43077. setEnabledRotationAxis(axis: string): void;
  43078. /**
  43079. * Enables/disables scaling
  43080. * @param enable if scaling should be enabled
  43081. */
  43082. setEnabledScaling(enable: boolean): void;
  43083. private _updateDummy;
  43084. /**
  43085. * Enables a pointer drag behavior on the bounding box of the gizmo
  43086. */
  43087. enableDragBehavior(): void;
  43088. /**
  43089. * Disposes of the gizmo
  43090. */
  43091. dispose(): void;
  43092. /**
  43093. * 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)
  43094. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43095. * @returns the bounding box mesh with the passed in mesh as a child
  43096. */
  43097. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43098. /**
  43099. * CustomMeshes are not supported by this gizmo
  43100. * @param mesh The mesh to replace the default mesh of the gizmo
  43101. */
  43102. setCustomMesh(mesh: Mesh): void;
  43103. }
  43104. }
  43105. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43106. import { Observable } from "babylonjs/Misc/observable";
  43107. import { Nullable } from "babylonjs/types";
  43108. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43110. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43111. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43112. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43113. import "babylonjs/Meshes/Builders/linesBuilder";
  43114. /**
  43115. * Single plane rotation gizmo
  43116. */
  43117. export class PlaneRotationGizmo extends Gizmo {
  43118. /**
  43119. * Drag behavior responsible for the gizmos dragging interactions
  43120. */
  43121. dragBehavior: PointerDragBehavior;
  43122. private _pointerObserver;
  43123. /**
  43124. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43125. */
  43126. snapDistance: number;
  43127. /**
  43128. * Event that fires each time the gizmo snaps to a new location.
  43129. * * snapDistance is the the change in distance
  43130. */
  43131. onSnapObservable: Observable<{
  43132. snapDistance: number;
  43133. }>;
  43134. /**
  43135. * Creates a PlaneRotationGizmo
  43136. * @param gizmoLayer The utility layer the gizmo will be added to
  43137. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43138. * @param color The color of the gizmo
  43139. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43140. */
  43141. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43142. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43143. /**
  43144. * Disposes of the gizmo
  43145. */
  43146. dispose(): void;
  43147. }
  43148. }
  43149. declare module "babylonjs/Gizmos/rotationGizmo" {
  43150. import { Observable } from "babylonjs/Misc/observable";
  43151. import { Nullable } from "babylonjs/types";
  43152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43153. import { Mesh } from "babylonjs/Meshes/mesh";
  43154. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43155. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43156. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43157. /**
  43158. * Gizmo that enables rotating a mesh along 3 axis
  43159. */
  43160. export class RotationGizmo extends Gizmo {
  43161. /**
  43162. * Internal gizmo used for interactions on the x axis
  43163. */
  43164. xGizmo: PlaneRotationGizmo;
  43165. /**
  43166. * Internal gizmo used for interactions on the y axis
  43167. */
  43168. yGizmo: PlaneRotationGizmo;
  43169. /**
  43170. * Internal gizmo used for interactions on the z axis
  43171. */
  43172. zGizmo: PlaneRotationGizmo;
  43173. /** Fires an event when any of it's sub gizmos are dragged */
  43174. onDragStartObservable: Observable<{}>;
  43175. /** Fires an event when any of it's sub gizmos are released from dragging */
  43176. onDragEndObservable: Observable<{}>;
  43177. attachedMesh: Nullable<AbstractMesh>;
  43178. /**
  43179. * Creates a RotationGizmo
  43180. * @param gizmoLayer The utility layer the gizmo will be added to
  43181. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43182. */
  43183. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43184. updateGizmoRotationToMatchAttachedMesh: boolean;
  43185. /**
  43186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43187. */
  43188. snapDistance: number;
  43189. /**
  43190. * Ratio for the scale of the gizmo (Default: 1)
  43191. */
  43192. scaleRatio: number;
  43193. /**
  43194. * Disposes of the gizmo
  43195. */
  43196. dispose(): void;
  43197. /**
  43198. * CustomMeshes are not supported by this gizmo
  43199. * @param mesh The mesh to replace the default mesh of the gizmo
  43200. */
  43201. setCustomMesh(mesh: Mesh): void;
  43202. }
  43203. }
  43204. declare module "babylonjs/Gizmos/positionGizmo" {
  43205. import { Observable } from "babylonjs/Misc/observable";
  43206. import { Nullable } from "babylonjs/types";
  43207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43208. import { Mesh } from "babylonjs/Meshes/mesh";
  43209. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43210. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43211. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43212. /**
  43213. * Gizmo that enables dragging a mesh along 3 axis
  43214. */
  43215. export class PositionGizmo extends Gizmo {
  43216. /**
  43217. * Internal gizmo used for interactions on the x axis
  43218. */
  43219. xGizmo: AxisDragGizmo;
  43220. /**
  43221. * Internal gizmo used for interactions on the y axis
  43222. */
  43223. yGizmo: AxisDragGizmo;
  43224. /**
  43225. * Internal gizmo used for interactions on the z axis
  43226. */
  43227. zGizmo: AxisDragGizmo;
  43228. /** Fires an event when any of it's sub gizmos are dragged */
  43229. onDragStartObservable: Observable<{}>;
  43230. /** Fires an event when any of it's sub gizmos are released from dragging */
  43231. onDragEndObservable: Observable<{}>;
  43232. attachedMesh: Nullable<AbstractMesh>;
  43233. /**
  43234. * Creates a PositionGizmo
  43235. * @param gizmoLayer The utility layer the gizmo will be added to
  43236. */
  43237. constructor(gizmoLayer?: UtilityLayerRenderer);
  43238. updateGizmoRotationToMatchAttachedMesh: boolean;
  43239. /**
  43240. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43241. */
  43242. snapDistance: number;
  43243. /**
  43244. * Ratio for the scale of the gizmo (Default: 1)
  43245. */
  43246. scaleRatio: number;
  43247. /**
  43248. * Disposes of the gizmo
  43249. */
  43250. dispose(): void;
  43251. /**
  43252. * CustomMeshes are not supported by this gizmo
  43253. * @param mesh The mesh to replace the default mesh of the gizmo
  43254. */
  43255. setCustomMesh(mesh: Mesh): void;
  43256. }
  43257. }
  43258. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43259. import { Scene } from "babylonjs/scene";
  43260. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43261. import { Mesh } from "babylonjs/Meshes/mesh";
  43262. /**
  43263. * Class containing static functions to help procedurally build meshes
  43264. */
  43265. export class PolyhedronBuilder {
  43266. /**
  43267. * Creates a polyhedron mesh
  43268. * * 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
  43269. * * The parameter `size` (positive float, default 1) sets the polygon size
  43270. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43271. * * 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`
  43272. * * 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
  43273. * * 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)`)
  43274. * * 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
  43275. * * 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
  43276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43277. * * If you create a double-sided mesh, you can choose what parts of 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
  43278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43279. * @param name defines the name of the mesh
  43280. * @param options defines the options used to create the mesh
  43281. * @param scene defines the hosting scene
  43282. * @returns the polyhedron mesh
  43283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43284. */
  43285. static CreatePolyhedron(name: string, options: {
  43286. type?: number;
  43287. size?: number;
  43288. sizeX?: number;
  43289. sizeY?: number;
  43290. sizeZ?: number;
  43291. custom?: any;
  43292. faceUV?: Vector4[];
  43293. faceColors?: Color4[];
  43294. flat?: boolean;
  43295. updatable?: boolean;
  43296. sideOrientation?: number;
  43297. frontUVs?: Vector4;
  43298. backUVs?: Vector4;
  43299. }, scene: Scene): Mesh;
  43300. }
  43301. }
  43302. declare module "babylonjs/Gizmos/scaleGizmo" {
  43303. import { Observable } from "babylonjs/Misc/observable";
  43304. import { Nullable } from "babylonjs/types";
  43305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43306. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43307. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43308. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43309. /**
  43310. * Gizmo that enables scaling a mesh along 3 axis
  43311. */
  43312. export class ScaleGizmo extends Gizmo {
  43313. /**
  43314. * Internal gizmo used for interactions on the x axis
  43315. */
  43316. xGizmo: AxisScaleGizmo;
  43317. /**
  43318. * Internal gizmo used for interactions on the y axis
  43319. */
  43320. yGizmo: AxisScaleGizmo;
  43321. /**
  43322. * Internal gizmo used for interactions on the z axis
  43323. */
  43324. zGizmo: AxisScaleGizmo;
  43325. /**
  43326. * Internal gizmo used to scale all axis equally
  43327. */
  43328. uniformScaleGizmo: AxisScaleGizmo;
  43329. /** Fires an event when any of it's sub gizmos are dragged */
  43330. onDragStartObservable: Observable<{}>;
  43331. /** Fires an event when any of it's sub gizmos are released from dragging */
  43332. onDragEndObservable: Observable<{}>;
  43333. attachedMesh: Nullable<AbstractMesh>;
  43334. /**
  43335. * Creates a ScaleGizmo
  43336. * @param gizmoLayer The utility layer the gizmo will be added to
  43337. */
  43338. constructor(gizmoLayer?: UtilityLayerRenderer);
  43339. updateGizmoRotationToMatchAttachedMesh: boolean;
  43340. /**
  43341. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43342. */
  43343. snapDistance: number;
  43344. /**
  43345. * Ratio for the scale of the gizmo (Default: 1)
  43346. */
  43347. scaleRatio: number;
  43348. /**
  43349. * Disposes of the gizmo
  43350. */
  43351. dispose(): void;
  43352. }
  43353. }
  43354. declare module "babylonjs/Gizmos/gizmoManager" {
  43355. import { Observable } from "babylonjs/Misc/observable";
  43356. import { Nullable } from "babylonjs/types";
  43357. import { Scene, IDisposable } from "babylonjs/scene";
  43358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43359. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43360. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43361. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43362. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43363. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43364. /**
  43365. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43366. */
  43367. export class GizmoManager implements IDisposable {
  43368. private scene;
  43369. /**
  43370. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43371. */
  43372. gizmos: {
  43373. positionGizmo: Nullable<PositionGizmo>;
  43374. rotationGizmo: Nullable<RotationGizmo>;
  43375. scaleGizmo: Nullable<ScaleGizmo>;
  43376. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43377. };
  43378. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43379. clearGizmoOnEmptyPointerEvent: boolean;
  43380. /** Fires an event when the manager is attached to a mesh */
  43381. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43382. private _gizmosEnabled;
  43383. private _pointerObserver;
  43384. private _attachedMesh;
  43385. private _boundingBoxColor;
  43386. private _defaultUtilityLayer;
  43387. private _defaultKeepDepthUtilityLayer;
  43388. /**
  43389. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43390. */
  43391. boundingBoxDragBehavior: SixDofDragBehavior;
  43392. /**
  43393. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43394. */
  43395. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43396. /**
  43397. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43398. */
  43399. usePointerToAttachGizmos: boolean;
  43400. /**
  43401. * Instatiates a gizmo manager
  43402. * @param scene the scene to overlay the gizmos on top of
  43403. */
  43404. constructor(scene: Scene);
  43405. /**
  43406. * Attaches a set of gizmos to the specified mesh
  43407. * @param mesh The mesh the gizmo's should be attached to
  43408. */
  43409. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43410. /**
  43411. * If the position gizmo is enabled
  43412. */
  43413. positionGizmoEnabled: boolean;
  43414. /**
  43415. * If the rotation gizmo is enabled
  43416. */
  43417. rotationGizmoEnabled: boolean;
  43418. /**
  43419. * If the scale gizmo is enabled
  43420. */
  43421. scaleGizmoEnabled: boolean;
  43422. /**
  43423. * If the boundingBox gizmo is enabled
  43424. */
  43425. boundingBoxGizmoEnabled: boolean;
  43426. /**
  43427. * Disposes of the gizmo manager
  43428. */
  43429. dispose(): void;
  43430. }
  43431. }
  43432. declare module "babylonjs/Gizmos/lightGizmo" {
  43433. import { Nullable } from "babylonjs/types";
  43434. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43435. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43436. import { Light } from "babylonjs/Lights/light";
  43437. /**
  43438. * Gizmo that enables viewing a light
  43439. */
  43440. export class LightGizmo extends Gizmo {
  43441. private _box;
  43442. /**
  43443. * Creates a LightGizmo
  43444. * @param gizmoLayer The utility layer the gizmo will be added to
  43445. */
  43446. constructor(gizmoLayer?: UtilityLayerRenderer);
  43447. private _light;
  43448. /**
  43449. * The light that the gizmo is attached to
  43450. */
  43451. light: Nullable<Light>;
  43452. /**
  43453. * @hidden
  43454. * Updates the gizmo to match the attached mesh's position/rotation
  43455. */
  43456. protected _update(): void;
  43457. }
  43458. }
  43459. declare module "babylonjs/Gizmos/index" {
  43460. export * from "babylonjs/Gizmos/axisDragGizmo";
  43461. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43462. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43463. export * from "babylonjs/Gizmos/gizmo";
  43464. export * from "babylonjs/Gizmos/gizmoManager";
  43465. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43466. export * from "babylonjs/Gizmos/positionGizmo";
  43467. export * from "babylonjs/Gizmos/rotationGizmo";
  43468. export * from "babylonjs/Gizmos/scaleGizmo";
  43469. export * from "babylonjs/Gizmos/lightGizmo";
  43470. }
  43471. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43472. /** @hidden */
  43473. export var backgroundFragmentDeclaration: {
  43474. name: string;
  43475. shader: string;
  43476. };
  43477. }
  43478. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43479. /** @hidden */
  43480. export var backgroundUboDeclaration: {
  43481. name: string;
  43482. shader: string;
  43483. };
  43484. }
  43485. declare module "babylonjs/Shaders/background.fragment" {
  43486. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43487. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43488. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43489. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43490. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43491. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43492. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43493. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43494. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43495. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43496. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43497. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43498. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43499. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43500. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43501. /** @hidden */
  43502. export var backgroundPixelShader: {
  43503. name: string;
  43504. shader: string;
  43505. };
  43506. }
  43507. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43508. /** @hidden */
  43509. export var backgroundVertexDeclaration: {
  43510. name: string;
  43511. shader: string;
  43512. };
  43513. }
  43514. declare module "babylonjs/Shaders/background.vertex" {
  43515. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43516. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43517. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43518. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43519. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43521. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43522. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43523. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43524. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43525. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43527. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43528. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43529. /** @hidden */
  43530. export var backgroundVertexShader: {
  43531. name: string;
  43532. shader: string;
  43533. };
  43534. }
  43535. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43536. import { Nullable, int, float } from "babylonjs/types";
  43537. import { Scene } from "babylonjs/scene";
  43538. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43541. import { Mesh } from "babylonjs/Meshes/mesh";
  43542. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43543. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43544. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43546. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43547. import "babylonjs/Shaders/background.fragment";
  43548. import "babylonjs/Shaders/background.vertex";
  43549. /**
  43550. * Background material used to create an efficient environement around your scene.
  43551. */
  43552. export class BackgroundMaterial extends PushMaterial {
  43553. /**
  43554. * Standard reflectance value at parallel view angle.
  43555. */
  43556. static StandardReflectance0: number;
  43557. /**
  43558. * Standard reflectance value at grazing angle.
  43559. */
  43560. static StandardReflectance90: number;
  43561. protected _primaryColor: Color3;
  43562. /**
  43563. * Key light Color (multiply against the environement texture)
  43564. */
  43565. primaryColor: Color3;
  43566. protected __perceptualColor: Nullable<Color3>;
  43567. /**
  43568. * Experimental Internal Use Only.
  43569. *
  43570. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43571. * This acts as a helper to set the primary color to a more "human friendly" value.
  43572. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43573. * output color as close as possible from the chosen value.
  43574. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43575. * part of lighting setup.)
  43576. */
  43577. _perceptualColor: Nullable<Color3>;
  43578. protected _primaryColorShadowLevel: float;
  43579. /**
  43580. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43581. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43582. */
  43583. primaryColorShadowLevel: float;
  43584. protected _primaryColorHighlightLevel: float;
  43585. /**
  43586. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43587. * The primary color is used at the level chosen to define what the white area would look.
  43588. */
  43589. primaryColorHighlightLevel: float;
  43590. protected _reflectionTexture: Nullable<BaseTexture>;
  43591. /**
  43592. * Reflection Texture used in the material.
  43593. * Should be author in a specific way for the best result (refer to the documentation).
  43594. */
  43595. reflectionTexture: Nullable<BaseTexture>;
  43596. protected _reflectionBlur: float;
  43597. /**
  43598. * Reflection Texture level of blur.
  43599. *
  43600. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43601. * texture twice.
  43602. */
  43603. reflectionBlur: float;
  43604. protected _diffuseTexture: Nullable<BaseTexture>;
  43605. /**
  43606. * Diffuse Texture used in the material.
  43607. * Should be author in a specific way for the best result (refer to the documentation).
  43608. */
  43609. diffuseTexture: Nullable<BaseTexture>;
  43610. protected _shadowLights: Nullable<IShadowLight[]>;
  43611. /**
  43612. * Specify the list of lights casting shadow on the material.
  43613. * All scene shadow lights will be included if null.
  43614. */
  43615. shadowLights: Nullable<IShadowLight[]>;
  43616. protected _shadowLevel: float;
  43617. /**
  43618. * Helps adjusting the shadow to a softer level if required.
  43619. * 0 means black shadows and 1 means no shadows.
  43620. */
  43621. shadowLevel: float;
  43622. protected _sceneCenter: Vector3;
  43623. /**
  43624. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43625. * It is usually zero but might be interesting to modify according to your setup.
  43626. */
  43627. sceneCenter: Vector3;
  43628. protected _opacityFresnel: boolean;
  43629. /**
  43630. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43631. * This helps ensuring a nice transition when the camera goes under the ground.
  43632. */
  43633. opacityFresnel: boolean;
  43634. protected _reflectionFresnel: boolean;
  43635. /**
  43636. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43637. * This helps adding a mirror texture on the ground.
  43638. */
  43639. reflectionFresnel: boolean;
  43640. protected _reflectionFalloffDistance: number;
  43641. /**
  43642. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43643. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43644. */
  43645. reflectionFalloffDistance: number;
  43646. protected _reflectionAmount: number;
  43647. /**
  43648. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43649. */
  43650. reflectionAmount: number;
  43651. protected _reflectionReflectance0: number;
  43652. /**
  43653. * This specifies the weight of the reflection at grazing angle.
  43654. */
  43655. reflectionReflectance0: number;
  43656. protected _reflectionReflectance90: number;
  43657. /**
  43658. * This specifies the weight of the reflection at a perpendicular point of view.
  43659. */
  43660. reflectionReflectance90: number;
  43661. /**
  43662. * Sets the reflection reflectance fresnel values according to the default standard
  43663. * empirically know to work well :-)
  43664. */
  43665. reflectionStandardFresnelWeight: number;
  43666. protected _useRGBColor: boolean;
  43667. /**
  43668. * Helps to directly use the maps channels instead of their level.
  43669. */
  43670. useRGBColor: boolean;
  43671. protected _enableNoise: boolean;
  43672. /**
  43673. * This helps reducing the banding effect that could occur on the background.
  43674. */
  43675. enableNoise: boolean;
  43676. /**
  43677. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43678. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43679. * Recommended to be keep at 1.0 except for special cases.
  43680. */
  43681. fovMultiplier: number;
  43682. private _fovMultiplier;
  43683. /**
  43684. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43685. */
  43686. useEquirectangularFOV: boolean;
  43687. private _maxSimultaneousLights;
  43688. /**
  43689. * Number of Simultaneous lights allowed on the material.
  43690. */
  43691. maxSimultaneousLights: int;
  43692. /**
  43693. * Default configuration related to image processing available in the Background Material.
  43694. */
  43695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43696. /**
  43697. * Keep track of the image processing observer to allow dispose and replace.
  43698. */
  43699. private _imageProcessingObserver;
  43700. /**
  43701. * Attaches a new image processing configuration to the PBR Material.
  43702. * @param configuration (if null the scene configuration will be use)
  43703. */
  43704. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43705. /**
  43706. * Gets the image processing configuration used either in this material.
  43707. */
  43708. /**
  43709. * Sets the Default image processing configuration used either in the this material.
  43710. *
  43711. * If sets to null, the scene one is in use.
  43712. */
  43713. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43714. /**
  43715. * Gets wether the color curves effect is enabled.
  43716. */
  43717. /**
  43718. * Sets wether the color curves effect is enabled.
  43719. */
  43720. cameraColorCurvesEnabled: boolean;
  43721. /**
  43722. * Gets wether the color grading effect is enabled.
  43723. */
  43724. /**
  43725. * Gets wether the color grading effect is enabled.
  43726. */
  43727. cameraColorGradingEnabled: boolean;
  43728. /**
  43729. * Gets wether tonemapping is enabled or not.
  43730. */
  43731. /**
  43732. * Sets wether tonemapping is enabled or not
  43733. */
  43734. cameraToneMappingEnabled: boolean;
  43735. /**
  43736. * The camera exposure used on this material.
  43737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43738. * This corresponds to a photographic exposure.
  43739. */
  43740. /**
  43741. * The camera exposure used on this material.
  43742. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43743. * This corresponds to a photographic exposure.
  43744. */
  43745. cameraExposure: float;
  43746. /**
  43747. * Gets The camera contrast used on this material.
  43748. */
  43749. /**
  43750. * Sets The camera contrast used on this material.
  43751. */
  43752. cameraContrast: float;
  43753. /**
  43754. * Gets the Color Grading 2D Lookup Texture.
  43755. */
  43756. /**
  43757. * Sets the Color Grading 2D Lookup Texture.
  43758. */
  43759. cameraColorGradingTexture: Nullable<BaseTexture>;
  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. /**
  43767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43769. * 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;
  43770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43771. */
  43772. cameraColorCurves: Nullable<ColorCurves>;
  43773. /**
  43774. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43775. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43776. */
  43777. switchToBGR: boolean;
  43778. private _renderTargets;
  43779. private _reflectionControls;
  43780. private _white;
  43781. private _primaryShadowColor;
  43782. private _primaryHighlightColor;
  43783. /**
  43784. * Instantiates a Background Material in the given scene
  43785. * @param name The friendly name of the material
  43786. * @param scene The scene to add the material to
  43787. */
  43788. constructor(name: string, scene: Scene);
  43789. /**
  43790. * Gets a boolean indicating that current material needs to register RTT
  43791. */
  43792. readonly hasRenderTargetTextures: boolean;
  43793. /**
  43794. * The entire material has been created in order to prevent overdraw.
  43795. * @returns false
  43796. */
  43797. needAlphaTesting(): boolean;
  43798. /**
  43799. * The entire material has been created in order to prevent overdraw.
  43800. * @returns true if blending is enable
  43801. */
  43802. needAlphaBlending(): boolean;
  43803. /**
  43804. * Checks wether the material is ready to be rendered for a given mesh.
  43805. * @param mesh The mesh to render
  43806. * @param subMesh The submesh to check against
  43807. * @param useInstances Specify wether or not the material is used with instances
  43808. * @returns true if all the dependencies are ready (Textures, Effects...)
  43809. */
  43810. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43811. /**
  43812. * Compute the primary color according to the chosen perceptual color.
  43813. */
  43814. private _computePrimaryColorFromPerceptualColor;
  43815. /**
  43816. * Compute the highlights and shadow colors according to their chosen levels.
  43817. */
  43818. private _computePrimaryColors;
  43819. /**
  43820. * Build the uniform buffer used in the material.
  43821. */
  43822. buildUniformLayout(): void;
  43823. /**
  43824. * Unbind the material.
  43825. */
  43826. unbind(): void;
  43827. /**
  43828. * Bind only the world matrix to the material.
  43829. * @param world The world matrix to bind.
  43830. */
  43831. bindOnlyWorldMatrix(world: Matrix): void;
  43832. /**
  43833. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43834. * @param world The world matrix to bind.
  43835. * @param subMesh The submesh to bind for.
  43836. */
  43837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43838. /**
  43839. * Dispose the material.
  43840. * @param forceDisposeEffect Force disposal of the associated effect.
  43841. * @param forceDisposeTextures Force disposal of the associated textures.
  43842. */
  43843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43844. /**
  43845. * Clones the material.
  43846. * @param name The cloned name.
  43847. * @returns The cloned material.
  43848. */
  43849. clone(name: string): BackgroundMaterial;
  43850. /**
  43851. * Serializes the current material to its JSON representation.
  43852. * @returns The JSON representation.
  43853. */
  43854. serialize(): any;
  43855. /**
  43856. * Gets the class name of the material
  43857. * @returns "BackgroundMaterial"
  43858. */
  43859. getClassName(): string;
  43860. /**
  43861. * Parse a JSON input to create back a background material.
  43862. * @param source The JSON data to parse
  43863. * @param scene The scene to create the parsed material in
  43864. * @param rootUrl The root url of the assets the material depends upon
  43865. * @returns the instantiated BackgroundMaterial.
  43866. */
  43867. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43868. }
  43869. }
  43870. declare module "babylonjs/Helpers/environmentHelper" {
  43871. import { Observable } from "babylonjs/Misc/observable";
  43872. import { Nullable } from "babylonjs/types";
  43873. import { Scene } from "babylonjs/scene";
  43874. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43876. import { Mesh } from "babylonjs/Meshes/mesh";
  43877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43878. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43879. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43880. import "babylonjs/Meshes/Builders/planeBuilder";
  43881. import "babylonjs/Meshes/Builders/boxBuilder";
  43882. /**
  43883. * Represents the different options available during the creation of
  43884. * a Environment helper.
  43885. *
  43886. * This can control the default ground, skybox and image processing setup of your scene.
  43887. */
  43888. export interface IEnvironmentHelperOptions {
  43889. /**
  43890. * Specifies wether or not to create a ground.
  43891. * True by default.
  43892. */
  43893. createGround: boolean;
  43894. /**
  43895. * Specifies the ground size.
  43896. * 15 by default.
  43897. */
  43898. groundSize: number;
  43899. /**
  43900. * The texture used on the ground for the main color.
  43901. * Comes from the BabylonJS CDN by default.
  43902. *
  43903. * Remarks: Can be either a texture or a url.
  43904. */
  43905. groundTexture: string | BaseTexture;
  43906. /**
  43907. * The color mixed in the ground texture by default.
  43908. * BabylonJS clearColor by default.
  43909. */
  43910. groundColor: Color3;
  43911. /**
  43912. * Specifies the ground opacity.
  43913. * 1 by default.
  43914. */
  43915. groundOpacity: number;
  43916. /**
  43917. * Enables the ground to receive shadows.
  43918. * True by default.
  43919. */
  43920. enableGroundShadow: boolean;
  43921. /**
  43922. * Helps preventing the shadow to be fully black on the ground.
  43923. * 0.5 by default.
  43924. */
  43925. groundShadowLevel: number;
  43926. /**
  43927. * Creates a mirror texture attach to the ground.
  43928. * false by default.
  43929. */
  43930. enableGroundMirror: boolean;
  43931. /**
  43932. * Specifies the ground mirror size ratio.
  43933. * 0.3 by default as the default kernel is 64.
  43934. */
  43935. groundMirrorSizeRatio: number;
  43936. /**
  43937. * Specifies the ground mirror blur kernel size.
  43938. * 64 by default.
  43939. */
  43940. groundMirrorBlurKernel: number;
  43941. /**
  43942. * Specifies the ground mirror visibility amount.
  43943. * 1 by default
  43944. */
  43945. groundMirrorAmount: number;
  43946. /**
  43947. * Specifies the ground mirror reflectance weight.
  43948. * This uses the standard weight of the background material to setup the fresnel effect
  43949. * of the mirror.
  43950. * 1 by default.
  43951. */
  43952. groundMirrorFresnelWeight: number;
  43953. /**
  43954. * Specifies the ground mirror Falloff distance.
  43955. * This can helps reducing the size of the reflection.
  43956. * 0 by Default.
  43957. */
  43958. groundMirrorFallOffDistance: number;
  43959. /**
  43960. * Specifies the ground mirror texture type.
  43961. * Unsigned Int by Default.
  43962. */
  43963. groundMirrorTextureType: number;
  43964. /**
  43965. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43966. * the shown objects.
  43967. */
  43968. groundYBias: number;
  43969. /**
  43970. * Specifies wether or not to create a skybox.
  43971. * True by default.
  43972. */
  43973. createSkybox: boolean;
  43974. /**
  43975. * Specifies the skybox size.
  43976. * 20 by default.
  43977. */
  43978. skyboxSize: number;
  43979. /**
  43980. * The texture used on the skybox for the main color.
  43981. * Comes from the BabylonJS CDN by default.
  43982. *
  43983. * Remarks: Can be either a texture or a url.
  43984. */
  43985. skyboxTexture: string | BaseTexture;
  43986. /**
  43987. * The color mixed in the skybox texture by default.
  43988. * BabylonJS clearColor by default.
  43989. */
  43990. skyboxColor: Color3;
  43991. /**
  43992. * The background rotation around the Y axis of the scene.
  43993. * This helps aligning the key lights of your scene with the background.
  43994. * 0 by default.
  43995. */
  43996. backgroundYRotation: number;
  43997. /**
  43998. * Compute automatically the size of the elements to best fit with the scene.
  43999. */
  44000. sizeAuto: boolean;
  44001. /**
  44002. * Default position of the rootMesh if autoSize is not true.
  44003. */
  44004. rootPosition: Vector3;
  44005. /**
  44006. * Sets up the image processing in the scene.
  44007. * true by default.
  44008. */
  44009. setupImageProcessing: boolean;
  44010. /**
  44011. * The texture used as your environment texture in the scene.
  44012. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44013. *
  44014. * Remarks: Can be either a texture or a url.
  44015. */
  44016. environmentTexture: string | BaseTexture;
  44017. /**
  44018. * The value of the exposure to apply to the scene.
  44019. * 0.6 by default if setupImageProcessing is true.
  44020. */
  44021. cameraExposure: number;
  44022. /**
  44023. * The value of the contrast to apply to the scene.
  44024. * 1.6 by default if setupImageProcessing is true.
  44025. */
  44026. cameraContrast: number;
  44027. /**
  44028. * Specifies wether or not tonemapping should be enabled in the scene.
  44029. * true by default if setupImageProcessing is true.
  44030. */
  44031. toneMappingEnabled: boolean;
  44032. }
  44033. /**
  44034. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44035. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44036. * It also helps with the default setup of your imageProcessing configuration.
  44037. */
  44038. export class EnvironmentHelper {
  44039. /**
  44040. * Default ground texture URL.
  44041. */
  44042. private static _groundTextureCDNUrl;
  44043. /**
  44044. * Default skybox texture URL.
  44045. */
  44046. private static _skyboxTextureCDNUrl;
  44047. /**
  44048. * Default environment texture URL.
  44049. */
  44050. private static _environmentTextureCDNUrl;
  44051. /**
  44052. * Creates the default options for the helper.
  44053. */
  44054. private static _getDefaultOptions;
  44055. private _rootMesh;
  44056. /**
  44057. * Gets the root mesh created by the helper.
  44058. */
  44059. readonly rootMesh: Mesh;
  44060. private _skybox;
  44061. /**
  44062. * Gets the skybox created by the helper.
  44063. */
  44064. readonly skybox: Nullable<Mesh>;
  44065. private _skyboxTexture;
  44066. /**
  44067. * Gets the skybox texture created by the helper.
  44068. */
  44069. readonly skyboxTexture: Nullable<BaseTexture>;
  44070. private _skyboxMaterial;
  44071. /**
  44072. * Gets the skybox material created by the helper.
  44073. */
  44074. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44075. private _ground;
  44076. /**
  44077. * Gets the ground mesh created by the helper.
  44078. */
  44079. readonly ground: Nullable<Mesh>;
  44080. private _groundTexture;
  44081. /**
  44082. * Gets the ground texture created by the helper.
  44083. */
  44084. readonly groundTexture: Nullable<BaseTexture>;
  44085. private _groundMirror;
  44086. /**
  44087. * Gets the ground mirror created by the helper.
  44088. */
  44089. readonly groundMirror: Nullable<MirrorTexture>;
  44090. /**
  44091. * Gets the ground mirror render list to helps pushing the meshes
  44092. * you wish in the ground reflection.
  44093. */
  44094. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44095. private _groundMaterial;
  44096. /**
  44097. * Gets the ground material created by the helper.
  44098. */
  44099. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44100. /**
  44101. * Stores the creation options.
  44102. */
  44103. private readonly _scene;
  44104. private _options;
  44105. /**
  44106. * This observable will be notified with any error during the creation of the environment,
  44107. * mainly texture creation errors.
  44108. */
  44109. onErrorObservable: Observable<{
  44110. message?: string;
  44111. exception?: any;
  44112. }>;
  44113. /**
  44114. * constructor
  44115. * @param options Defines the options we want to customize the helper
  44116. * @param scene The scene to add the material to
  44117. */
  44118. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44119. /**
  44120. * Updates the background according to the new options
  44121. * @param options
  44122. */
  44123. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44124. /**
  44125. * Sets the primary color of all the available elements.
  44126. * @param color the main color to affect to the ground and the background
  44127. */
  44128. setMainColor(color: Color3): void;
  44129. /**
  44130. * Setup the image processing according to the specified options.
  44131. */
  44132. private _setupImageProcessing;
  44133. /**
  44134. * Setup the environment texture according to the specified options.
  44135. */
  44136. private _setupEnvironmentTexture;
  44137. /**
  44138. * Setup the background according to the specified options.
  44139. */
  44140. private _setupBackground;
  44141. /**
  44142. * Get the scene sizes according to the setup.
  44143. */
  44144. private _getSceneSize;
  44145. /**
  44146. * Setup the ground according to the specified options.
  44147. */
  44148. private _setupGround;
  44149. /**
  44150. * Setup the ground material according to the specified options.
  44151. */
  44152. private _setupGroundMaterial;
  44153. /**
  44154. * Setup the ground diffuse texture according to the specified options.
  44155. */
  44156. private _setupGroundDiffuseTexture;
  44157. /**
  44158. * Setup the ground mirror texture according to the specified options.
  44159. */
  44160. private _setupGroundMirrorTexture;
  44161. /**
  44162. * Setup the ground to receive the mirror texture.
  44163. */
  44164. private _setupMirrorInGroundMaterial;
  44165. /**
  44166. * Setup the skybox according to the specified options.
  44167. */
  44168. private _setupSkybox;
  44169. /**
  44170. * Setup the skybox material according to the specified options.
  44171. */
  44172. private _setupSkyboxMaterial;
  44173. /**
  44174. * Setup the skybox reflection texture according to the specified options.
  44175. */
  44176. private _setupSkyboxReflectionTexture;
  44177. private _errorHandler;
  44178. /**
  44179. * Dispose all the elements created by the Helper.
  44180. */
  44181. dispose(): void;
  44182. }
  44183. }
  44184. declare module "babylonjs/Helpers/photoDome" {
  44185. import { Observable } from "babylonjs/Misc/observable";
  44186. import { Nullable } from "babylonjs/types";
  44187. import { Scene } from "babylonjs/scene";
  44188. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44189. import { Mesh } from "babylonjs/Meshes/mesh";
  44190. import { Texture } from "babylonjs/Materials/Textures/texture";
  44191. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44192. import "babylonjs/Meshes/Builders/sphereBuilder";
  44193. /**
  44194. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44195. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44196. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44197. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44198. */
  44199. export class PhotoDome extends TransformNode {
  44200. private _useDirectMapping;
  44201. /**
  44202. * The texture being displayed on the sphere
  44203. */
  44204. protected _photoTexture: Texture;
  44205. /**
  44206. * Gets or sets the texture being displayed on the sphere
  44207. */
  44208. photoTexture: Texture;
  44209. /**
  44210. * Observable raised when an error occured while loading the 360 image
  44211. */
  44212. onLoadErrorObservable: Observable<string>;
  44213. /**
  44214. * The skybox material
  44215. */
  44216. protected _material: BackgroundMaterial;
  44217. /**
  44218. * The surface used for the skybox
  44219. */
  44220. protected _mesh: Mesh;
  44221. /**
  44222. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44223. * Also see the options.resolution property.
  44224. */
  44225. fovMultiplier: number;
  44226. /**
  44227. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44228. * @param name Element's name, child elements will append suffixes for their own names.
  44229. * @param urlsOfPhoto defines the url of the photo to display
  44230. * @param options defines an object containing optional or exposed sub element properties
  44231. * @param onError defines a callback called when an error occured while loading the texture
  44232. */
  44233. constructor(name: string, urlOfPhoto: string, options: {
  44234. resolution?: number;
  44235. size?: number;
  44236. useDirectMapping?: boolean;
  44237. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44238. /**
  44239. * Releases resources associated with this node.
  44240. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44241. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44242. */
  44243. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44244. }
  44245. }
  44246. declare module "babylonjs/Misc/textureTools" {
  44247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44248. import { Texture } from "babylonjs/Materials/Textures/texture";
  44249. import { Scene } from "babylonjs/scene";
  44250. /**
  44251. * Class used to host texture specific utilities
  44252. */
  44253. export class TextureTools {
  44254. /**
  44255. * Uses the GPU to create a copy texture rescaled at a given size
  44256. * @param texture Texture to copy from
  44257. * @param width defines the desired width
  44258. * @param height defines the desired height
  44259. * @param useBilinearMode defines if bilinear mode has to be used
  44260. * @return the generated texture
  44261. */
  44262. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44263. /**
  44264. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44265. * @param scene defines the hosting scene
  44266. * @returns the environment BRDF texture
  44267. */
  44268. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44269. private static _environmentBRDFBase64Texture;
  44270. }
  44271. }
  44272. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44273. import { Nullable } from "babylonjs/types";
  44274. import { IAnimatable } from "babylonjs/Misc/tools";
  44275. import { Color3 } from "babylonjs/Maths/math";
  44276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44277. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44278. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44279. import { Engine } from "babylonjs/Engines/engine";
  44280. import { Scene } from "babylonjs/scene";
  44281. /**
  44282. * @hidden
  44283. */
  44284. export interface IMaterialClearCoatDefines {
  44285. CLEARCOAT: boolean;
  44286. CLEARCOAT_DEFAULTIOR: boolean;
  44287. CLEARCOAT_TEXTURE: boolean;
  44288. CLEARCOAT_TEXTUREDIRECTUV: number;
  44289. CLEARCOAT_BUMP: boolean;
  44290. CLEARCOAT_BUMPDIRECTUV: number;
  44291. CLEARCOAT_TINT: boolean;
  44292. CLEARCOAT_TINT_TEXTURE: boolean;
  44293. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44294. /** @hidden */
  44295. _areTexturesDirty: boolean;
  44296. }
  44297. /**
  44298. * Define the code related to the clear coat parameters of the pbr material.
  44299. */
  44300. export class PBRClearCoatConfiguration {
  44301. /**
  44302. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44303. * The default fits with a polyurethane material.
  44304. */
  44305. private static readonly _DefaultIndiceOfRefraction;
  44306. private _isEnabled;
  44307. /**
  44308. * Defines if the clear coat is enabled in the material.
  44309. */
  44310. isEnabled: boolean;
  44311. /**
  44312. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44313. */
  44314. intensity: number;
  44315. /**
  44316. * Defines the clear coat layer roughness.
  44317. */
  44318. roughness: number;
  44319. private _indiceOfRefraction;
  44320. /**
  44321. * Defines the indice of refraction of the clear coat.
  44322. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44323. * The default fits with a polyurethane material.
  44324. * Changing the default value is more performance intensive.
  44325. */
  44326. indiceOfRefraction: number;
  44327. private _texture;
  44328. /**
  44329. * Stores the clear coat values in a texture.
  44330. */
  44331. texture: Nullable<BaseTexture>;
  44332. private _bumpTexture;
  44333. /**
  44334. * Define the clear coat specific bump texture.
  44335. */
  44336. bumpTexture: Nullable<BaseTexture>;
  44337. private _isTintEnabled;
  44338. /**
  44339. * Defines if the clear coat tint is enabled in the material.
  44340. */
  44341. isTintEnabled: boolean;
  44342. /**
  44343. * Defines if the clear coat tint is enabled in the material.
  44344. * This is only use if tint is enabled
  44345. */
  44346. tintColor: Color3;
  44347. /**
  44348. * Defines if the distance at which the tint color should be found in the
  44349. * clear coat media.
  44350. * This is only use if tint is enabled
  44351. */
  44352. tintColorAtDistance: number;
  44353. /**
  44354. * Defines the clear coat layer thickness.
  44355. * This is only use if tint is enabled
  44356. */
  44357. tintThickness: number;
  44358. private _tintTexture;
  44359. /**
  44360. * Stores the clear tint values in a texture.
  44361. * rgb is tint
  44362. * a is a thickness factor
  44363. */
  44364. tintTexture: Nullable<BaseTexture>;
  44365. /** @hidden */
  44366. private _internalMarkAllSubMeshesAsTexturesDirty;
  44367. /** @hidden */
  44368. _markAllSubMeshesAsTexturesDirty(): void;
  44369. /**
  44370. * Instantiate a new istance of clear coat configuration.
  44371. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44372. */
  44373. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44374. /**
  44375. * Specifies that the submesh is ready to be used.
  44376. * @param defines the list of "defines" to update.
  44377. * @param scene defines the scene the material belongs to.
  44378. * @param engine defines the engine the material belongs to.
  44379. * @param disableBumpMap defines wether the material disables bump or not.
  44380. * @returns - boolean indicating that the submesh is ready or not.
  44381. */
  44382. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44383. /**
  44384. * Checks to see if a texture is used in the material.
  44385. * @param defines the list of "defines" to update.
  44386. * @param scene defines the scene to the material belongs to.
  44387. */
  44388. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44389. /**
  44390. * Binds the material data.
  44391. * @param uniformBuffer defines the Uniform buffer to fill in.
  44392. * @param scene defines the scene the material belongs to.
  44393. * @param engine defines the engine the material belongs to.
  44394. * @param disableBumpMap defines wether the material disables bump or not.
  44395. * @param isFrozen defines wether the material is frozen or not.
  44396. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44397. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44398. */
  44399. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44400. /**
  44401. * Checks to see if a texture is used in the material.
  44402. * @param texture - Base texture to use.
  44403. * @returns - Boolean specifying if a texture is used in the material.
  44404. */
  44405. hasTexture(texture: BaseTexture): boolean;
  44406. /**
  44407. * Returns an array of the actively used textures.
  44408. * @param activeTextures Array of BaseTextures
  44409. */
  44410. getActiveTextures(activeTextures: BaseTexture[]): void;
  44411. /**
  44412. * Returns the animatable textures.
  44413. * @param animatables Array of animatable textures.
  44414. */
  44415. getAnimatables(animatables: IAnimatable[]): void;
  44416. /**
  44417. * Disposes the resources of the material.
  44418. * @param forceDisposeTextures - Forces the disposal of all textures.
  44419. */
  44420. dispose(forceDisposeTextures?: boolean): void;
  44421. /**
  44422. * Get the current class name of the texture useful for serialization or dynamic coding.
  44423. * @returns "PBRClearCoatConfiguration"
  44424. */
  44425. getClassName(): string;
  44426. /**
  44427. * Makes a duplicate of the current configuration into another one.
  44428. * @param clearCoatConfiguration define the config where to copy the info
  44429. */
  44430. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44431. /**
  44432. * Serializes this clear coat configuration.
  44433. * @returns - An object with the serialized config.
  44434. */
  44435. serialize(): any;
  44436. /**
  44437. * Parses a Clear Coat Configuration from a serialized object.
  44438. * @param source - Serialized object.
  44439. */
  44440. parse(source: any): void;
  44441. /**
  44442. * Add fallbacks to the effect fallbacks list.
  44443. * @param defines defines the Base texture to use.
  44444. * @param fallbacks defines the current fallback list.
  44445. * @param currentRank defines the current fallback rank.
  44446. * @returns the new fallback rank.
  44447. */
  44448. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44449. /**
  44450. * Add the required uniforms to the current list.
  44451. * @param uniforms defines the current uniform list.
  44452. */
  44453. static AddUniforms(uniforms: string[]): void;
  44454. /**
  44455. * Add the required samplers to the current list.
  44456. * @param samplers defines the current sampler list.
  44457. */
  44458. static AddSamplers(samplers: string[]): void;
  44459. /**
  44460. * Add the required uniforms to the current buffer.
  44461. * @param uniformBuffer defines the current uniform buffer.
  44462. */
  44463. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44464. }
  44465. }
  44466. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44467. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44468. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44470. /**
  44471. * @hidden
  44472. */
  44473. export interface IMaterialAnisotropicDefines {
  44474. ANISOTROPIC: boolean;
  44475. MAINUV1: boolean;
  44476. _areMiscDirty: boolean;
  44477. _needUVs: boolean;
  44478. }
  44479. /**
  44480. * Define the code related to the anisotropic parameters of the pbr material.
  44481. */
  44482. export class PBRAnisotropicConfiguration {
  44483. private _isEnabled;
  44484. /**
  44485. * Defines if the anisotropy is enabled in the material.
  44486. */
  44487. isEnabled: boolean;
  44488. /**
  44489. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44490. */
  44491. intensity: number;
  44492. /**
  44493. * Defines if the effect is along the tangents or bitangents.
  44494. * By default, the effect is "strectching" the highlights along the tangents.
  44495. */
  44496. followTangents: boolean;
  44497. /** @hidden */
  44498. private _internalMarkAllSubMeshesAsMiscDirty;
  44499. /** @hidden */
  44500. _markAllSubMeshesAsMiscDirty(): void;
  44501. /**
  44502. * Instantiate a new istance of clear coat configuration.
  44503. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44504. */
  44505. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44506. /**
  44507. * Checks to see if a texture is used in the material.
  44508. * @param defines the list of "defines" to update.
  44509. * @param mesh the mesh we are preparing the defines for.
  44510. */
  44511. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44512. /**
  44513. * Binds the material data.
  44514. * @param uniformBuffer defines the Uniform buffer to fill in.
  44515. * @param isFrozen defines wether the material is frozen or not.
  44516. */
  44517. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44518. /**
  44519. * Get the current class name of the texture useful for serialization or dynamic coding.
  44520. * @returns "PBRAnisotropicConfiguration"
  44521. */
  44522. getClassName(): string;
  44523. /**
  44524. * Makes a duplicate of the current configuration into another one.
  44525. * @param anisotropicConfiguration define the config where to copy the info
  44526. */
  44527. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44528. /**
  44529. * Serializes this clear coat configuration.
  44530. * @returns - An object with the serialized config.
  44531. */
  44532. serialize(): any;
  44533. /**
  44534. * Parses a Clear Coat Configuration from a serialized object.
  44535. * @param source - Serialized object.
  44536. */
  44537. parse(source: any): void;
  44538. /**
  44539. * Add fallbacks to the effect fallbacks list.
  44540. * @param defines defines the Base texture to use.
  44541. * @param fallbacks defines the current fallback list.
  44542. * @param currentRank defines the current fallback rank.
  44543. * @returns the new fallback rank.
  44544. */
  44545. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44546. /**
  44547. * Add the required uniforms to the current list.
  44548. * @param uniforms defines the current uniform list.
  44549. */
  44550. static AddUniforms(uniforms: string[]): void;
  44551. /**
  44552. * Add the required uniforms to the current buffer.
  44553. * @param uniformBuffer defines the current uniform buffer.
  44554. */
  44555. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44556. }
  44557. }
  44558. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44559. /**
  44560. * @hidden
  44561. */
  44562. export interface IMaterialBRDFDefines {
  44563. BRDF_V_HEIGHT_CORRELATED: boolean;
  44564. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44565. /** @hidden */
  44566. _areMiscDirty: boolean;
  44567. }
  44568. /**
  44569. * Define the code related to the BRDF parameters of the pbr material.
  44570. */
  44571. export class PBRBRDFConfiguration {
  44572. private _useEnergyConservation;
  44573. /**
  44574. * Defines if the material uses energy conservation.
  44575. */
  44576. useEnergyConservation: boolean;
  44577. private _useSmithVisibilityHeightCorrelated;
  44578. /**
  44579. * LEGACY Mode set to false
  44580. * Defines if the material uses height smith correlated visibility term.
  44581. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44582. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44583. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44584. * Not relying on height correlated will also disable energy conservation.
  44585. */
  44586. useSmithVisibilityHeightCorrelated: boolean;
  44587. /** @hidden */
  44588. private _internalMarkAllSubMeshesAsMiscDirty;
  44589. /** @hidden */
  44590. _markAllSubMeshesAsMiscDirty(): void;
  44591. /**
  44592. * Instantiate a new istance of clear coat configuration.
  44593. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44594. */
  44595. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44596. /**
  44597. * Checks to see if a texture is used in the material.
  44598. * @param defines the list of "defines" to update.
  44599. */
  44600. prepareDefines(defines: IMaterialBRDFDefines): void;
  44601. /**
  44602. * Get the current class name of the texture useful for serialization or dynamic coding.
  44603. * @returns "PBRClearCoatConfiguration"
  44604. */
  44605. getClassName(): string;
  44606. /**
  44607. * Makes a duplicate of the current configuration into another one.
  44608. * @param brdfConfiguration define the config where to copy the info
  44609. */
  44610. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44611. /**
  44612. * Serializes this BRDF configuration.
  44613. * @returns - An object with the serialized config.
  44614. */
  44615. serialize(): any;
  44616. /**
  44617. * Parses a BRDF Configuration from a serialized object.
  44618. * @param source - Serialized object.
  44619. */
  44620. parse(source: any): void;
  44621. }
  44622. }
  44623. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44624. /** @hidden */
  44625. export var pbrFragmentDeclaration: {
  44626. name: string;
  44627. shader: string;
  44628. };
  44629. }
  44630. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44631. /** @hidden */
  44632. export var pbrUboDeclaration: {
  44633. name: string;
  44634. shader: string;
  44635. };
  44636. }
  44637. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44638. /** @hidden */
  44639. export var pbrFunctions: {
  44640. name: string;
  44641. shader: string;
  44642. };
  44643. }
  44644. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44645. /** @hidden */
  44646. export var harmonicsFunctions: {
  44647. name: string;
  44648. shader: string;
  44649. };
  44650. }
  44651. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44652. /** @hidden */
  44653. export var pbrPreLightingFunctions: {
  44654. name: string;
  44655. shader: string;
  44656. };
  44657. }
  44658. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44659. /** @hidden */
  44660. export var pbrFalloffLightingFunctions: {
  44661. name: string;
  44662. shader: string;
  44663. };
  44664. }
  44665. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44666. /** @hidden */
  44667. export var pbrLightingFunctions: {
  44668. name: string;
  44669. shader: string;
  44670. };
  44671. }
  44672. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44673. /** @hidden */
  44674. export var pbrDebug: {
  44675. name: string;
  44676. shader: string;
  44677. };
  44678. }
  44679. declare module "babylonjs/Shaders/pbr.fragment" {
  44680. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44681. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44682. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44683. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44684. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44685. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44686. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44687. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44688. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44689. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44690. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44691. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44692. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44693. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44694. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44695. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44696. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44697. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44698. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44699. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44700. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44701. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44702. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44703. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44704. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44705. /** @hidden */
  44706. export var pbrPixelShader: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44712. /** @hidden */
  44713. export var pbrVertexDeclaration: {
  44714. name: string;
  44715. shader: string;
  44716. };
  44717. }
  44718. declare module "babylonjs/Shaders/pbr.vertex" {
  44719. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44720. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44721. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44722. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44723. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44724. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44725. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44726. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44727. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44728. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44729. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44730. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44731. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44732. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44733. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44734. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44735. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44736. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44737. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44738. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44739. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44740. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44741. /** @hidden */
  44742. export var pbrVertexShader: {
  44743. name: string;
  44744. shader: string;
  44745. };
  44746. }
  44747. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44748. import { IAnimatable } from "babylonjs/Misc/tools";
  44749. import { Nullable } from "babylonjs/types";
  44750. import { Scene } from "babylonjs/scene";
  44751. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44754. import { Mesh } from "babylonjs/Meshes/mesh";
  44755. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44756. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44757. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44758. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44759. import { Material } from "babylonjs/Materials/material";
  44760. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44762. import "babylonjs/Shaders/pbr.fragment";
  44763. import "babylonjs/Shaders/pbr.vertex";
  44764. /**
  44765. * The Physically based material base class of BJS.
  44766. *
  44767. * This offers the main features of a standard PBR material.
  44768. * For more information, please refer to the documentation :
  44769. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44770. */
  44771. export abstract class PBRBaseMaterial extends PushMaterial {
  44772. /**
  44773. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44774. */
  44775. static readonly PBRMATERIAL_OPAQUE: number;
  44776. /**
  44777. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44778. */
  44779. static readonly PBRMATERIAL_ALPHATEST: number;
  44780. /**
  44781. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44782. */
  44783. static readonly PBRMATERIAL_ALPHABLEND: number;
  44784. /**
  44785. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44786. * They are also discarded below the alpha cutoff threshold to improve performances.
  44787. */
  44788. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44789. /**
  44790. * Defines the default value of how much AO map is occluding the analytical lights
  44791. * (point spot...).
  44792. */
  44793. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44794. /**
  44795. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44796. */
  44797. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44798. /**
  44799. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44800. * to enhance interoperability with other engines.
  44801. */
  44802. static readonly LIGHTFALLOFF_GLTF: number;
  44803. /**
  44804. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44805. * to enhance interoperability with other materials.
  44806. */
  44807. static readonly LIGHTFALLOFF_STANDARD: number;
  44808. /**
  44809. * Intensity of the direct lights e.g. the four lights available in your scene.
  44810. * This impacts both the direct diffuse and specular highlights.
  44811. */
  44812. protected _directIntensity: number;
  44813. /**
  44814. * Intensity of the emissive part of the material.
  44815. * This helps controlling the emissive effect without modifying the emissive color.
  44816. */
  44817. protected _emissiveIntensity: number;
  44818. /**
  44819. * Intensity of the environment e.g. how much the environment will light the object
  44820. * either through harmonics for rough material or through the refelction for shiny ones.
  44821. */
  44822. protected _environmentIntensity: number;
  44823. /**
  44824. * This is a special control allowing the reduction of the specular highlights coming from the
  44825. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44826. */
  44827. protected _specularIntensity: number;
  44828. /**
  44829. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44830. */
  44831. private _lightingInfos;
  44832. /**
  44833. * Debug Control allowing disabling the bump map on this material.
  44834. */
  44835. protected _disableBumpMap: boolean;
  44836. /**
  44837. * AKA Diffuse Texture in standard nomenclature.
  44838. */
  44839. protected _albedoTexture: BaseTexture;
  44840. /**
  44841. * AKA Occlusion Texture in other nomenclature.
  44842. */
  44843. protected _ambientTexture: BaseTexture;
  44844. /**
  44845. * AKA Occlusion Texture Intensity in other nomenclature.
  44846. */
  44847. protected _ambientTextureStrength: number;
  44848. /**
  44849. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44850. * 1 means it completely occludes it
  44851. * 0 mean it has no impact
  44852. */
  44853. protected _ambientTextureImpactOnAnalyticalLights: number;
  44854. /**
  44855. * Stores the alpha values in a texture.
  44856. */
  44857. protected _opacityTexture: BaseTexture;
  44858. /**
  44859. * Stores the reflection values in a texture.
  44860. */
  44861. protected _reflectionTexture: BaseTexture;
  44862. /**
  44863. * Stores the refraction values in a texture.
  44864. */
  44865. protected _refractionTexture: BaseTexture;
  44866. /**
  44867. * Stores the emissive values in a texture.
  44868. */
  44869. protected _emissiveTexture: BaseTexture;
  44870. /**
  44871. * AKA Specular texture in other nomenclature.
  44872. */
  44873. protected _reflectivityTexture: BaseTexture;
  44874. /**
  44875. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44876. */
  44877. protected _metallicTexture: BaseTexture;
  44878. /**
  44879. * Specifies the metallic scalar of the metallic/roughness workflow.
  44880. * Can also be used to scale the metalness values of the metallic texture.
  44881. */
  44882. protected _metallic: Nullable<number>;
  44883. /**
  44884. * Specifies the roughness scalar of the metallic/roughness workflow.
  44885. * Can also be used to scale the roughness values of the metallic texture.
  44886. */
  44887. protected _roughness: Nullable<number>;
  44888. /**
  44889. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44890. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44891. */
  44892. protected _microSurfaceTexture: BaseTexture;
  44893. /**
  44894. * Stores surface normal data used to displace a mesh in a texture.
  44895. */
  44896. protected _bumpTexture: BaseTexture;
  44897. /**
  44898. * Stores the pre-calculated light information of a mesh in a texture.
  44899. */
  44900. protected _lightmapTexture: BaseTexture;
  44901. /**
  44902. * The color of a material in ambient lighting.
  44903. */
  44904. protected _ambientColor: Color3;
  44905. /**
  44906. * AKA Diffuse Color in other nomenclature.
  44907. */
  44908. protected _albedoColor: Color3;
  44909. /**
  44910. * AKA Specular Color in other nomenclature.
  44911. */
  44912. protected _reflectivityColor: Color3;
  44913. /**
  44914. * The color applied when light is reflected from a material.
  44915. */
  44916. protected _reflectionColor: Color3;
  44917. /**
  44918. * The color applied when light is emitted from a material.
  44919. */
  44920. protected _emissiveColor: Color3;
  44921. /**
  44922. * AKA Glossiness in other nomenclature.
  44923. */
  44924. protected _microSurface: number;
  44925. /**
  44926. * source material index of refraction (IOR)' / 'destination material IOR.
  44927. */
  44928. protected _indexOfRefraction: number;
  44929. /**
  44930. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44931. */
  44932. protected _invertRefractionY: boolean;
  44933. /**
  44934. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44935. * Materials half opaque for instance using refraction could benefit from this control.
  44936. */
  44937. protected _linkRefractionWithTransparency: boolean;
  44938. /**
  44939. * Specifies that the material will use the light map as a show map.
  44940. */
  44941. protected _useLightmapAsShadowmap: boolean;
  44942. /**
  44943. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44944. * makes the reflect vector face the model (under horizon).
  44945. */
  44946. protected _useHorizonOcclusion: boolean;
  44947. /**
  44948. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44949. * too much the area relying on ambient texture to define their ambient occlusion.
  44950. */
  44951. protected _useRadianceOcclusion: boolean;
  44952. /**
  44953. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44954. */
  44955. protected _useAlphaFromAlbedoTexture: boolean;
  44956. /**
  44957. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44959. */
  44960. protected _useSpecularOverAlpha: boolean;
  44961. /**
  44962. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44963. */
  44964. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44965. /**
  44966. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44967. */
  44968. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44969. /**
  44970. * Specifies if the metallic texture contains the roughness information in its green channel.
  44971. */
  44972. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44973. /**
  44974. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44975. */
  44976. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44977. /**
  44978. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44979. */
  44980. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44981. /**
  44982. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44983. */
  44984. protected _useAmbientInGrayScale: boolean;
  44985. /**
  44986. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44987. * The material will try to infer what glossiness each pixel should be.
  44988. */
  44989. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44990. /**
  44991. * Defines the falloff type used in this material.
  44992. * It by default is Physical.
  44993. */
  44994. protected _lightFalloff: number;
  44995. /**
  44996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44998. */
  44999. protected _useRadianceOverAlpha: boolean;
  45000. /**
  45001. * Allows using an object space normal map (instead of tangent space).
  45002. */
  45003. protected _useObjectSpaceNormalMap: boolean;
  45004. /**
  45005. * Allows using the bump map in parallax mode.
  45006. */
  45007. protected _useParallax: boolean;
  45008. /**
  45009. * Allows using the bump map in parallax occlusion mode.
  45010. */
  45011. protected _useParallaxOcclusion: boolean;
  45012. /**
  45013. * Controls the scale bias of the parallax mode.
  45014. */
  45015. protected _parallaxScaleBias: number;
  45016. /**
  45017. * If sets to true, disables all the lights affecting the material.
  45018. */
  45019. protected _disableLighting: boolean;
  45020. /**
  45021. * Number of Simultaneous lights allowed on the material.
  45022. */
  45023. protected _maxSimultaneousLights: number;
  45024. /**
  45025. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45026. */
  45027. protected _invertNormalMapX: boolean;
  45028. /**
  45029. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45030. */
  45031. protected _invertNormalMapY: boolean;
  45032. /**
  45033. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45034. */
  45035. protected _twoSidedLighting: boolean;
  45036. /**
  45037. * Defines the alpha limits in alpha test mode.
  45038. */
  45039. protected _alphaCutOff: number;
  45040. /**
  45041. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45042. */
  45043. protected _forceAlphaTest: boolean;
  45044. /**
  45045. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45046. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45047. */
  45048. protected _useAlphaFresnel: boolean;
  45049. /**
  45050. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45051. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45052. */
  45053. protected _useLinearAlphaFresnel: boolean;
  45054. /**
  45055. * The transparency mode of the material.
  45056. */
  45057. protected _transparencyMode: Nullable<number>;
  45058. /**
  45059. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45060. * from cos thetav and roughness:
  45061. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45062. */
  45063. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45064. /**
  45065. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45066. */
  45067. protected _forceIrradianceInFragment: boolean;
  45068. /**
  45069. * Force normal to face away from face.
  45070. */
  45071. protected _forceNormalForward: boolean;
  45072. /**
  45073. * Enables specular anti aliasing in the PBR shader.
  45074. * It will both interacts on the Geometry for analytical and IBL lighting.
  45075. * It also prefilter the roughness map based on the bump values.
  45076. */
  45077. protected _enableSpecularAntiAliasing: boolean;
  45078. /**
  45079. * Default configuration related to image processing available in the PBR Material.
  45080. */
  45081. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45082. /**
  45083. * Keep track of the image processing observer to allow dispose and replace.
  45084. */
  45085. private _imageProcessingObserver;
  45086. /**
  45087. * Attaches a new image processing configuration to the PBR Material.
  45088. * @param configuration
  45089. */
  45090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45091. /**
  45092. * Stores the available render targets.
  45093. */
  45094. private _renderTargets;
  45095. /**
  45096. * Sets the global ambient color for the material used in lighting calculations.
  45097. */
  45098. private _globalAmbientColor;
  45099. /**
  45100. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45101. */
  45102. private _useLogarithmicDepth;
  45103. /**
  45104. * If set to true, no lighting calculations will be applied.
  45105. */
  45106. private _unlit;
  45107. private _debugMode;
  45108. /**
  45109. * @hidden
  45110. * This is reserved for the inspector.
  45111. * Defines the material debug mode.
  45112. * It helps seeing only some components of the material while troubleshooting.
  45113. */
  45114. debugMode: number;
  45115. /**
  45116. * @hidden
  45117. * This is reserved for the inspector.
  45118. * Specify from where on screen the debug mode should start.
  45119. * The value goes from -1 (full screen) to 1 (not visible)
  45120. * It helps with side by side comparison against the final render
  45121. * This defaults to -1
  45122. */
  45123. private debugLimit;
  45124. /**
  45125. * @hidden
  45126. * This is reserved for the inspector.
  45127. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45128. * You can use the factor to better multiply the final value.
  45129. */
  45130. private debugFactor;
  45131. /**
  45132. * Defines the clear coat layer parameters for the material.
  45133. */
  45134. readonly clearCoat: PBRClearCoatConfiguration;
  45135. /**
  45136. * Defines the anisotropic parameters for the material.
  45137. */
  45138. readonly anisotropy: PBRAnisotropicConfiguration;
  45139. /**
  45140. * Defines the BRDF parameters for the material.
  45141. */
  45142. readonly brdf: PBRBRDFConfiguration;
  45143. /**
  45144. * Instantiates a new PBRMaterial instance.
  45145. *
  45146. * @param name The material name
  45147. * @param scene The scene the material will be use in.
  45148. */
  45149. constructor(name: string, scene: Scene);
  45150. /**
  45151. * Gets a boolean indicating that current material needs to register RTT
  45152. */
  45153. readonly hasRenderTargetTextures: boolean;
  45154. /**
  45155. * Gets the name of the material class.
  45156. */
  45157. getClassName(): string;
  45158. /**
  45159. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45160. */
  45161. /**
  45162. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45163. */
  45164. useLogarithmicDepth: boolean;
  45165. /**
  45166. * Gets the current transparency mode.
  45167. */
  45168. /**
  45169. * Sets the transparency mode of the material.
  45170. *
  45171. * | Value | Type | Description |
  45172. * | ----- | ----------------------------------- | ----------- |
  45173. * | 0 | OPAQUE | |
  45174. * | 1 | ALPHATEST | |
  45175. * | 2 | ALPHABLEND | |
  45176. * | 3 | ALPHATESTANDBLEND | |
  45177. *
  45178. */
  45179. transparencyMode: Nullable<number>;
  45180. /**
  45181. * Returns true if alpha blending should be disabled.
  45182. */
  45183. private readonly _disableAlphaBlending;
  45184. /**
  45185. * Specifies whether or not this material should be rendered in alpha blend mode.
  45186. */
  45187. needAlphaBlending(): boolean;
  45188. /**
  45189. * Specifies if the mesh will require alpha blending.
  45190. * @param mesh - BJS mesh.
  45191. */
  45192. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45193. /**
  45194. * Specifies whether or not this material should be rendered in alpha test mode.
  45195. */
  45196. needAlphaTesting(): boolean;
  45197. /**
  45198. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45199. */
  45200. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45201. /**
  45202. * Gets the texture used for the alpha test.
  45203. */
  45204. getAlphaTestTexture(): BaseTexture;
  45205. /**
  45206. * Specifies that the submesh is ready to be used.
  45207. * @param mesh - BJS mesh.
  45208. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45209. * @param useInstances - Specifies that instances should be used.
  45210. * @returns - boolean indicating that the submesh is ready or not.
  45211. */
  45212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45213. /**
  45214. * Specifies if the material uses metallic roughness workflow.
  45215. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45216. */
  45217. isMetallicWorkflow(): boolean;
  45218. private _prepareEffect;
  45219. private _prepareDefines;
  45220. /**
  45221. * Force shader compilation
  45222. */
  45223. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45224. clipPlane: boolean;
  45225. }>): void;
  45226. /**
  45227. * Initializes the uniform buffer layout for the shader.
  45228. */
  45229. buildUniformLayout(): void;
  45230. /**
  45231. * Unbinds the textures.
  45232. */
  45233. unbind(): void;
  45234. /**
  45235. * Binds the submesh data.
  45236. * @param world - The world matrix.
  45237. * @param mesh - The BJS mesh.
  45238. * @param subMesh - A submesh of the BJS mesh.
  45239. */
  45240. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45241. /**
  45242. * Returns the animatable textures.
  45243. * @returns - Array of animatable textures.
  45244. */
  45245. getAnimatables(): IAnimatable[];
  45246. /**
  45247. * Returns the texture used for reflections.
  45248. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45249. */
  45250. private _getReflectionTexture;
  45251. /**
  45252. * Returns the texture used for refraction or null if none is used.
  45253. * @returns - Refection texture if present. If no refraction texture and refraction
  45254. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45255. */
  45256. private _getRefractionTexture;
  45257. /**
  45258. * Returns an array of the actively used textures.
  45259. * @returns - Array of BaseTextures
  45260. */
  45261. getActiveTextures(): BaseTexture[];
  45262. /**
  45263. * Checks to see if a texture is used in the material.
  45264. * @param texture - Base texture to use.
  45265. * @returns - Boolean specifying if a texture is used in the material.
  45266. */
  45267. hasTexture(texture: BaseTexture): boolean;
  45268. /**
  45269. * Disposes the resources of the material.
  45270. * @param forceDisposeEffect - Forces the disposal of effects.
  45271. * @param forceDisposeTextures - Forces the disposal of all textures.
  45272. */
  45273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45274. }
  45275. }
  45276. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45277. import { Nullable } from "babylonjs/types";
  45278. import { Scene } from "babylonjs/scene";
  45279. import { Color3 } from "babylonjs/Maths/math";
  45280. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45281. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45283. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45284. /**
  45285. * The Physically based material of BJS.
  45286. *
  45287. * This offers the main features of a standard PBR material.
  45288. * For more information, please refer to the documentation :
  45289. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45290. */
  45291. export class PBRMaterial extends PBRBaseMaterial {
  45292. /**
  45293. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45294. */
  45295. static readonly PBRMATERIAL_OPAQUE: number;
  45296. /**
  45297. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45298. */
  45299. static readonly PBRMATERIAL_ALPHATEST: number;
  45300. /**
  45301. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45302. */
  45303. static readonly PBRMATERIAL_ALPHABLEND: number;
  45304. /**
  45305. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45306. * They are also discarded below the alpha cutoff threshold to improve performances.
  45307. */
  45308. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45309. /**
  45310. * Defines the default value of how much AO map is occluding the analytical lights
  45311. * (point spot...).
  45312. */
  45313. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45314. /**
  45315. * Intensity of the direct lights e.g. the four lights available in your scene.
  45316. * This impacts both the direct diffuse and specular highlights.
  45317. */
  45318. directIntensity: number;
  45319. /**
  45320. * Intensity of the emissive part of the material.
  45321. * This helps controlling the emissive effect without modifying the emissive color.
  45322. */
  45323. emissiveIntensity: number;
  45324. /**
  45325. * Intensity of the environment e.g. how much the environment will light the object
  45326. * either through harmonics for rough material or through the refelction for shiny ones.
  45327. */
  45328. environmentIntensity: number;
  45329. /**
  45330. * This is a special control allowing the reduction of the specular highlights coming from the
  45331. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45332. */
  45333. specularIntensity: number;
  45334. /**
  45335. * Debug Control allowing disabling the bump map on this material.
  45336. */
  45337. disableBumpMap: boolean;
  45338. /**
  45339. * AKA Diffuse Texture in standard nomenclature.
  45340. */
  45341. albedoTexture: BaseTexture;
  45342. /**
  45343. * AKA Occlusion Texture in other nomenclature.
  45344. */
  45345. ambientTexture: BaseTexture;
  45346. /**
  45347. * AKA Occlusion Texture Intensity in other nomenclature.
  45348. */
  45349. ambientTextureStrength: number;
  45350. /**
  45351. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45352. * 1 means it completely occludes it
  45353. * 0 mean it has no impact
  45354. */
  45355. ambientTextureImpactOnAnalyticalLights: number;
  45356. /**
  45357. * Stores the alpha values in a texture.
  45358. */
  45359. opacityTexture: BaseTexture;
  45360. /**
  45361. * Stores the reflection values in a texture.
  45362. */
  45363. reflectionTexture: Nullable<BaseTexture>;
  45364. /**
  45365. * Stores the emissive values in a texture.
  45366. */
  45367. emissiveTexture: BaseTexture;
  45368. /**
  45369. * AKA Specular texture in other nomenclature.
  45370. */
  45371. reflectivityTexture: BaseTexture;
  45372. /**
  45373. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45374. */
  45375. metallicTexture: BaseTexture;
  45376. /**
  45377. * Specifies the metallic scalar of the metallic/roughness workflow.
  45378. * Can also be used to scale the metalness values of the metallic texture.
  45379. */
  45380. metallic: Nullable<number>;
  45381. /**
  45382. * Specifies the roughness scalar of the metallic/roughness workflow.
  45383. * Can also be used to scale the roughness values of the metallic texture.
  45384. */
  45385. roughness: Nullable<number>;
  45386. /**
  45387. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45388. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45389. */
  45390. microSurfaceTexture: BaseTexture;
  45391. /**
  45392. * Stores surface normal data used to displace a mesh in a texture.
  45393. */
  45394. bumpTexture: BaseTexture;
  45395. /**
  45396. * Stores the pre-calculated light information of a mesh in a texture.
  45397. */
  45398. lightmapTexture: BaseTexture;
  45399. /**
  45400. * Stores the refracted light information in a texture.
  45401. */
  45402. refractionTexture: BaseTexture;
  45403. /**
  45404. * The color of a material in ambient lighting.
  45405. */
  45406. ambientColor: Color3;
  45407. /**
  45408. * AKA Diffuse Color in other nomenclature.
  45409. */
  45410. albedoColor: Color3;
  45411. /**
  45412. * AKA Specular Color in other nomenclature.
  45413. */
  45414. reflectivityColor: Color3;
  45415. /**
  45416. * The color reflected from the material.
  45417. */
  45418. reflectionColor: Color3;
  45419. /**
  45420. * The color emitted from the material.
  45421. */
  45422. emissiveColor: Color3;
  45423. /**
  45424. * AKA Glossiness in other nomenclature.
  45425. */
  45426. microSurface: number;
  45427. /**
  45428. * source material index of refraction (IOR)' / 'destination material IOR.
  45429. */
  45430. indexOfRefraction: number;
  45431. /**
  45432. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45433. */
  45434. invertRefractionY: boolean;
  45435. /**
  45436. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45437. * Materials half opaque for instance using refraction could benefit from this control.
  45438. */
  45439. linkRefractionWithTransparency: boolean;
  45440. /**
  45441. * If true, the light map contains occlusion information instead of lighting info.
  45442. */
  45443. useLightmapAsShadowmap: boolean;
  45444. /**
  45445. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45446. */
  45447. useAlphaFromAlbedoTexture: boolean;
  45448. /**
  45449. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45450. */
  45451. forceAlphaTest: boolean;
  45452. /**
  45453. * Defines the alpha limits in alpha test mode.
  45454. */
  45455. alphaCutOff: number;
  45456. /**
  45457. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45458. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45459. */
  45460. useSpecularOverAlpha: boolean;
  45461. /**
  45462. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45463. */
  45464. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45465. /**
  45466. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45467. */
  45468. useRoughnessFromMetallicTextureAlpha: boolean;
  45469. /**
  45470. * Specifies if the metallic texture contains the roughness information in its green channel.
  45471. */
  45472. useRoughnessFromMetallicTextureGreen: boolean;
  45473. /**
  45474. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45475. */
  45476. useMetallnessFromMetallicTextureBlue: boolean;
  45477. /**
  45478. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45479. */
  45480. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45481. /**
  45482. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45483. */
  45484. useAmbientInGrayScale: boolean;
  45485. /**
  45486. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45487. * The material will try to infer what glossiness each pixel should be.
  45488. */
  45489. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45490. /**
  45491. * BJS is using an harcoded light falloff based on a manually sets up range.
  45492. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45493. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45494. */
  45495. /**
  45496. * BJS is using an harcoded light falloff based on a manually sets up range.
  45497. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45498. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45499. */
  45500. usePhysicalLightFalloff: boolean;
  45501. /**
  45502. * In order to support the falloff compatibility with gltf, a special mode has been added
  45503. * to reproduce the gltf light falloff.
  45504. */
  45505. /**
  45506. * In order to support the falloff compatibility with gltf, a special mode has been added
  45507. * to reproduce the gltf light falloff.
  45508. */
  45509. useGLTFLightFalloff: boolean;
  45510. /**
  45511. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45512. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45513. */
  45514. useRadianceOverAlpha: boolean;
  45515. /**
  45516. * Allows using an object space normal map (instead of tangent space).
  45517. */
  45518. useObjectSpaceNormalMap: boolean;
  45519. /**
  45520. * Allows using the bump map in parallax mode.
  45521. */
  45522. useParallax: boolean;
  45523. /**
  45524. * Allows using the bump map in parallax occlusion mode.
  45525. */
  45526. useParallaxOcclusion: boolean;
  45527. /**
  45528. * Controls the scale bias of the parallax mode.
  45529. */
  45530. parallaxScaleBias: number;
  45531. /**
  45532. * If sets to true, disables all the lights affecting the material.
  45533. */
  45534. disableLighting: boolean;
  45535. /**
  45536. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45537. */
  45538. forceIrradianceInFragment: boolean;
  45539. /**
  45540. * Number of Simultaneous lights allowed on the material.
  45541. */
  45542. maxSimultaneousLights: number;
  45543. /**
  45544. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45545. */
  45546. invertNormalMapX: boolean;
  45547. /**
  45548. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45549. */
  45550. invertNormalMapY: boolean;
  45551. /**
  45552. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45553. */
  45554. twoSidedLighting: boolean;
  45555. /**
  45556. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45557. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45558. */
  45559. useAlphaFresnel: boolean;
  45560. /**
  45561. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45562. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45563. */
  45564. useLinearAlphaFresnel: boolean;
  45565. /**
  45566. * Let user defines the brdf lookup texture used for IBL.
  45567. * A default 8bit version is embedded but you could point at :
  45568. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45569. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45570. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45571. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45572. */
  45573. environmentBRDFTexture: Nullable<BaseTexture>;
  45574. /**
  45575. * Force normal to face away from face.
  45576. */
  45577. forceNormalForward: boolean;
  45578. /**
  45579. * Enables specular anti aliasing in the PBR shader.
  45580. * It will both interacts on the Geometry for analytical and IBL lighting.
  45581. * It also prefilter the roughness map based on the bump values.
  45582. */
  45583. enableSpecularAntiAliasing: boolean;
  45584. /**
  45585. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45586. * makes the reflect vector face the model (under horizon).
  45587. */
  45588. useHorizonOcclusion: boolean;
  45589. /**
  45590. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45591. * too much the area relying on ambient texture to define their ambient occlusion.
  45592. */
  45593. useRadianceOcclusion: boolean;
  45594. /**
  45595. * If set to true, no lighting calculations will be applied.
  45596. */
  45597. unlit: boolean;
  45598. /**
  45599. * Gets the image processing configuration used either in this material.
  45600. */
  45601. /**
  45602. * Sets the Default image processing configuration used either in the this material.
  45603. *
  45604. * If sets to null, the scene one is in use.
  45605. */
  45606. imageProcessingConfiguration: ImageProcessingConfiguration;
  45607. /**
  45608. * Gets wether the color curves effect is enabled.
  45609. */
  45610. /**
  45611. * Sets wether the color curves effect is enabled.
  45612. */
  45613. cameraColorCurvesEnabled: boolean;
  45614. /**
  45615. * Gets wether the color grading effect is enabled.
  45616. */
  45617. /**
  45618. * Gets wether the color grading effect is enabled.
  45619. */
  45620. cameraColorGradingEnabled: boolean;
  45621. /**
  45622. * Gets wether tonemapping is enabled or not.
  45623. */
  45624. /**
  45625. * Sets wether tonemapping is enabled or not
  45626. */
  45627. cameraToneMappingEnabled: boolean;
  45628. /**
  45629. * The camera exposure used on this material.
  45630. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45631. * This corresponds to a photographic exposure.
  45632. */
  45633. /**
  45634. * The camera exposure used on this material.
  45635. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45636. * This corresponds to a photographic exposure.
  45637. */
  45638. cameraExposure: number;
  45639. /**
  45640. * Gets The camera contrast used on this material.
  45641. */
  45642. /**
  45643. * Sets The camera contrast used on this material.
  45644. */
  45645. cameraContrast: number;
  45646. /**
  45647. * Gets the Color Grading 2D Lookup Texture.
  45648. */
  45649. /**
  45650. * Sets the Color Grading 2D Lookup Texture.
  45651. */
  45652. cameraColorGradingTexture: Nullable<BaseTexture>;
  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. /**
  45660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45662. * 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;
  45663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45664. */
  45665. cameraColorCurves: Nullable<ColorCurves>;
  45666. /**
  45667. * Instantiates a new PBRMaterial instance.
  45668. *
  45669. * @param name The material name
  45670. * @param scene The scene the material will be use in.
  45671. */
  45672. constructor(name: string, scene: Scene);
  45673. /**
  45674. * Returns the name of this material class.
  45675. */
  45676. getClassName(): string;
  45677. /**
  45678. * Makes a duplicate of the current material.
  45679. * @param name - name to use for the new material.
  45680. */
  45681. clone(name: string): PBRMaterial;
  45682. /**
  45683. * Serializes this PBR Material.
  45684. * @returns - An object with the serialized material.
  45685. */
  45686. serialize(): any;
  45687. /**
  45688. * Parses a PBR Material from a serialized object.
  45689. * @param source - Serialized object.
  45690. * @param scene - BJS scene instance.
  45691. * @param rootUrl - url for the scene object
  45692. * @returns - PBRMaterial
  45693. */
  45694. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45695. }
  45696. }
  45697. declare module "babylonjs/Misc/dds" {
  45698. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45699. import { Engine } from "babylonjs/Engines/engine";
  45700. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45701. import { Nullable } from "babylonjs/types";
  45702. import { Scene } from "babylonjs/scene";
  45703. /**
  45704. * Direct draw surface info
  45705. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45706. */
  45707. export interface DDSInfo {
  45708. /**
  45709. * Width of the texture
  45710. */
  45711. width: number;
  45712. /**
  45713. * Width of the texture
  45714. */
  45715. height: number;
  45716. /**
  45717. * Number of Mipmaps for the texture
  45718. * @see https://en.wikipedia.org/wiki/Mipmap
  45719. */
  45720. mipmapCount: number;
  45721. /**
  45722. * If the textures format is a known fourCC format
  45723. * @see https://www.fourcc.org/
  45724. */
  45725. isFourCC: boolean;
  45726. /**
  45727. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45728. */
  45729. isRGB: boolean;
  45730. /**
  45731. * If the texture is a lumincance format
  45732. */
  45733. isLuminance: boolean;
  45734. /**
  45735. * If this is a cube texture
  45736. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45737. */
  45738. isCube: boolean;
  45739. /**
  45740. * If the texture is a compressed format eg. FOURCC_DXT1
  45741. */
  45742. isCompressed: boolean;
  45743. /**
  45744. * The dxgiFormat of the texture
  45745. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45746. */
  45747. dxgiFormat: number;
  45748. /**
  45749. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45750. */
  45751. textureType: number;
  45752. /**
  45753. * Sphericle polynomial created for the dds texture
  45754. */
  45755. sphericalPolynomial?: SphericalPolynomial;
  45756. }
  45757. /**
  45758. * Class used to provide DDS decompression tools
  45759. */
  45760. export class DDSTools {
  45761. /**
  45762. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45763. */
  45764. static StoreLODInAlphaChannel: boolean;
  45765. /**
  45766. * Gets DDS information from an array buffer
  45767. * @param arrayBuffer defines the array buffer to read data from
  45768. * @returns the DDS information
  45769. */
  45770. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45771. private static _FloatView;
  45772. private static _Int32View;
  45773. private static _ToHalfFloat;
  45774. private static _FromHalfFloat;
  45775. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45776. private static _GetHalfFloatRGBAArrayBuffer;
  45777. private static _GetFloatRGBAArrayBuffer;
  45778. private static _GetFloatAsUIntRGBAArrayBuffer;
  45779. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45780. private static _GetRGBAArrayBuffer;
  45781. private static _ExtractLongWordOrder;
  45782. private static _GetRGBArrayBuffer;
  45783. private static _GetLuminanceArrayBuffer;
  45784. /**
  45785. * Uploads DDS Levels to a Babylon Texture
  45786. * @hidden
  45787. */
  45788. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45789. }
  45790. module "babylonjs/Engines/engine" {
  45791. interface Engine {
  45792. /**
  45793. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45794. * @param rootUrl defines the url where the file to load is located
  45795. * @param scene defines the current scene
  45796. * @param lodScale defines scale to apply to the mip map selection
  45797. * @param lodOffset defines offset to apply to the mip map selection
  45798. * @param onLoad defines an optional callback raised when the texture is loaded
  45799. * @param onError defines an optional callback raised if there is an issue to load the texture
  45800. * @param format defines the format of the data
  45801. * @param forcedExtension defines the extension to use to pick the right loader
  45802. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45803. * @returns the cube texture as an InternalTexture
  45804. */
  45805. 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;
  45806. }
  45807. }
  45808. }
  45809. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  45810. import { Nullable } from "babylonjs/types";
  45811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45812. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  45813. /**
  45814. * Implementation of the DDS Texture Loader.
  45815. * @hidden
  45816. */
  45817. export class _DDSTextureLoader implements IInternalTextureLoader {
  45818. /**
  45819. * Defines wether the loader supports cascade loading the different faces.
  45820. */
  45821. readonly supportCascades: boolean;
  45822. /**
  45823. * This returns if the loader support the current file information.
  45824. * @param extension defines the file extension of the file being loaded
  45825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45826. * @param fallback defines the fallback internal texture if any
  45827. * @param isBase64 defines whether the texture is encoded as a base64
  45828. * @param isBuffer defines whether the texture data are stored as a buffer
  45829. * @returns true if the loader can load the specified file
  45830. */
  45831. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45832. /**
  45833. * Transform the url before loading if required.
  45834. * @param rootUrl the url of the texture
  45835. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45836. * @returns the transformed texture
  45837. */
  45838. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45839. /**
  45840. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45841. * @param rootUrl the url of the texture
  45842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45843. * @returns the fallback texture
  45844. */
  45845. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45846. /**
  45847. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45848. * @param data contains the texture data
  45849. * @param texture defines the BabylonJS internal texture
  45850. * @param createPolynomials will be true if polynomials have been requested
  45851. * @param onLoad defines the callback to trigger once the texture is ready
  45852. * @param onError defines the callback to trigger in case of error
  45853. */
  45854. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45855. /**
  45856. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45857. * @param data contains the texture data
  45858. * @param texture defines the BabylonJS internal texture
  45859. * @param callback defines the method to call once ready to upload
  45860. */
  45861. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45862. }
  45863. }
  45864. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45866. /** @hidden */
  45867. export var rgbdEncodePixelShader: {
  45868. name: string;
  45869. shader: string;
  45870. };
  45871. }
  45872. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45874. /** @hidden */
  45875. export var rgbdDecodePixelShader: {
  45876. name: string;
  45877. shader: string;
  45878. };
  45879. }
  45880. declare module "babylonjs/Misc/environmentTextureTools" {
  45881. import { Nullable } from "babylonjs/types";
  45882. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45884. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45885. import "babylonjs/Shaders/rgbdEncode.fragment";
  45886. import "babylonjs/Shaders/rgbdDecode.fragment";
  45887. /**
  45888. * Raw texture data and descriptor sufficient for WebGL texture upload
  45889. */
  45890. export interface EnvironmentTextureInfo {
  45891. /**
  45892. * Version of the environment map
  45893. */
  45894. version: number;
  45895. /**
  45896. * Width of image
  45897. */
  45898. width: number;
  45899. /**
  45900. * Irradiance information stored in the file.
  45901. */
  45902. irradiance: any;
  45903. /**
  45904. * Specular information stored in the file.
  45905. */
  45906. specular: any;
  45907. }
  45908. /**
  45909. * Sets of helpers addressing the serialization and deserialization of environment texture
  45910. * stored in a BabylonJS env file.
  45911. * Those files are usually stored as .env files.
  45912. */
  45913. export class EnvironmentTextureTools {
  45914. /**
  45915. * Magic number identifying the env file.
  45916. */
  45917. private static _MagicBytes;
  45918. /**
  45919. * Gets the environment info from an env file.
  45920. * @param data The array buffer containing the .env bytes.
  45921. * @returns the environment file info (the json header) if successfully parsed.
  45922. */
  45923. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45924. /**
  45925. * Creates an environment texture from a loaded cube texture.
  45926. * @param texture defines the cube texture to convert in env file
  45927. * @return a promise containing the environment data if succesfull.
  45928. */
  45929. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45930. /**
  45931. * Creates a JSON representation of the spherical data.
  45932. * @param texture defines the texture containing the polynomials
  45933. * @return the JSON representation of the spherical info
  45934. */
  45935. private static _CreateEnvTextureIrradiance;
  45936. /**
  45937. * Uploads the texture info contained in the env file to the GPU.
  45938. * @param texture defines the internal texture to upload to
  45939. * @param arrayBuffer defines the buffer cotaining the data to load
  45940. * @param info defines the texture info retrieved through the GetEnvInfo method
  45941. * @returns a promise
  45942. */
  45943. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45944. /**
  45945. * Uploads the levels of image data to the GPU.
  45946. * @param texture defines the internal texture to upload to
  45947. * @param imageData defines the array buffer views of image data [mipmap][face]
  45948. * @returns a promise
  45949. */
  45950. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45951. /**
  45952. * Uploads spherical polynomials information to the texture.
  45953. * @param texture defines the texture we are trying to upload the information to
  45954. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45955. */
  45956. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45957. /** @hidden */
  45958. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45959. }
  45960. }
  45961. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  45962. import { Nullable } from "babylonjs/types";
  45963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45964. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  45965. /**
  45966. * Implementation of the ENV Texture Loader.
  45967. * @hidden
  45968. */
  45969. export class _ENVTextureLoader implements IInternalTextureLoader {
  45970. /**
  45971. * Defines wether the loader supports cascade loading the different faces.
  45972. */
  45973. readonly supportCascades: boolean;
  45974. /**
  45975. * This returns if the loader support the current file information.
  45976. * @param extension defines the file extension of the file being loaded
  45977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45978. * @param fallback defines the fallback internal texture if any
  45979. * @param isBase64 defines whether the texture is encoded as a base64
  45980. * @param isBuffer defines whether the texture data are stored as a buffer
  45981. * @returns true if the loader can load the specified file
  45982. */
  45983. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45984. /**
  45985. * Transform the url before loading if required.
  45986. * @param rootUrl the url of the texture
  45987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45988. * @returns the transformed texture
  45989. */
  45990. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45991. /**
  45992. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45993. * @param rootUrl the url of the texture
  45994. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45995. * @returns the fallback texture
  45996. */
  45997. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45998. /**
  45999. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46000. * @param data contains the texture data
  46001. * @param texture defines the BabylonJS internal texture
  46002. * @param createPolynomials will be true if polynomials have been requested
  46003. * @param onLoad defines the callback to trigger once the texture is ready
  46004. * @param onError defines the callback to trigger in case of error
  46005. */
  46006. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46007. /**
  46008. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46009. * @param data contains the texture data
  46010. * @param texture defines the BabylonJS internal texture
  46011. * @param callback defines the method to call once ready to upload
  46012. */
  46013. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46014. }
  46015. }
  46016. declare module "babylonjs/Misc/khronosTextureContainer" {
  46017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46018. /**
  46019. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46020. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46021. */
  46022. export class KhronosTextureContainer {
  46023. /** contents of the KTX container file */
  46024. arrayBuffer: any;
  46025. private static HEADER_LEN;
  46026. private static COMPRESSED_2D;
  46027. private static COMPRESSED_3D;
  46028. private static TEX_2D;
  46029. private static TEX_3D;
  46030. /**
  46031. * Gets the openGL type
  46032. */
  46033. glType: number;
  46034. /**
  46035. * Gets the openGL type size
  46036. */
  46037. glTypeSize: number;
  46038. /**
  46039. * Gets the openGL format
  46040. */
  46041. glFormat: number;
  46042. /**
  46043. * Gets the openGL internal format
  46044. */
  46045. glInternalFormat: number;
  46046. /**
  46047. * Gets the base internal format
  46048. */
  46049. glBaseInternalFormat: number;
  46050. /**
  46051. * Gets image width in pixel
  46052. */
  46053. pixelWidth: number;
  46054. /**
  46055. * Gets image height in pixel
  46056. */
  46057. pixelHeight: number;
  46058. /**
  46059. * Gets image depth in pixels
  46060. */
  46061. pixelDepth: number;
  46062. /**
  46063. * Gets the number of array elements
  46064. */
  46065. numberOfArrayElements: number;
  46066. /**
  46067. * Gets the number of faces
  46068. */
  46069. numberOfFaces: number;
  46070. /**
  46071. * Gets the number of mipmap levels
  46072. */
  46073. numberOfMipmapLevels: number;
  46074. /**
  46075. * Gets the bytes of key value data
  46076. */
  46077. bytesOfKeyValueData: number;
  46078. /**
  46079. * Gets the load type
  46080. */
  46081. loadType: number;
  46082. /**
  46083. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46084. */
  46085. isInvalid: boolean;
  46086. /**
  46087. * Creates a new KhronosTextureContainer
  46088. * @param arrayBuffer contents of the KTX container file
  46089. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46090. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46091. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46092. */
  46093. constructor(
  46094. /** contents of the KTX container file */
  46095. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46096. /**
  46097. * Uploads KTX content to a Babylon Texture.
  46098. * It is assumed that the texture has already been created & is currently bound
  46099. * @hidden
  46100. */
  46101. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46102. private _upload2DCompressedLevels;
  46103. }
  46104. }
  46105. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46106. import { Nullable } from "babylonjs/types";
  46107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46109. /**
  46110. * Implementation of the KTX Texture Loader.
  46111. * @hidden
  46112. */
  46113. export class _KTXTextureLoader implements IInternalTextureLoader {
  46114. /**
  46115. * Defines wether the loader supports cascade loading the different faces.
  46116. */
  46117. readonly supportCascades: boolean;
  46118. /**
  46119. * This returns if the loader support the current file information.
  46120. * @param extension defines the file extension of the file being loaded
  46121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46122. * @param fallback defines the fallback internal texture if any
  46123. * @param isBase64 defines whether the texture is encoded as a base64
  46124. * @param isBuffer defines whether the texture data are stored as a buffer
  46125. * @returns true if the loader can load the specified file
  46126. */
  46127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46128. /**
  46129. * Transform the url before loading if required.
  46130. * @param rootUrl the url of the texture
  46131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46132. * @returns the transformed texture
  46133. */
  46134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46135. /**
  46136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46137. * @param rootUrl the url of the texture
  46138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46139. * @returns the fallback texture
  46140. */
  46141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46142. /**
  46143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46144. * @param data contains the texture data
  46145. * @param texture defines the BabylonJS internal texture
  46146. * @param createPolynomials will be true if polynomials have been requested
  46147. * @param onLoad defines the callback to trigger once the texture is ready
  46148. * @param onError defines the callback to trigger in case of error
  46149. */
  46150. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46151. /**
  46152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46153. * @param data contains the texture data
  46154. * @param texture defines the BabylonJS internal texture
  46155. * @param callback defines the method to call once ready to upload
  46156. */
  46157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46158. }
  46159. }
  46160. declare module "babylonjs/Helpers/sceneHelpers" {
  46161. import { Nullable } from "babylonjs/types";
  46162. import { Mesh } from "babylonjs/Meshes/mesh";
  46163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46164. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46165. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46166. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46167. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46168. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46169. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46170. import "babylonjs/Meshes/Builders/boxBuilder";
  46171. /** @hidden */
  46172. export var _forceSceneHelpersToBundle: boolean;
  46173. module "babylonjs/scene" {
  46174. interface Scene {
  46175. /**
  46176. * Creates a default light for the scene.
  46177. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46178. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46179. */
  46180. createDefaultLight(replace?: boolean): void;
  46181. /**
  46182. * Creates a default camera for the scene.
  46183. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46184. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46185. * @param replace has default false, when true replaces the active camera in the scene
  46186. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46187. */
  46188. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46189. /**
  46190. * Creates a default camera and a default light.
  46191. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46192. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46193. * @param replace has the default false, when true replaces the active camera/light in the scene
  46194. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46195. */
  46196. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46197. /**
  46198. * Creates a new sky box
  46199. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46200. * @param environmentTexture defines the texture to use as environment texture
  46201. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46202. * @param scale defines the overall scale of the skybox
  46203. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46204. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46205. * @returns a new mesh holding the sky box
  46206. */
  46207. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46208. /**
  46209. * Creates a new environment
  46210. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46211. * @param options defines the options you can use to configure the environment
  46212. * @returns the new EnvironmentHelper
  46213. */
  46214. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46215. /**
  46216. * Creates a new VREXperienceHelper
  46217. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46218. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46219. * @returns a new VREXperienceHelper
  46220. */
  46221. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46222. /**
  46223. * Creates a new XREXperienceHelper
  46224. * @see http://doc.babylonjs.com/how_to/webxr
  46225. * @returns a promise for a new XREXperienceHelper
  46226. */
  46227. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46228. }
  46229. }
  46230. }
  46231. declare module "babylonjs/Helpers/videoDome" {
  46232. import { Scene } from "babylonjs/scene";
  46233. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46234. import { Mesh } from "babylonjs/Meshes/mesh";
  46235. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46236. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46237. import "babylonjs/Meshes/Builders/sphereBuilder";
  46238. /**
  46239. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46240. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46241. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46242. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46243. */
  46244. export class VideoDome extends TransformNode {
  46245. /**
  46246. * Define the video source as a Monoscopic panoramic 360 video.
  46247. */
  46248. static readonly MODE_MONOSCOPIC: number;
  46249. /**
  46250. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46251. */
  46252. static readonly MODE_TOPBOTTOM: number;
  46253. /**
  46254. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46255. */
  46256. static readonly MODE_SIDEBYSIDE: number;
  46257. private _useDirectMapping;
  46258. /**
  46259. * The video texture being displayed on the sphere
  46260. */
  46261. protected _videoTexture: VideoTexture;
  46262. /**
  46263. * Gets the video texture being displayed on the sphere
  46264. */
  46265. readonly videoTexture: VideoTexture;
  46266. /**
  46267. * The skybox material
  46268. */
  46269. protected _material: BackgroundMaterial;
  46270. /**
  46271. * The surface used for the skybox
  46272. */
  46273. protected _mesh: Mesh;
  46274. /**
  46275. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46276. * Also see the options.resolution property.
  46277. */
  46278. fovMultiplier: number;
  46279. private _videoMode;
  46280. /**
  46281. * Gets or set the current video mode for the video. It can be:
  46282. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46283. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46284. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46285. */
  46286. videoMode: number;
  46287. /**
  46288. * Oberserver used in Stereoscopic VR Mode.
  46289. */
  46290. private _onBeforeCameraRenderObserver;
  46291. /**
  46292. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46293. * @param name Element's name, child elements will append suffixes for their own names.
  46294. * @param urlsOrVideo defines the url(s) or the video element to use
  46295. * @param options An object containing optional or exposed sub element properties
  46296. */
  46297. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46298. resolution?: number;
  46299. clickToPlay?: boolean;
  46300. autoPlay?: boolean;
  46301. loop?: boolean;
  46302. size?: number;
  46303. poster?: string;
  46304. useDirectMapping?: boolean;
  46305. }, scene: Scene);
  46306. private _changeVideoMode;
  46307. /**
  46308. * Releases resources associated with this node.
  46309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46311. */
  46312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46313. }
  46314. }
  46315. declare module "babylonjs/Helpers/index" {
  46316. export * from "babylonjs/Helpers/environmentHelper";
  46317. export * from "babylonjs/Helpers/photoDome";
  46318. export * from "babylonjs/Helpers/sceneHelpers";
  46319. export * from "babylonjs/Helpers/videoDome";
  46320. }
  46321. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46322. import { PerfCounter } from "babylonjs/Misc/tools";
  46323. import { IDisposable } from "babylonjs/scene";
  46324. import { Engine } from "babylonjs/Engines/engine";
  46325. /**
  46326. * This class can be used to get instrumentation data from a Babylon engine
  46327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46328. */
  46329. export class EngineInstrumentation implements IDisposable {
  46330. /**
  46331. * Define the instrumented engine.
  46332. */
  46333. engine: Engine;
  46334. private _captureGPUFrameTime;
  46335. private _gpuFrameTimeToken;
  46336. private _gpuFrameTime;
  46337. private _captureShaderCompilationTime;
  46338. private _shaderCompilationTime;
  46339. private _onBeginFrameObserver;
  46340. private _onEndFrameObserver;
  46341. private _onBeforeShaderCompilationObserver;
  46342. private _onAfterShaderCompilationObserver;
  46343. /**
  46344. * Gets the perf counter used for GPU frame time
  46345. */
  46346. readonly gpuFrameTimeCounter: PerfCounter;
  46347. /**
  46348. * Gets the GPU frame time capture status
  46349. */
  46350. /**
  46351. * Enable or disable the GPU frame time capture
  46352. */
  46353. captureGPUFrameTime: boolean;
  46354. /**
  46355. * Gets the perf counter used for shader compilation time
  46356. */
  46357. readonly shaderCompilationTimeCounter: PerfCounter;
  46358. /**
  46359. * Gets the shader compilation time capture status
  46360. */
  46361. /**
  46362. * Enable or disable the shader compilation time capture
  46363. */
  46364. captureShaderCompilationTime: boolean;
  46365. /**
  46366. * Instantiates a new engine instrumentation.
  46367. * This class can be used to get instrumentation data from a Babylon engine
  46368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46369. * @param engine Defines the engine to instrument
  46370. */
  46371. constructor(
  46372. /**
  46373. * Define the instrumented engine.
  46374. */
  46375. engine: Engine);
  46376. /**
  46377. * Dispose and release associated resources.
  46378. */
  46379. dispose(): void;
  46380. }
  46381. }
  46382. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46383. import { PerfCounter } from "babylonjs/Misc/tools";
  46384. import { Scene, IDisposable } from "babylonjs/scene";
  46385. /**
  46386. * This class can be used to get instrumentation data from a Babylon engine
  46387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46388. */
  46389. export class SceneInstrumentation implements IDisposable {
  46390. /**
  46391. * Defines the scene to instrument
  46392. */
  46393. scene: Scene;
  46394. private _captureActiveMeshesEvaluationTime;
  46395. private _activeMeshesEvaluationTime;
  46396. private _captureRenderTargetsRenderTime;
  46397. private _renderTargetsRenderTime;
  46398. private _captureFrameTime;
  46399. private _frameTime;
  46400. private _captureRenderTime;
  46401. private _renderTime;
  46402. private _captureInterFrameTime;
  46403. private _interFrameTime;
  46404. private _captureParticlesRenderTime;
  46405. private _particlesRenderTime;
  46406. private _captureSpritesRenderTime;
  46407. private _spritesRenderTime;
  46408. private _capturePhysicsTime;
  46409. private _physicsTime;
  46410. private _captureAnimationsTime;
  46411. private _animationsTime;
  46412. private _captureCameraRenderTime;
  46413. private _cameraRenderTime;
  46414. private _onBeforeActiveMeshesEvaluationObserver;
  46415. private _onAfterActiveMeshesEvaluationObserver;
  46416. private _onBeforeRenderTargetsRenderObserver;
  46417. private _onAfterRenderTargetsRenderObserver;
  46418. private _onAfterRenderObserver;
  46419. private _onBeforeDrawPhaseObserver;
  46420. private _onAfterDrawPhaseObserver;
  46421. private _onBeforeAnimationsObserver;
  46422. private _onBeforeParticlesRenderingObserver;
  46423. private _onAfterParticlesRenderingObserver;
  46424. private _onBeforeSpritesRenderingObserver;
  46425. private _onAfterSpritesRenderingObserver;
  46426. private _onBeforePhysicsObserver;
  46427. private _onAfterPhysicsObserver;
  46428. private _onAfterAnimationsObserver;
  46429. private _onBeforeCameraRenderObserver;
  46430. private _onAfterCameraRenderObserver;
  46431. /**
  46432. * Gets the perf counter used for active meshes evaluation time
  46433. */
  46434. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46435. /**
  46436. * Gets the active meshes evaluation time capture status
  46437. */
  46438. /**
  46439. * Enable or disable the active meshes evaluation time capture
  46440. */
  46441. captureActiveMeshesEvaluationTime: boolean;
  46442. /**
  46443. * Gets the perf counter used for render targets render time
  46444. */
  46445. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46446. /**
  46447. * Gets the render targets render time capture status
  46448. */
  46449. /**
  46450. * Enable or disable the render targets render time capture
  46451. */
  46452. captureRenderTargetsRenderTime: boolean;
  46453. /**
  46454. * Gets the perf counter used for particles render time
  46455. */
  46456. readonly particlesRenderTimeCounter: PerfCounter;
  46457. /**
  46458. * Gets the particles render time capture status
  46459. */
  46460. /**
  46461. * Enable or disable the particles render time capture
  46462. */
  46463. captureParticlesRenderTime: boolean;
  46464. /**
  46465. * Gets the perf counter used for sprites render time
  46466. */
  46467. readonly spritesRenderTimeCounter: PerfCounter;
  46468. /**
  46469. * Gets the sprites render time capture status
  46470. */
  46471. /**
  46472. * Enable or disable the sprites render time capture
  46473. */
  46474. captureSpritesRenderTime: boolean;
  46475. /**
  46476. * Gets the perf counter used for physics time
  46477. */
  46478. readonly physicsTimeCounter: PerfCounter;
  46479. /**
  46480. * Gets the physics time capture status
  46481. */
  46482. /**
  46483. * Enable or disable the physics time capture
  46484. */
  46485. capturePhysicsTime: boolean;
  46486. /**
  46487. * Gets the perf counter used for animations time
  46488. */
  46489. readonly animationsTimeCounter: PerfCounter;
  46490. /**
  46491. * Gets the animations time capture status
  46492. */
  46493. /**
  46494. * Enable or disable the animations time capture
  46495. */
  46496. captureAnimationsTime: boolean;
  46497. /**
  46498. * Gets the perf counter used for frame time capture
  46499. */
  46500. readonly frameTimeCounter: PerfCounter;
  46501. /**
  46502. * Gets the frame time capture status
  46503. */
  46504. /**
  46505. * Enable or disable the frame time capture
  46506. */
  46507. captureFrameTime: boolean;
  46508. /**
  46509. * Gets the perf counter used for inter-frames time capture
  46510. */
  46511. readonly interFrameTimeCounter: PerfCounter;
  46512. /**
  46513. * Gets the inter-frames time capture status
  46514. */
  46515. /**
  46516. * Enable or disable the inter-frames time capture
  46517. */
  46518. captureInterFrameTime: boolean;
  46519. /**
  46520. * Gets the perf counter used for render time capture
  46521. */
  46522. readonly renderTimeCounter: PerfCounter;
  46523. /**
  46524. * Gets the render time capture status
  46525. */
  46526. /**
  46527. * Enable or disable the render time capture
  46528. */
  46529. captureRenderTime: boolean;
  46530. /**
  46531. * Gets the perf counter used for camera render time capture
  46532. */
  46533. readonly cameraRenderTimeCounter: PerfCounter;
  46534. /**
  46535. * Gets the camera render time capture status
  46536. */
  46537. /**
  46538. * Enable or disable the camera render time capture
  46539. */
  46540. captureCameraRenderTime: boolean;
  46541. /**
  46542. * Gets the perf counter used for draw calls
  46543. */
  46544. readonly drawCallsCounter: PerfCounter;
  46545. /**
  46546. * Gets the perf counter used for texture collisions
  46547. */
  46548. readonly textureCollisionsCounter: PerfCounter;
  46549. /**
  46550. * Instantiates a new scene instrumentation.
  46551. * This class can be used to get instrumentation data from a Babylon engine
  46552. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46553. * @param scene Defines the scene to instrument
  46554. */
  46555. constructor(
  46556. /**
  46557. * Defines the scene to instrument
  46558. */
  46559. scene: Scene);
  46560. /**
  46561. * Dispose and release associated resources.
  46562. */
  46563. dispose(): void;
  46564. }
  46565. }
  46566. declare module "babylonjs/Instrumentation/index" {
  46567. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46568. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46569. export * from "babylonjs/Instrumentation/timeToken";
  46570. }
  46571. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46572. /** @hidden */
  46573. export var glowMapGenerationPixelShader: {
  46574. name: string;
  46575. shader: string;
  46576. };
  46577. }
  46578. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46579. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46580. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46581. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46582. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46583. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46584. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46585. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46586. /** @hidden */
  46587. export var glowMapGenerationVertexShader: {
  46588. name: string;
  46589. shader: string;
  46590. };
  46591. }
  46592. declare module "babylonjs/Layers/effectLayer" {
  46593. import { Observable } from "babylonjs/Misc/observable";
  46594. import { Nullable } from "babylonjs/types";
  46595. import { Camera } from "babylonjs/Cameras/camera";
  46596. import { Scene } from "babylonjs/scene";
  46597. import { Color4, ISize } from "babylonjs/Maths/math";
  46598. import { Engine } from "babylonjs/Engines/engine";
  46599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46601. import { Mesh } from "babylonjs/Meshes/mesh";
  46602. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46605. import { Effect } from "babylonjs/Materials/effect";
  46606. import { Material } from "babylonjs/Materials/material";
  46607. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46608. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46609. /**
  46610. * Effect layer options. This helps customizing the behaviour
  46611. * of the effect layer.
  46612. */
  46613. export interface IEffectLayerOptions {
  46614. /**
  46615. * Multiplication factor apply to the canvas size to compute the render target size
  46616. * used to generated the objects (the smaller the faster).
  46617. */
  46618. mainTextureRatio: number;
  46619. /**
  46620. * Enforces a fixed size texture to ensure effect stability across devices.
  46621. */
  46622. mainTextureFixedSize?: number;
  46623. /**
  46624. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46625. */
  46626. alphaBlendingMode: number;
  46627. /**
  46628. * The camera attached to the layer.
  46629. */
  46630. camera: Nullable<Camera>;
  46631. /**
  46632. * The rendering group to draw the layer in.
  46633. */
  46634. renderingGroupId: number;
  46635. }
  46636. /**
  46637. * The effect layer Helps adding post process effect blended with the main pass.
  46638. *
  46639. * This can be for instance use to generate glow or higlight effects on the scene.
  46640. *
  46641. * The effect layer class can not be used directly and is intented to inherited from to be
  46642. * customized per effects.
  46643. */
  46644. export abstract class EffectLayer {
  46645. private _vertexBuffers;
  46646. private _indexBuffer;
  46647. private _cachedDefines;
  46648. private _effectLayerMapGenerationEffect;
  46649. private _effectLayerOptions;
  46650. private _mergeEffect;
  46651. protected _scene: Scene;
  46652. protected _engine: Engine;
  46653. protected _maxSize: number;
  46654. protected _mainTextureDesiredSize: ISize;
  46655. protected _mainTexture: RenderTargetTexture;
  46656. protected _shouldRender: boolean;
  46657. protected _postProcesses: PostProcess[];
  46658. protected _textures: BaseTexture[];
  46659. protected _emissiveTextureAndColor: {
  46660. texture: Nullable<BaseTexture>;
  46661. color: Color4;
  46662. };
  46663. /**
  46664. * The name of the layer
  46665. */
  46666. name: string;
  46667. /**
  46668. * The clear color of the texture used to generate the glow map.
  46669. */
  46670. neutralColor: Color4;
  46671. /**
  46672. * Specifies wether the highlight layer is enabled or not.
  46673. */
  46674. isEnabled: boolean;
  46675. /**
  46676. * Gets the camera attached to the layer.
  46677. */
  46678. readonly camera: Nullable<Camera>;
  46679. /**
  46680. * Gets the rendering group id the layer should render in.
  46681. */
  46682. readonly renderingGroupId: number;
  46683. /**
  46684. * An event triggered when the effect layer has been disposed.
  46685. */
  46686. onDisposeObservable: Observable<EffectLayer>;
  46687. /**
  46688. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46689. */
  46690. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46691. /**
  46692. * An event triggered when the generated texture is being merged in the scene.
  46693. */
  46694. onBeforeComposeObservable: Observable<EffectLayer>;
  46695. /**
  46696. * An event triggered when the generated texture has been merged in the scene.
  46697. */
  46698. onAfterComposeObservable: Observable<EffectLayer>;
  46699. /**
  46700. * An event triggered when the efffect layer changes its size.
  46701. */
  46702. onSizeChangedObservable: Observable<EffectLayer>;
  46703. /** @hidden */
  46704. static _SceneComponentInitialization: (scene: Scene) => void;
  46705. /**
  46706. * Instantiates a new effect Layer and references it in the scene.
  46707. * @param name The name of the layer
  46708. * @param scene The scene to use the layer in
  46709. */
  46710. constructor(
  46711. /** The Friendly of the effect in the scene */
  46712. name: string, scene: Scene);
  46713. /**
  46714. * Get the effect name of the layer.
  46715. * @return The effect name
  46716. */
  46717. abstract getEffectName(): string;
  46718. /**
  46719. * Checks for the readiness of the element composing the layer.
  46720. * @param subMesh the mesh to check for
  46721. * @param useInstances specify wether or not to use instances to render the mesh
  46722. * @return true if ready otherwise, false
  46723. */
  46724. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46725. /**
  46726. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46727. * @returns true if the effect requires stencil during the main canvas render pass.
  46728. */
  46729. abstract needStencil(): boolean;
  46730. /**
  46731. * Create the merge effect. This is the shader use to blit the information back
  46732. * to the main canvas at the end of the scene rendering.
  46733. * @returns The effect containing the shader used to merge the effect on the main canvas
  46734. */
  46735. protected abstract _createMergeEffect(): Effect;
  46736. /**
  46737. * Creates the render target textures and post processes used in the effect layer.
  46738. */
  46739. protected abstract _createTextureAndPostProcesses(): void;
  46740. /**
  46741. * Implementation specific of rendering the generating effect on the main canvas.
  46742. * @param effect The effect used to render through
  46743. */
  46744. protected abstract _internalRender(effect: Effect): void;
  46745. /**
  46746. * Sets the required values for both the emissive texture and and the main color.
  46747. */
  46748. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46749. /**
  46750. * Free any resources and references associated to a mesh.
  46751. * Internal use
  46752. * @param mesh The mesh to free.
  46753. */
  46754. abstract _disposeMesh(mesh: Mesh): void;
  46755. /**
  46756. * Serializes this layer (Glow or Highlight for example)
  46757. * @returns a serialized layer object
  46758. */
  46759. abstract serialize?(): any;
  46760. /**
  46761. * Initializes the effect layer with the required options.
  46762. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46763. */
  46764. protected _init(options: Partial<IEffectLayerOptions>): void;
  46765. /**
  46766. * Generates the index buffer of the full screen quad blending to the main canvas.
  46767. */
  46768. private _generateIndexBuffer;
  46769. /**
  46770. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46771. */
  46772. private _genrateVertexBuffer;
  46773. /**
  46774. * Sets the main texture desired size which is the closest power of two
  46775. * of the engine canvas size.
  46776. */
  46777. private _setMainTextureSize;
  46778. /**
  46779. * Creates the main texture for the effect layer.
  46780. */
  46781. protected _createMainTexture(): void;
  46782. /**
  46783. * Adds specific effects defines.
  46784. * @param defines The defines to add specifics to.
  46785. */
  46786. protected _addCustomEffectDefines(defines: string[]): void;
  46787. /**
  46788. * Checks for the readiness of the element composing the layer.
  46789. * @param subMesh the mesh to check for
  46790. * @param useInstances specify wether or not to use instances to render the mesh
  46791. * @param emissiveTexture the associated emissive texture used to generate the glow
  46792. * @return true if ready otherwise, false
  46793. */
  46794. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46795. /**
  46796. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46797. */
  46798. render(): void;
  46799. /**
  46800. * Determine if a given mesh will be used in the current effect.
  46801. * @param mesh mesh to test
  46802. * @returns true if the mesh will be used
  46803. */
  46804. hasMesh(mesh: AbstractMesh): boolean;
  46805. /**
  46806. * Returns true if the layer contains information to display, otherwise false.
  46807. * @returns true if the glow layer should be rendered
  46808. */
  46809. shouldRender(): boolean;
  46810. /**
  46811. * Returns true if the mesh should render, otherwise false.
  46812. * @param mesh The mesh to render
  46813. * @returns true if it should render otherwise false
  46814. */
  46815. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46816. /**
  46817. * Returns true if the mesh can be rendered, otherwise false.
  46818. * @param mesh The mesh to render
  46819. * @param material The material used on the mesh
  46820. * @returns true if it can be rendered otherwise false
  46821. */
  46822. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46823. /**
  46824. * Returns true if the mesh should render, otherwise false.
  46825. * @param mesh The mesh to render
  46826. * @returns true if it should render otherwise false
  46827. */
  46828. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46829. /**
  46830. * Renders the submesh passed in parameter to the generation map.
  46831. */
  46832. protected _renderSubMesh(subMesh: SubMesh): void;
  46833. /**
  46834. * Rebuild the required buffers.
  46835. * @hidden Internal use only.
  46836. */
  46837. _rebuild(): void;
  46838. /**
  46839. * Dispose only the render target textures and post process.
  46840. */
  46841. private _disposeTextureAndPostProcesses;
  46842. /**
  46843. * Dispose the highlight layer and free resources.
  46844. */
  46845. dispose(): void;
  46846. /**
  46847. * Gets the class name of the effect layer
  46848. * @returns the string with the class name of the effect layer
  46849. */
  46850. getClassName(): string;
  46851. /**
  46852. * Creates an effect layer from parsed effect layer data
  46853. * @param parsedEffectLayer defines effect layer data
  46854. * @param scene defines the current scene
  46855. * @param rootUrl defines the root URL containing the effect layer information
  46856. * @returns a parsed effect Layer
  46857. */
  46858. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46859. }
  46860. }
  46861. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46862. import { Scene } from "babylonjs/scene";
  46863. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46864. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46865. import { AbstractScene } from "babylonjs/abstractScene";
  46866. module "babylonjs/abstractScene" {
  46867. interface AbstractScene {
  46868. /**
  46869. * The list of effect layers (highlights/glow) added to the scene
  46870. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46871. * @see http://doc.babylonjs.com/how_to/glow_layer
  46872. */
  46873. effectLayers: Array<EffectLayer>;
  46874. /**
  46875. * Removes the given effect layer from this scene.
  46876. * @param toRemove defines the effect layer to remove
  46877. * @returns the index of the removed effect layer
  46878. */
  46879. removeEffectLayer(toRemove: EffectLayer): number;
  46880. /**
  46881. * Adds the given effect layer to this scene
  46882. * @param newEffectLayer defines the effect layer to add
  46883. */
  46884. addEffectLayer(newEffectLayer: EffectLayer): void;
  46885. }
  46886. }
  46887. /**
  46888. * Defines the layer scene component responsible to manage any effect layers
  46889. * in a given scene.
  46890. */
  46891. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46892. /**
  46893. * The component name helpfull to identify the component in the list of scene components.
  46894. */
  46895. readonly name: string;
  46896. /**
  46897. * The scene the component belongs to.
  46898. */
  46899. scene: Scene;
  46900. private _engine;
  46901. private _renderEffects;
  46902. private _needStencil;
  46903. private _previousStencilState;
  46904. /**
  46905. * Creates a new instance of the component for the given scene
  46906. * @param scene Defines the scene to register the component in
  46907. */
  46908. constructor(scene: Scene);
  46909. /**
  46910. * Registers the component in a given scene
  46911. */
  46912. register(): void;
  46913. /**
  46914. * Rebuilds the elements related to this component in case of
  46915. * context lost for instance.
  46916. */
  46917. rebuild(): void;
  46918. /**
  46919. * Serializes the component data to the specified json object
  46920. * @param serializationObject The object to serialize to
  46921. */
  46922. serialize(serializationObject: any): void;
  46923. /**
  46924. * Adds all the element from the container to the scene
  46925. * @param container the container holding the elements
  46926. */
  46927. addFromContainer(container: AbstractScene): void;
  46928. /**
  46929. * Removes all the elements in the container from the scene
  46930. * @param container contains the elements to remove
  46931. */
  46932. removeFromContainer(container: AbstractScene): void;
  46933. /**
  46934. * Disposes the component and the associated ressources.
  46935. */
  46936. dispose(): void;
  46937. private _isReadyForMesh;
  46938. private _renderMainTexture;
  46939. private _setStencil;
  46940. private _setStencilBack;
  46941. private _draw;
  46942. private _drawCamera;
  46943. private _drawRenderingGroup;
  46944. }
  46945. }
  46946. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46947. /** @hidden */
  46948. export var glowMapMergePixelShader: {
  46949. name: string;
  46950. shader: string;
  46951. };
  46952. }
  46953. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46954. /** @hidden */
  46955. export var glowMapMergeVertexShader: {
  46956. name: string;
  46957. shader: string;
  46958. };
  46959. }
  46960. declare module "babylonjs/Layers/glowLayer" {
  46961. import { Nullable } from "babylonjs/types";
  46962. import { Camera } from "babylonjs/Cameras/camera";
  46963. import { Scene } from "babylonjs/scene";
  46964. import { Color4 } from "babylonjs/Maths/math";
  46965. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46967. import { Mesh } from "babylonjs/Meshes/mesh";
  46968. import { Texture } from "babylonjs/Materials/Textures/texture";
  46969. import { Effect } from "babylonjs/Materials/effect";
  46970. import { Material } from "babylonjs/Materials/material";
  46971. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46972. import "babylonjs/Shaders/glowMapMerge.fragment";
  46973. import "babylonjs/Shaders/glowMapMerge.vertex";
  46974. import "babylonjs/Layers/effectLayerSceneComponent";
  46975. module "babylonjs/abstractScene" {
  46976. interface AbstractScene {
  46977. /**
  46978. * Return a the first highlight layer of the scene with a given name.
  46979. * @param name The name of the highlight layer to look for.
  46980. * @return The highlight layer if found otherwise null.
  46981. */
  46982. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46983. }
  46984. }
  46985. /**
  46986. * Glow layer options. This helps customizing the behaviour
  46987. * of the glow layer.
  46988. */
  46989. export interface IGlowLayerOptions {
  46990. /**
  46991. * Multiplication factor apply to the canvas size to compute the render target size
  46992. * used to generated the glowing objects (the smaller the faster).
  46993. */
  46994. mainTextureRatio: number;
  46995. /**
  46996. * Enforces a fixed size texture to ensure resize independant blur.
  46997. */
  46998. mainTextureFixedSize?: number;
  46999. /**
  47000. * How big is the kernel of the blur texture.
  47001. */
  47002. blurKernelSize: number;
  47003. /**
  47004. * The camera attached to the layer.
  47005. */
  47006. camera: Nullable<Camera>;
  47007. /**
  47008. * Enable MSAA by chosing the number of samples.
  47009. */
  47010. mainTextureSamples?: number;
  47011. /**
  47012. * The rendering group to draw the layer in.
  47013. */
  47014. renderingGroupId: number;
  47015. }
  47016. /**
  47017. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47018. *
  47019. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47020. * glowy meshes to your scene.
  47021. *
  47022. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47023. */
  47024. export class GlowLayer extends EffectLayer {
  47025. /**
  47026. * Effect Name of the layer.
  47027. */
  47028. static readonly EffectName: string;
  47029. /**
  47030. * The default blur kernel size used for the glow.
  47031. */
  47032. static DefaultBlurKernelSize: number;
  47033. /**
  47034. * The default texture size ratio used for the glow.
  47035. */
  47036. static DefaultTextureRatio: number;
  47037. /**
  47038. * Sets the kernel size of the blur.
  47039. */
  47040. /**
  47041. * Gets the kernel size of the blur.
  47042. */
  47043. blurKernelSize: number;
  47044. /**
  47045. * Sets the glow intensity.
  47046. */
  47047. /**
  47048. * Gets the glow intensity.
  47049. */
  47050. intensity: number;
  47051. private _options;
  47052. private _intensity;
  47053. private _horizontalBlurPostprocess1;
  47054. private _verticalBlurPostprocess1;
  47055. private _horizontalBlurPostprocess2;
  47056. private _verticalBlurPostprocess2;
  47057. private _blurTexture1;
  47058. private _blurTexture2;
  47059. private _postProcesses1;
  47060. private _postProcesses2;
  47061. private _includedOnlyMeshes;
  47062. private _excludedMeshes;
  47063. /**
  47064. * Callback used to let the user override the color selection on a per mesh basis
  47065. */
  47066. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47067. /**
  47068. * Callback used to let the user override the texture selection on a per mesh basis
  47069. */
  47070. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47071. /**
  47072. * Instantiates a new glow Layer and references it to the scene.
  47073. * @param name The name of the layer
  47074. * @param scene The scene to use the layer in
  47075. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47076. */
  47077. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47078. /**
  47079. * Get the effect name of the layer.
  47080. * @return The effect name
  47081. */
  47082. getEffectName(): string;
  47083. /**
  47084. * Create the merge effect. This is the shader use to blit the information back
  47085. * to the main canvas at the end of the scene rendering.
  47086. */
  47087. protected _createMergeEffect(): Effect;
  47088. /**
  47089. * Creates the render target textures and post processes used in the glow layer.
  47090. */
  47091. protected _createTextureAndPostProcesses(): void;
  47092. /**
  47093. * Checks for the readiness of the element composing the layer.
  47094. * @param subMesh the mesh to check for
  47095. * @param useInstances specify wether or not to use instances to render the mesh
  47096. * @param emissiveTexture the associated emissive texture used to generate the glow
  47097. * @return true if ready otherwise, false
  47098. */
  47099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47100. /**
  47101. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47102. */
  47103. needStencil(): boolean;
  47104. /**
  47105. * Returns true if the mesh can be rendered, otherwise false.
  47106. * @param mesh The mesh to render
  47107. * @param material The material used on the mesh
  47108. * @returns true if it can be rendered otherwise false
  47109. */
  47110. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47111. /**
  47112. * Implementation specific of rendering the generating effect on the main canvas.
  47113. * @param effect The effect used to render through
  47114. */
  47115. protected _internalRender(effect: Effect): void;
  47116. /**
  47117. * Sets the required values for both the emissive texture and and the main color.
  47118. */
  47119. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47120. /**
  47121. * Returns true if the mesh should render, otherwise false.
  47122. * @param mesh The mesh to render
  47123. * @returns true if it should render otherwise false
  47124. */
  47125. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47126. /**
  47127. * Adds specific effects defines.
  47128. * @param defines The defines to add specifics to.
  47129. */
  47130. protected _addCustomEffectDefines(defines: string[]): void;
  47131. /**
  47132. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47133. * @param mesh The mesh to exclude from the glow layer
  47134. */
  47135. addExcludedMesh(mesh: Mesh): void;
  47136. /**
  47137. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47138. * @param mesh The mesh to remove
  47139. */
  47140. removeExcludedMesh(mesh: Mesh): void;
  47141. /**
  47142. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47143. * @param mesh The mesh to include in the glow layer
  47144. */
  47145. addIncludedOnlyMesh(mesh: Mesh): void;
  47146. /**
  47147. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47148. * @param mesh The mesh to remove
  47149. */
  47150. removeIncludedOnlyMesh(mesh: Mesh): void;
  47151. /**
  47152. * Determine if a given mesh will be used in the glow layer
  47153. * @param mesh The mesh to test
  47154. * @returns true if the mesh will be highlighted by the current glow layer
  47155. */
  47156. hasMesh(mesh: AbstractMesh): boolean;
  47157. /**
  47158. * Free any resources and references associated to a mesh.
  47159. * Internal use
  47160. * @param mesh The mesh to free.
  47161. * @hidden
  47162. */
  47163. _disposeMesh(mesh: Mesh): void;
  47164. /**
  47165. * Gets the class name of the effect layer
  47166. * @returns the string with the class name of the effect layer
  47167. */
  47168. getClassName(): string;
  47169. /**
  47170. * Serializes this glow layer
  47171. * @returns a serialized glow layer object
  47172. */
  47173. serialize(): any;
  47174. /**
  47175. * Creates a Glow Layer from parsed glow layer data
  47176. * @param parsedGlowLayer defines glow layer data
  47177. * @param scene defines the current scene
  47178. * @param rootUrl defines the root URL containing the glow layer information
  47179. * @returns a parsed Glow Layer
  47180. */
  47181. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47182. }
  47183. }
  47184. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47185. /** @hidden */
  47186. export var glowBlurPostProcessPixelShader: {
  47187. name: string;
  47188. shader: string;
  47189. };
  47190. }
  47191. declare module "babylonjs/Layers/highlightLayer" {
  47192. import { Observable } from "babylonjs/Misc/observable";
  47193. import { Nullable } from "babylonjs/types";
  47194. import { Camera } from "babylonjs/Cameras/camera";
  47195. import { Scene } from "babylonjs/scene";
  47196. import { Color3, Color4 } from "babylonjs/Maths/math";
  47197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47199. import { Mesh } from "babylonjs/Meshes/mesh";
  47200. import { Effect } from "babylonjs/Materials/effect";
  47201. import { Material } from "babylonjs/Materials/material";
  47202. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47203. import "babylonjs/Shaders/glowMapMerge.fragment";
  47204. import "babylonjs/Shaders/glowMapMerge.vertex";
  47205. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47206. module "babylonjs/abstractScene" {
  47207. interface AbstractScene {
  47208. /**
  47209. * Return a the first highlight layer of the scene with a given name.
  47210. * @param name The name of the highlight layer to look for.
  47211. * @return The highlight layer if found otherwise null.
  47212. */
  47213. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47214. }
  47215. }
  47216. /**
  47217. * Highlight layer options. This helps customizing the behaviour
  47218. * of the highlight layer.
  47219. */
  47220. export interface IHighlightLayerOptions {
  47221. /**
  47222. * Multiplication factor apply to the canvas size to compute the render target size
  47223. * used to generated the glowing objects (the smaller the faster).
  47224. */
  47225. mainTextureRatio: number;
  47226. /**
  47227. * Enforces a fixed size texture to ensure resize independant blur.
  47228. */
  47229. mainTextureFixedSize?: number;
  47230. /**
  47231. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47232. * of the picture to blur (the smaller the faster).
  47233. */
  47234. blurTextureSizeRatio: number;
  47235. /**
  47236. * How big in texel of the blur texture is the vertical blur.
  47237. */
  47238. blurVerticalSize: number;
  47239. /**
  47240. * How big in texel of the blur texture is the horizontal blur.
  47241. */
  47242. blurHorizontalSize: number;
  47243. /**
  47244. * Alpha blending mode used to apply the blur. Default is combine.
  47245. */
  47246. alphaBlendingMode: number;
  47247. /**
  47248. * The camera attached to the layer.
  47249. */
  47250. camera: Nullable<Camera>;
  47251. /**
  47252. * Should we display highlight as a solid stroke?
  47253. */
  47254. isStroke?: boolean;
  47255. /**
  47256. * The rendering group to draw the layer in.
  47257. */
  47258. renderingGroupId: number;
  47259. }
  47260. /**
  47261. * The highlight layer Helps adding a glow effect around a mesh.
  47262. *
  47263. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47264. * glowy meshes to your scene.
  47265. *
  47266. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47267. */
  47268. export class HighlightLayer extends EffectLayer {
  47269. name: string;
  47270. /**
  47271. * Effect Name of the highlight layer.
  47272. */
  47273. static readonly EffectName: string;
  47274. /**
  47275. * The neutral color used during the preparation of the glow effect.
  47276. * This is black by default as the blend operation is a blend operation.
  47277. */
  47278. static NeutralColor: Color4;
  47279. /**
  47280. * Stencil value used for glowing meshes.
  47281. */
  47282. static GlowingMeshStencilReference: number;
  47283. /**
  47284. * Stencil value used for the other meshes in the scene.
  47285. */
  47286. static NormalMeshStencilReference: number;
  47287. /**
  47288. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47289. */
  47290. innerGlow: boolean;
  47291. /**
  47292. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47293. */
  47294. outerGlow: boolean;
  47295. /**
  47296. * Specifies the horizontal size of the blur.
  47297. */
  47298. /**
  47299. * Gets the horizontal size of the blur.
  47300. */
  47301. blurHorizontalSize: number;
  47302. /**
  47303. * Specifies the vertical size of the blur.
  47304. */
  47305. /**
  47306. * Gets the vertical size of the blur.
  47307. */
  47308. blurVerticalSize: number;
  47309. /**
  47310. * An event triggered when the highlight layer is being blurred.
  47311. */
  47312. onBeforeBlurObservable: Observable<HighlightLayer>;
  47313. /**
  47314. * An event triggered when the highlight layer has been blurred.
  47315. */
  47316. onAfterBlurObservable: Observable<HighlightLayer>;
  47317. private _instanceGlowingMeshStencilReference;
  47318. private _options;
  47319. private _downSamplePostprocess;
  47320. private _horizontalBlurPostprocess;
  47321. private _verticalBlurPostprocess;
  47322. private _blurTexture;
  47323. private _meshes;
  47324. private _excludedMeshes;
  47325. /**
  47326. * Instantiates a new highlight Layer and references it to the scene..
  47327. * @param name The name of the layer
  47328. * @param scene The scene to use the layer in
  47329. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47330. */
  47331. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47332. /**
  47333. * Get the effect name of the layer.
  47334. * @return The effect name
  47335. */
  47336. getEffectName(): string;
  47337. /**
  47338. * Create the merge effect. This is the shader use to blit the information back
  47339. * to the main canvas at the end of the scene rendering.
  47340. */
  47341. protected _createMergeEffect(): Effect;
  47342. /**
  47343. * Creates the render target textures and post processes used in the highlight layer.
  47344. */
  47345. protected _createTextureAndPostProcesses(): void;
  47346. /**
  47347. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47348. */
  47349. needStencil(): boolean;
  47350. /**
  47351. * Checks for the readiness of the element composing the layer.
  47352. * @param subMesh the mesh to check for
  47353. * @param useInstances specify wether or not to use instances to render the mesh
  47354. * @param emissiveTexture the associated emissive texture used to generate the glow
  47355. * @return true if ready otherwise, false
  47356. */
  47357. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47358. /**
  47359. * Implementation specific of rendering the generating effect on the main canvas.
  47360. * @param effect The effect used to render through
  47361. */
  47362. protected _internalRender(effect: Effect): void;
  47363. /**
  47364. * Returns true if the layer contains information to display, otherwise false.
  47365. */
  47366. shouldRender(): boolean;
  47367. /**
  47368. * Returns true if the mesh should render, otherwise false.
  47369. * @param mesh The mesh to render
  47370. * @returns true if it should render otherwise false
  47371. */
  47372. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47373. /**
  47374. * Sets the required values for both the emissive texture and and the main color.
  47375. */
  47376. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47377. /**
  47378. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47379. * @param mesh The mesh to exclude from the highlight layer
  47380. */
  47381. addExcludedMesh(mesh: Mesh): void;
  47382. /**
  47383. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47384. * @param mesh The mesh to highlight
  47385. */
  47386. removeExcludedMesh(mesh: Mesh): void;
  47387. /**
  47388. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47389. * @param mesh mesh to test
  47390. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47391. */
  47392. hasMesh(mesh: AbstractMesh): boolean;
  47393. /**
  47394. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47395. * @param mesh The mesh to highlight
  47396. * @param color The color of the highlight
  47397. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47398. */
  47399. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47400. /**
  47401. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47402. * @param mesh The mesh to highlight
  47403. */
  47404. removeMesh(mesh: Mesh): void;
  47405. /**
  47406. * Force the stencil to the normal expected value for none glowing parts
  47407. */
  47408. private _defaultStencilReference;
  47409. /**
  47410. * Free any resources and references associated to a mesh.
  47411. * Internal use
  47412. * @param mesh The mesh to free.
  47413. * @hidden
  47414. */
  47415. _disposeMesh(mesh: Mesh): void;
  47416. /**
  47417. * Dispose the highlight layer and free resources.
  47418. */
  47419. dispose(): void;
  47420. /**
  47421. * Gets the class name of the effect layer
  47422. * @returns the string with the class name of the effect layer
  47423. */
  47424. getClassName(): string;
  47425. /**
  47426. * Serializes this Highlight layer
  47427. * @returns a serialized Highlight layer object
  47428. */
  47429. serialize(): any;
  47430. /**
  47431. * Creates a Highlight layer from parsed Highlight layer data
  47432. * @param parsedHightlightLayer defines the Highlight layer data
  47433. * @param scene defines the current scene
  47434. * @param rootUrl defines the root URL containing the Highlight layer information
  47435. * @returns a parsed Highlight layer
  47436. */
  47437. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47438. }
  47439. }
  47440. declare module "babylonjs/Layers/index" {
  47441. export * from "babylonjs/Layers/effectLayer";
  47442. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47443. export * from "babylonjs/Layers/glowLayer";
  47444. export * from "babylonjs/Layers/highlightLayer";
  47445. export * from "babylonjs/Layers/layer";
  47446. export * from "babylonjs/Layers/layerSceneComponent";
  47447. }
  47448. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47449. /** @hidden */
  47450. export var lensFlarePixelShader: {
  47451. name: string;
  47452. shader: string;
  47453. };
  47454. }
  47455. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47456. /** @hidden */
  47457. export var lensFlareVertexShader: {
  47458. name: string;
  47459. shader: string;
  47460. };
  47461. }
  47462. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47463. import { Scene } from "babylonjs/scene";
  47464. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47466. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47467. import "babylonjs/Shaders/lensFlare.fragment";
  47468. import "babylonjs/Shaders/lensFlare.vertex";
  47469. /**
  47470. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47471. * It is usually composed of several `lensFlare`.
  47472. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47473. */
  47474. export class LensFlareSystem {
  47475. /**
  47476. * Define the name of the lens flare system
  47477. */
  47478. name: string;
  47479. /**
  47480. * List of lens flares used in this system.
  47481. */
  47482. lensFlares: LensFlare[];
  47483. /**
  47484. * Define a limit from the border the lens flare can be visible.
  47485. */
  47486. borderLimit: number;
  47487. /**
  47488. * Define a viewport border we do not want to see the lens flare in.
  47489. */
  47490. viewportBorder: number;
  47491. /**
  47492. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47493. */
  47494. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47495. /**
  47496. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47497. */
  47498. layerMask: number;
  47499. /**
  47500. * Define the id of the lens flare system in the scene.
  47501. * (equal to name by default)
  47502. */
  47503. id: string;
  47504. private _scene;
  47505. private _emitter;
  47506. private _vertexBuffers;
  47507. private _indexBuffer;
  47508. private _effect;
  47509. private _positionX;
  47510. private _positionY;
  47511. private _isEnabled;
  47512. /** @hidden */
  47513. static _SceneComponentInitialization: (scene: Scene) => void;
  47514. /**
  47515. * Instantiates a lens flare system.
  47516. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47517. * It is usually composed of several `lensFlare`.
  47518. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47519. * @param name Define the name of the lens flare system in the scene
  47520. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47521. * @param scene Define the scene the lens flare system belongs to
  47522. */
  47523. constructor(
  47524. /**
  47525. * Define the name of the lens flare system
  47526. */
  47527. name: string, emitter: any, scene: Scene);
  47528. /**
  47529. * Define if the lens flare system is enabled.
  47530. */
  47531. isEnabled: boolean;
  47532. /**
  47533. * Get the scene the effects belongs to.
  47534. * @returns the scene holding the lens flare system
  47535. */
  47536. getScene(): Scene;
  47537. /**
  47538. * Get the emitter of the lens flare system.
  47539. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47540. * @returns the emitter of the lens flare system
  47541. */
  47542. getEmitter(): any;
  47543. /**
  47544. * Set the emitter of the lens flare system.
  47545. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47546. * @param newEmitter Define the new emitter of the system
  47547. */
  47548. setEmitter(newEmitter: any): void;
  47549. /**
  47550. * Get the lens flare system emitter position.
  47551. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47552. * @returns the position
  47553. */
  47554. getEmitterPosition(): Vector3;
  47555. /**
  47556. * @hidden
  47557. */
  47558. computeEffectivePosition(globalViewport: Viewport): boolean;
  47559. /** @hidden */
  47560. _isVisible(): boolean;
  47561. /**
  47562. * @hidden
  47563. */
  47564. render(): boolean;
  47565. /**
  47566. * Dispose and release the lens flare with its associated resources.
  47567. */
  47568. dispose(): void;
  47569. /**
  47570. * Parse a lens flare system from a JSON repressentation
  47571. * @param parsedLensFlareSystem Define the JSON to parse
  47572. * @param scene Define the scene the parsed system should be instantiated in
  47573. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47574. * @returns the parsed system
  47575. */
  47576. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47577. /**
  47578. * Serialize the current Lens Flare System into a JSON representation.
  47579. * @returns the serialized JSON
  47580. */
  47581. serialize(): any;
  47582. }
  47583. }
  47584. declare module "babylonjs/LensFlares/lensFlare" {
  47585. import { Nullable } from "babylonjs/types";
  47586. import { Color3 } from "babylonjs/Maths/math";
  47587. import { Texture } from "babylonjs/Materials/Textures/texture";
  47588. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47589. /**
  47590. * This represents one of the lens effect in a `lensFlareSystem`.
  47591. * It controls one of the indiviual texture used in the effect.
  47592. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47593. */
  47594. export class LensFlare {
  47595. /**
  47596. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47597. */
  47598. size: number;
  47599. /**
  47600. * 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.
  47601. */
  47602. position: number;
  47603. /**
  47604. * Define the lens color.
  47605. */
  47606. color: Color3;
  47607. /**
  47608. * Define the lens texture.
  47609. */
  47610. texture: Nullable<Texture>;
  47611. /**
  47612. * Define the alpha mode to render this particular lens.
  47613. */
  47614. alphaMode: number;
  47615. private _system;
  47616. /**
  47617. * Creates a new Lens Flare.
  47618. * This represents one of the lens effect in a `lensFlareSystem`.
  47619. * It controls one of the indiviual texture used in the effect.
  47620. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47621. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47622. * @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.
  47623. * @param color Define the lens color
  47624. * @param imgUrl Define the lens texture url
  47625. * @param system Define the `lensFlareSystem` this flare is part of
  47626. * @returns The newly created Lens Flare
  47627. */
  47628. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47629. /**
  47630. * Instantiates a new Lens Flare.
  47631. * This represents one of the lens effect in a `lensFlareSystem`.
  47632. * It controls one of the indiviual texture used in the effect.
  47633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47634. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47635. * @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.
  47636. * @param color Define the lens color
  47637. * @param imgUrl Define the lens texture url
  47638. * @param system Define the `lensFlareSystem` this flare is part of
  47639. */
  47640. constructor(
  47641. /**
  47642. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47643. */
  47644. size: number,
  47645. /**
  47646. * 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.
  47647. */
  47648. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47649. /**
  47650. * Dispose and release the lens flare with its associated resources.
  47651. */
  47652. dispose(): void;
  47653. }
  47654. }
  47655. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47656. import { Nullable } from "babylonjs/types";
  47657. import { Scene } from "babylonjs/scene";
  47658. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47659. import { AbstractScene } from "babylonjs/abstractScene";
  47660. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47661. module "babylonjs/abstractScene" {
  47662. interface AbstractScene {
  47663. /**
  47664. * The list of lens flare system added to the scene
  47665. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47666. */
  47667. lensFlareSystems: Array<LensFlareSystem>;
  47668. /**
  47669. * Removes the given lens flare system from this scene.
  47670. * @param toRemove The lens flare system to remove
  47671. * @returns The index of the removed lens flare system
  47672. */
  47673. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47674. /**
  47675. * Adds the given lens flare system to this scene
  47676. * @param newLensFlareSystem The lens flare system to add
  47677. */
  47678. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47679. /**
  47680. * Gets a lens flare system using its name
  47681. * @param name defines the name to look for
  47682. * @returns the lens flare system or null if not found
  47683. */
  47684. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47685. /**
  47686. * Gets a lens flare system using its id
  47687. * @param id defines the id to look for
  47688. * @returns the lens flare system or null if not found
  47689. */
  47690. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47691. }
  47692. }
  47693. /**
  47694. * Defines the lens flare scene component responsible to manage any lens flares
  47695. * in a given scene.
  47696. */
  47697. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47698. /**
  47699. * The component name helpfull to identify the component in the list of scene components.
  47700. */
  47701. readonly name: string;
  47702. /**
  47703. * The scene the component belongs to.
  47704. */
  47705. scene: Scene;
  47706. /**
  47707. * Creates a new instance of the component for the given scene
  47708. * @param scene Defines the scene to register the component in
  47709. */
  47710. constructor(scene: Scene);
  47711. /**
  47712. * Registers the component in a given scene
  47713. */
  47714. register(): void;
  47715. /**
  47716. * Rebuilds the elements related to this component in case of
  47717. * context lost for instance.
  47718. */
  47719. rebuild(): void;
  47720. /**
  47721. * Adds all the element from the container to the scene
  47722. * @param container the container holding the elements
  47723. */
  47724. addFromContainer(container: AbstractScene): void;
  47725. /**
  47726. * Removes all the elements in the container from the scene
  47727. * @param container contains the elements to remove
  47728. */
  47729. removeFromContainer(container: AbstractScene): void;
  47730. /**
  47731. * Serializes the component data to the specified json object
  47732. * @param serializationObject The object to serialize to
  47733. */
  47734. serialize(serializationObject: any): void;
  47735. /**
  47736. * Disposes the component and the associated ressources.
  47737. */
  47738. dispose(): void;
  47739. private _draw;
  47740. }
  47741. }
  47742. declare module "babylonjs/LensFlares/index" {
  47743. export * from "babylonjs/LensFlares/lensFlare";
  47744. export * from "babylonjs/LensFlares/lensFlareSystem";
  47745. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47746. }
  47747. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47748. import { Scene } from "babylonjs/scene";
  47749. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47750. import { AbstractScene } from "babylonjs/abstractScene";
  47751. /**
  47752. * Defines the shadow generator component responsible to manage any shadow generators
  47753. * in a given scene.
  47754. */
  47755. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47756. /**
  47757. * The component name helpfull to identify the component in the list of scene components.
  47758. */
  47759. readonly name: string;
  47760. /**
  47761. * The scene the component belongs to.
  47762. */
  47763. scene: Scene;
  47764. /**
  47765. * Creates a new instance of the component for the given scene
  47766. * @param scene Defines the scene to register the component in
  47767. */
  47768. constructor(scene: Scene);
  47769. /**
  47770. * Registers the component in a given scene
  47771. */
  47772. register(): void;
  47773. /**
  47774. * Rebuilds the elements related to this component in case of
  47775. * context lost for instance.
  47776. */
  47777. rebuild(): void;
  47778. /**
  47779. * Serializes the component data to the specified json object
  47780. * @param serializationObject The object to serialize to
  47781. */
  47782. serialize(serializationObject: any): void;
  47783. /**
  47784. * Adds all the element from the container to the scene
  47785. * @param container the container holding the elements
  47786. */
  47787. addFromContainer(container: AbstractScene): void;
  47788. /**
  47789. * Removes all the elements in the container from the scene
  47790. * @param container contains the elements to remove
  47791. */
  47792. removeFromContainer(container: AbstractScene): void;
  47793. /**
  47794. * Rebuilds the elements related to this component in case of
  47795. * context lost for instance.
  47796. */
  47797. dispose(): void;
  47798. private _gatherRenderTargets;
  47799. }
  47800. }
  47801. declare module "babylonjs/Lights/Shadows/index" {
  47802. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47803. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47804. }
  47805. declare module "babylonjs/Lights/directionalLight" {
  47806. import { Camera } from "babylonjs/Cameras/camera";
  47807. import { Scene } from "babylonjs/scene";
  47808. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47810. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47811. import { Effect } from "babylonjs/Materials/effect";
  47812. /**
  47813. * A directional light is defined by a direction (what a surprise!).
  47814. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47815. * 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.
  47816. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47817. */
  47818. export class DirectionalLight extends ShadowLight {
  47819. private _shadowFrustumSize;
  47820. /**
  47821. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47822. */
  47823. /**
  47824. * Specifies a fix frustum size for the shadow generation.
  47825. */
  47826. shadowFrustumSize: number;
  47827. private _shadowOrthoScale;
  47828. /**
  47829. * Gets the shadow projection scale against the optimal computed one.
  47830. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47831. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47832. */
  47833. /**
  47834. * Sets the shadow projection scale against the optimal computed one.
  47835. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47836. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47837. */
  47838. shadowOrthoScale: number;
  47839. /**
  47840. * Automatically compute the projection matrix to best fit (including all the casters)
  47841. * on each frame.
  47842. */
  47843. autoUpdateExtends: boolean;
  47844. private _orthoLeft;
  47845. private _orthoRight;
  47846. private _orthoTop;
  47847. private _orthoBottom;
  47848. /**
  47849. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47850. * The directional light is emitted from everywhere in the given direction.
  47851. * It can cast shadows.
  47852. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47853. * @param name The friendly name of the light
  47854. * @param direction The direction of the light
  47855. * @param scene The scene the light belongs to
  47856. */
  47857. constructor(name: string, direction: Vector3, scene: Scene);
  47858. /**
  47859. * Returns the string "DirectionalLight".
  47860. * @return The class name
  47861. */
  47862. getClassName(): string;
  47863. /**
  47864. * Returns the integer 1.
  47865. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47866. */
  47867. getTypeID(): number;
  47868. /**
  47869. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47870. * Returns the DirectionalLight Shadow projection matrix.
  47871. */
  47872. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47873. /**
  47874. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47875. * Returns the DirectionalLight Shadow projection matrix.
  47876. */
  47877. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47878. /**
  47879. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47880. * Returns the DirectionalLight Shadow projection matrix.
  47881. */
  47882. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47883. protected _buildUniformLayout(): void;
  47884. /**
  47885. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47886. * @param effect The effect to update
  47887. * @param lightIndex The index of the light in the effect to update
  47888. * @returns The directional light
  47889. */
  47890. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47891. /**
  47892. * Gets the minZ used for shadow according to both the scene and the light.
  47893. *
  47894. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47895. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47896. * @param activeCamera The camera we are returning the min for
  47897. * @returns the depth min z
  47898. */
  47899. getDepthMinZ(activeCamera: Camera): number;
  47900. /**
  47901. * Gets the maxZ used for shadow according to both the scene and the light.
  47902. *
  47903. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47904. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47905. * @param activeCamera The camera we are returning the max for
  47906. * @returns the depth max z
  47907. */
  47908. getDepthMaxZ(activeCamera: Camera): number;
  47909. /**
  47910. * Prepares the list of defines specific to the light type.
  47911. * @param defines the list of defines
  47912. * @param lightIndex defines the index of the light for the effect
  47913. */
  47914. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47915. }
  47916. }
  47917. declare module "babylonjs/Lights/pointLight" {
  47918. import { Scene } from "babylonjs/scene";
  47919. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47921. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47922. import { Effect } from "babylonjs/Materials/effect";
  47923. /**
  47924. * A point light is a light defined by an unique point in world space.
  47925. * The light is emitted in every direction from this point.
  47926. * A good example of a point light is a standard light bulb.
  47927. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47928. */
  47929. export class PointLight extends ShadowLight {
  47930. private _shadowAngle;
  47931. /**
  47932. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47933. * This specifies what angle the shadow will use to be created.
  47934. *
  47935. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47936. */
  47937. /**
  47938. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47939. * This specifies what angle the shadow will use to be created.
  47940. *
  47941. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47942. */
  47943. shadowAngle: number;
  47944. /**
  47945. * Gets the direction if it has been set.
  47946. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47947. */
  47948. /**
  47949. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47950. */
  47951. direction: Vector3;
  47952. /**
  47953. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47954. * A PointLight emits the light in every direction.
  47955. * It can cast shadows.
  47956. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47957. * ```javascript
  47958. * var pointLight = new PointLight("pl", camera.position, scene);
  47959. * ```
  47960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47961. * @param name The light friendly name
  47962. * @param position The position of the point light in the scene
  47963. * @param scene The scene the lights belongs to
  47964. */
  47965. constructor(name: string, position: Vector3, scene: Scene);
  47966. /**
  47967. * Returns the string "PointLight"
  47968. * @returns the class name
  47969. */
  47970. getClassName(): string;
  47971. /**
  47972. * Returns the integer 0.
  47973. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47974. */
  47975. getTypeID(): number;
  47976. /**
  47977. * Specifies wether or not the shadowmap should be a cube texture.
  47978. * @returns true if the shadowmap needs to be a cube texture.
  47979. */
  47980. needCube(): boolean;
  47981. /**
  47982. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47983. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47984. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47985. */
  47986. getShadowDirection(faceIndex?: number): Vector3;
  47987. /**
  47988. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47989. * - fov = PI / 2
  47990. * - aspect ratio : 1.0
  47991. * - z-near and far equal to the active camera minZ and maxZ.
  47992. * Returns the PointLight.
  47993. */
  47994. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47995. protected _buildUniformLayout(): void;
  47996. /**
  47997. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47998. * @param effect The effect to update
  47999. * @param lightIndex The index of the light in the effect to update
  48000. * @returns The point light
  48001. */
  48002. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48003. /**
  48004. * Prepares the list of defines specific to the light type.
  48005. * @param defines the list of defines
  48006. * @param lightIndex defines the index of the light for the effect
  48007. */
  48008. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48009. }
  48010. }
  48011. declare module "babylonjs/Lights/spotLight" {
  48012. import { Nullable } from "babylonjs/types";
  48013. import { Scene } from "babylonjs/scene";
  48014. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48016. import { Effect } from "babylonjs/Materials/effect";
  48017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48018. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48019. /**
  48020. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48021. * These values define a cone of light starting from the position, emitting toward the direction.
  48022. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48023. * and the exponent defines the speed of the decay of the light with distance (reach).
  48024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48025. */
  48026. export class SpotLight extends ShadowLight {
  48027. private _angle;
  48028. private _innerAngle;
  48029. private _cosHalfAngle;
  48030. private _lightAngleScale;
  48031. private _lightAngleOffset;
  48032. /**
  48033. * Gets the cone angle of the spot light in Radians.
  48034. */
  48035. /**
  48036. * Sets the cone angle of the spot light in Radians.
  48037. */
  48038. angle: number;
  48039. /**
  48040. * Only used in gltf falloff mode, this defines the angle where
  48041. * the directional falloff will start before cutting at angle which could be seen
  48042. * as outer angle.
  48043. */
  48044. /**
  48045. * Only used in gltf falloff mode, this defines the angle where
  48046. * the directional falloff will start before cutting at angle which could be seen
  48047. * as outer angle.
  48048. */
  48049. innerAngle: number;
  48050. private _shadowAngleScale;
  48051. /**
  48052. * Allows scaling the angle of the light for shadow generation only.
  48053. */
  48054. /**
  48055. * Allows scaling the angle of the light for shadow generation only.
  48056. */
  48057. shadowAngleScale: number;
  48058. /**
  48059. * The light decay speed with the distance from the emission spot.
  48060. */
  48061. exponent: number;
  48062. private _projectionTextureMatrix;
  48063. /**
  48064. * Allows reading the projecton texture
  48065. */
  48066. readonly projectionTextureMatrix: Matrix;
  48067. protected _projectionTextureLightNear: number;
  48068. /**
  48069. * Gets the near clip of the Spotlight for texture projection.
  48070. */
  48071. /**
  48072. * Sets the near clip of the Spotlight for texture projection.
  48073. */
  48074. projectionTextureLightNear: number;
  48075. protected _projectionTextureLightFar: number;
  48076. /**
  48077. * Gets the far clip of the Spotlight for texture projection.
  48078. */
  48079. /**
  48080. * Sets the far clip of the Spotlight for texture projection.
  48081. */
  48082. projectionTextureLightFar: number;
  48083. protected _projectionTextureUpDirection: Vector3;
  48084. /**
  48085. * Gets the Up vector of the Spotlight for texture projection.
  48086. */
  48087. /**
  48088. * Sets the Up vector of the Spotlight for texture projection.
  48089. */
  48090. projectionTextureUpDirection: Vector3;
  48091. private _projectionTexture;
  48092. /**
  48093. * Gets the projection texture of the light.
  48094. */
  48095. /**
  48096. * Sets the projection texture of the light.
  48097. */
  48098. projectionTexture: Nullable<BaseTexture>;
  48099. private _projectionTextureViewLightDirty;
  48100. private _projectionTextureProjectionLightDirty;
  48101. private _projectionTextureDirty;
  48102. private _projectionTextureViewTargetVector;
  48103. private _projectionTextureViewLightMatrix;
  48104. private _projectionTextureProjectionLightMatrix;
  48105. private _projectionTextureScalingMatrix;
  48106. /**
  48107. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48108. * It can cast shadows.
  48109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48110. * @param name The light friendly name
  48111. * @param position The position of the spot light in the scene
  48112. * @param direction The direction of the light in the scene
  48113. * @param angle The cone angle of the light in Radians
  48114. * @param exponent The light decay speed with the distance from the emission spot
  48115. * @param scene The scene the lights belongs to
  48116. */
  48117. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48118. /**
  48119. * Returns the string "SpotLight".
  48120. * @returns the class name
  48121. */
  48122. getClassName(): string;
  48123. /**
  48124. * Returns the integer 2.
  48125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48126. */
  48127. getTypeID(): number;
  48128. /**
  48129. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48130. */
  48131. protected _setDirection(value: Vector3): void;
  48132. /**
  48133. * Overrides the position setter to recompute the projection texture view light Matrix.
  48134. */
  48135. protected _setPosition(value: Vector3): void;
  48136. /**
  48137. * 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.
  48138. * Returns the SpotLight.
  48139. */
  48140. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48141. protected _computeProjectionTextureViewLightMatrix(): void;
  48142. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48143. /**
  48144. * Main function for light texture projection matrix computing.
  48145. */
  48146. protected _computeProjectionTextureMatrix(): void;
  48147. protected _buildUniformLayout(): void;
  48148. private _computeAngleValues;
  48149. /**
  48150. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48151. * @param effect The effect to update
  48152. * @param lightIndex The index of the light in the effect to update
  48153. * @returns The spot light
  48154. */
  48155. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48156. /**
  48157. * Disposes the light and the associated resources.
  48158. */
  48159. dispose(): void;
  48160. /**
  48161. * Prepares the list of defines specific to the light type.
  48162. * @param defines the list of defines
  48163. * @param lightIndex defines the index of the light for the effect
  48164. */
  48165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48166. }
  48167. }
  48168. declare module "babylonjs/Lights/index" {
  48169. export * from "babylonjs/Lights/light";
  48170. export * from "babylonjs/Lights/shadowLight";
  48171. export * from "babylonjs/Lights/Shadows/index";
  48172. export * from "babylonjs/Lights/directionalLight";
  48173. export * from "babylonjs/Lights/hemisphericLight";
  48174. export * from "babylonjs/Lights/pointLight";
  48175. export * from "babylonjs/Lights/spotLight";
  48176. }
  48177. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48178. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48179. /**
  48180. * Header information of HDR texture files.
  48181. */
  48182. export interface HDRInfo {
  48183. /**
  48184. * The height of the texture in pixels.
  48185. */
  48186. height: number;
  48187. /**
  48188. * The width of the texture in pixels.
  48189. */
  48190. width: number;
  48191. /**
  48192. * The index of the beginning of the data in the binary file.
  48193. */
  48194. dataPosition: number;
  48195. }
  48196. /**
  48197. * This groups tools to convert HDR texture to native colors array.
  48198. */
  48199. export class HDRTools {
  48200. private static Ldexp;
  48201. private static Rgbe2float;
  48202. private static readStringLine;
  48203. /**
  48204. * Reads header information from an RGBE texture stored in a native array.
  48205. * More information on this format are available here:
  48206. * https://en.wikipedia.org/wiki/RGBE_image_format
  48207. *
  48208. * @param uint8array The binary file stored in native array.
  48209. * @return The header information.
  48210. */
  48211. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48212. /**
  48213. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48214. * This RGBE texture needs to store the information as a panorama.
  48215. *
  48216. * More information on this format are available here:
  48217. * https://en.wikipedia.org/wiki/RGBE_image_format
  48218. *
  48219. * @param buffer The binary file stored in an array buffer.
  48220. * @param size The expected size of the extracted cubemap.
  48221. * @return The Cube Map information.
  48222. */
  48223. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48224. /**
  48225. * Returns the pixels data extracted from an RGBE texture.
  48226. * This pixels will be stored left to right up to down in the R G B order in one array.
  48227. *
  48228. * More information on this format are available here:
  48229. * https://en.wikipedia.org/wiki/RGBE_image_format
  48230. *
  48231. * @param uint8array The binary file stored in an array buffer.
  48232. * @param hdrInfo The header information of the file.
  48233. * @return The pixels data in RGB right to left up to down order.
  48234. */
  48235. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48236. private static RGBE_ReadPixels_RLE;
  48237. }
  48238. }
  48239. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48240. import { Nullable } from "babylonjs/types";
  48241. import { Scene } from "babylonjs/scene";
  48242. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48244. /**
  48245. * This represents a texture coming from an HDR input.
  48246. *
  48247. * The only supported format is currently panorama picture stored in RGBE format.
  48248. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48249. */
  48250. export class HDRCubeTexture extends BaseTexture {
  48251. private static _facesMapping;
  48252. private _generateHarmonics;
  48253. private _noMipmap;
  48254. private _textureMatrix;
  48255. private _size;
  48256. private _onLoad;
  48257. private _onError;
  48258. /**
  48259. * The texture URL.
  48260. */
  48261. url: string;
  48262. /**
  48263. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48264. */
  48265. coordinatesMode: number;
  48266. protected _isBlocking: boolean;
  48267. /**
  48268. * Sets wether or not the texture is blocking during loading.
  48269. */
  48270. /**
  48271. * Gets wether or not the texture is blocking during loading.
  48272. */
  48273. isBlocking: boolean;
  48274. protected _rotationY: number;
  48275. /**
  48276. * Sets texture matrix rotation angle around Y axis in radians.
  48277. */
  48278. /**
  48279. * Gets texture matrix rotation angle around Y axis radians.
  48280. */
  48281. rotationY: number;
  48282. /**
  48283. * Gets or sets the center of the bounding box associated with the cube texture
  48284. * It must define where the camera used to render the texture was set
  48285. */
  48286. boundingBoxPosition: Vector3;
  48287. private _boundingBoxSize;
  48288. /**
  48289. * Gets or sets the size of the bounding box associated with the cube texture
  48290. * When defined, the cubemap will switch to local mode
  48291. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48292. * @example https://www.babylonjs-playground.com/#RNASML
  48293. */
  48294. boundingBoxSize: Vector3;
  48295. /**
  48296. * Instantiates an HDRTexture from the following parameters.
  48297. *
  48298. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48299. * @param scene The scene the texture will be used in
  48300. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48301. * @param noMipmap Forces to not generate the mipmap if true
  48302. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48303. * @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)
  48304. * @param reserved Reserved flag for internal use.
  48305. */
  48306. 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>);
  48307. /**
  48308. * Get the current class name of the texture useful for serialization or dynamic coding.
  48309. * @returns "HDRCubeTexture"
  48310. */
  48311. getClassName(): string;
  48312. /**
  48313. * Occurs when the file is raw .hdr file.
  48314. */
  48315. private loadTexture;
  48316. clone(): HDRCubeTexture;
  48317. delayLoad(): void;
  48318. /**
  48319. * Get the texture reflection matrix used to rotate/transform the reflection.
  48320. * @returns the reflection matrix
  48321. */
  48322. getReflectionTextureMatrix(): Matrix;
  48323. /**
  48324. * Set the texture reflection matrix used to rotate/transform the reflection.
  48325. * @param value Define the reflection matrix to set
  48326. */
  48327. setReflectionTextureMatrix(value: Matrix): void;
  48328. /**
  48329. * Parses a JSON representation of an HDR Texture in order to create the texture
  48330. * @param parsedTexture Define the JSON representation
  48331. * @param scene Define the scene the texture should be created in
  48332. * @param rootUrl Define the root url in case we need to load relative dependencies
  48333. * @returns the newly created texture after parsing
  48334. */
  48335. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48336. serialize(): any;
  48337. }
  48338. }
  48339. declare module "babylonjs/Physics/physicsEngine" {
  48340. import { Nullable } from "babylonjs/types";
  48341. import { Vector3 } from "babylonjs/Maths/math";
  48342. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48343. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48344. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48345. /**
  48346. * Class used to control physics engine
  48347. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48348. */
  48349. export class PhysicsEngine implements IPhysicsEngine {
  48350. private _physicsPlugin;
  48351. /**
  48352. * Global value used to control the smallest number supported by the simulation
  48353. */
  48354. static Epsilon: number;
  48355. private _impostors;
  48356. private _joints;
  48357. /**
  48358. * Gets the gravity vector used by the simulation
  48359. */
  48360. gravity: Vector3;
  48361. /**
  48362. * Factory used to create the default physics plugin.
  48363. * @returns The default physics plugin
  48364. */
  48365. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48366. /**
  48367. * Creates a new Physics Engine
  48368. * @param gravity defines the gravity vector used by the simulation
  48369. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48370. */
  48371. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48372. /**
  48373. * Sets the gravity vector used by the simulation
  48374. * @param gravity defines the gravity vector to use
  48375. */
  48376. setGravity(gravity: Vector3): void;
  48377. /**
  48378. * Set the time step of the physics engine.
  48379. * Default is 1/60.
  48380. * To slow it down, enter 1/600 for example.
  48381. * To speed it up, 1/30
  48382. * @param newTimeStep defines the new timestep to apply to this world.
  48383. */
  48384. setTimeStep(newTimeStep?: number): void;
  48385. /**
  48386. * Get the time step of the physics engine.
  48387. * @returns the current time step
  48388. */
  48389. getTimeStep(): number;
  48390. /**
  48391. * Release all resources
  48392. */
  48393. dispose(): void;
  48394. /**
  48395. * Gets the name of the current physics plugin
  48396. * @returns the name of the plugin
  48397. */
  48398. getPhysicsPluginName(): string;
  48399. /**
  48400. * Adding a new impostor for the impostor tracking.
  48401. * This will be done by the impostor itself.
  48402. * @param impostor the impostor to add
  48403. */
  48404. addImpostor(impostor: PhysicsImpostor): void;
  48405. /**
  48406. * Remove an impostor from the engine.
  48407. * This impostor and its mesh will not longer be updated by the physics engine.
  48408. * @param impostor the impostor to remove
  48409. */
  48410. removeImpostor(impostor: PhysicsImpostor): void;
  48411. /**
  48412. * Add a joint to the physics engine
  48413. * @param mainImpostor defines the main impostor to which the joint is added.
  48414. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48415. * @param joint defines the joint that will connect both impostors.
  48416. */
  48417. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48418. /**
  48419. * Removes a joint from the simulation
  48420. * @param mainImpostor defines the impostor used with the joint
  48421. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48422. * @param joint defines the joint to remove
  48423. */
  48424. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48425. /**
  48426. * Called by the scene. No need to call it.
  48427. * @param delta defines the timespam between frames
  48428. */
  48429. _step(delta: number): void;
  48430. /**
  48431. * Gets the current plugin used to run the simulation
  48432. * @returns current plugin
  48433. */
  48434. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48435. /**
  48436. * Gets the list of physic impostors
  48437. * @returns an array of PhysicsImpostor
  48438. */
  48439. getImpostors(): Array<PhysicsImpostor>;
  48440. /**
  48441. * Gets the impostor for a physics enabled object
  48442. * @param object defines the object impersonated by the impostor
  48443. * @returns the PhysicsImpostor or null if not found
  48444. */
  48445. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48446. /**
  48447. * Gets the impostor for a physics body object
  48448. * @param body defines physics body used by the impostor
  48449. * @returns the PhysicsImpostor or null if not found
  48450. */
  48451. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48452. }
  48453. }
  48454. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48455. import { Nullable } from "babylonjs/types";
  48456. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48458. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48459. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48460. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48461. /** @hidden */
  48462. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48463. private _useDeltaForWorldStep;
  48464. world: any;
  48465. name: string;
  48466. private _physicsMaterials;
  48467. private _fixedTimeStep;
  48468. BJSCANNON: any;
  48469. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48470. setGravity(gravity: Vector3): void;
  48471. setTimeStep(timeStep: number): void;
  48472. getTimeStep(): number;
  48473. executeStep(delta: number): void;
  48474. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48475. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48476. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48477. private _processChildMeshes;
  48478. removePhysicsBody(impostor: PhysicsImpostor): void;
  48479. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48480. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48481. private _addMaterial;
  48482. private _checkWithEpsilon;
  48483. private _createShape;
  48484. private _createHeightmap;
  48485. private _minus90X;
  48486. private _plus90X;
  48487. private _tmpPosition;
  48488. private _tmpDeltaPosition;
  48489. private _tmpUnityRotation;
  48490. private _updatePhysicsBodyTransformation;
  48491. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48492. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48493. isSupported(): boolean;
  48494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48495. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48496. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48497. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48498. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48499. getBodyMass(impostor: PhysicsImpostor): number;
  48500. getBodyFriction(impostor: PhysicsImpostor): number;
  48501. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48502. getBodyRestitution(impostor: PhysicsImpostor): number;
  48503. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48504. sleepBody(impostor: PhysicsImpostor): void;
  48505. wakeUpBody(impostor: PhysicsImpostor): void;
  48506. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48507. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48508. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48509. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48510. getRadius(impostor: PhysicsImpostor): number;
  48511. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48512. dispose(): void;
  48513. private _extendNamespace;
  48514. }
  48515. }
  48516. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48517. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48518. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48519. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48521. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48522. import { Nullable } from "babylonjs/types";
  48523. /** @hidden */
  48524. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48525. world: any;
  48526. name: string;
  48527. BJSOIMO: any;
  48528. constructor(iterations?: number, oimoInjection?: any);
  48529. setGravity(gravity: Vector3): void;
  48530. setTimeStep(timeStep: number): void;
  48531. getTimeStep(): number;
  48532. private _tmpImpostorsArray;
  48533. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48537. private _tmpPositionVector;
  48538. removePhysicsBody(impostor: PhysicsImpostor): void;
  48539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48540. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48541. isSupported(): boolean;
  48542. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48544. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48545. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48546. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48547. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48548. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48549. getBodyMass(impostor: PhysicsImpostor): number;
  48550. getBodyFriction(impostor: PhysicsImpostor): number;
  48551. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48552. getBodyRestitution(impostor: PhysicsImpostor): number;
  48553. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48554. sleepBody(impostor: PhysicsImpostor): void;
  48555. wakeUpBody(impostor: PhysicsImpostor): void;
  48556. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48557. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48558. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48559. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48560. getRadius(impostor: PhysicsImpostor): number;
  48561. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48562. dispose(): void;
  48563. }
  48564. }
  48565. declare module "babylonjs/Probes/reflectionProbe" {
  48566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48567. import { Vector3 } from "babylonjs/Maths/math";
  48568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48569. import { Nullable } from "babylonjs/types";
  48570. import { Scene } from "babylonjs/scene";
  48571. module "babylonjs/abstractScene" {
  48572. interface AbstractScene {
  48573. /**
  48574. * The list of reflection probes added to the scene
  48575. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48576. */
  48577. reflectionProbes: Array<ReflectionProbe>;
  48578. /**
  48579. * Removes the given reflection probe from this scene.
  48580. * @param toRemove The reflection probe to remove
  48581. * @returns The index of the removed reflection probe
  48582. */
  48583. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48584. /**
  48585. * Adds the given reflection probe to this scene.
  48586. * @param newReflectionProbe The reflection probe to add
  48587. */
  48588. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48589. }
  48590. }
  48591. /**
  48592. * Class used to generate realtime reflection / refraction cube textures
  48593. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48594. */
  48595. export class ReflectionProbe {
  48596. /** defines the name of the probe */
  48597. name: string;
  48598. private _scene;
  48599. private _renderTargetTexture;
  48600. private _projectionMatrix;
  48601. private _viewMatrix;
  48602. private _target;
  48603. private _add;
  48604. private _attachedMesh;
  48605. private _invertYAxis;
  48606. /** Gets or sets probe position (center of the cube map) */
  48607. position: Vector3;
  48608. /**
  48609. * Creates a new reflection probe
  48610. * @param name defines the name of the probe
  48611. * @param size defines the texture resolution (for each face)
  48612. * @param scene defines the hosting scene
  48613. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48614. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48615. */
  48616. constructor(
  48617. /** defines the name of the probe */
  48618. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48619. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48620. samples: number;
  48621. /** Gets or sets the refresh rate to use (on every frame by default) */
  48622. refreshRate: number;
  48623. /**
  48624. * Gets the hosting scene
  48625. * @returns a Scene
  48626. */
  48627. getScene(): Scene;
  48628. /** Gets the internal CubeTexture used to render to */
  48629. readonly cubeTexture: RenderTargetTexture;
  48630. /** Gets the list of meshes to render */
  48631. readonly renderList: Nullable<AbstractMesh[]>;
  48632. /**
  48633. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48634. * @param mesh defines the mesh to attach to
  48635. */
  48636. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48637. /**
  48638. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48639. * @param renderingGroupId The rendering group id corresponding to its index
  48640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48641. */
  48642. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48643. /**
  48644. * Clean all associated resources
  48645. */
  48646. dispose(): void;
  48647. /**
  48648. * Converts the reflection probe information to a readable string for debug purpose.
  48649. * @param fullDetails Supports for multiple levels of logging within scene loading
  48650. * @returns the human readable reflection probe info
  48651. */
  48652. toString(fullDetails?: boolean): string;
  48653. /**
  48654. * Get the class name of the relfection probe.
  48655. * @returns "ReflectionProbe"
  48656. */
  48657. getClassName(): string;
  48658. /**
  48659. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48660. * @returns The JSON representation of the texture
  48661. */
  48662. serialize(): any;
  48663. /**
  48664. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48665. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48666. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48667. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48668. * @returns The parsed reflection probe if successful
  48669. */
  48670. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48671. }
  48672. }
  48673. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48674. /** @hidden */
  48675. export var _BabylonLoaderRegistered: boolean;
  48676. }
  48677. declare module "babylonjs/Loading/Plugins/index" {
  48678. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48679. }
  48680. declare module "babylonjs/Loading/index" {
  48681. export * from "babylonjs/Loading/loadingScreen";
  48682. export * from "babylonjs/Loading/Plugins/index";
  48683. export * from "babylonjs/Loading/sceneLoader";
  48684. export * from "babylonjs/Loading/sceneLoaderFlags";
  48685. }
  48686. declare module "babylonjs/Materials/Background/index" {
  48687. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48688. }
  48689. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48690. import { Scene } from "babylonjs/scene";
  48691. import { Color3 } from "babylonjs/Maths/math";
  48692. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48693. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48694. /**
  48695. * The Physically based simple base material of BJS.
  48696. *
  48697. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48698. * It is used as the base class for both the specGloss and metalRough conventions.
  48699. */
  48700. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48701. /**
  48702. * Number of Simultaneous lights allowed on the material.
  48703. */
  48704. maxSimultaneousLights: number;
  48705. /**
  48706. * If sets to true, disables all the lights affecting the material.
  48707. */
  48708. disableLighting: boolean;
  48709. /**
  48710. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48711. */
  48712. environmentTexture: BaseTexture;
  48713. /**
  48714. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48715. */
  48716. invertNormalMapX: boolean;
  48717. /**
  48718. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48719. */
  48720. invertNormalMapY: boolean;
  48721. /**
  48722. * Normal map used in the model.
  48723. */
  48724. normalTexture: BaseTexture;
  48725. /**
  48726. * Emissivie color used to self-illuminate the model.
  48727. */
  48728. emissiveColor: Color3;
  48729. /**
  48730. * Emissivie texture used to self-illuminate the model.
  48731. */
  48732. emissiveTexture: BaseTexture;
  48733. /**
  48734. * Occlusion Channel Strenght.
  48735. */
  48736. occlusionStrength: number;
  48737. /**
  48738. * Occlusion Texture of the material (adding extra occlusion effects).
  48739. */
  48740. occlusionTexture: BaseTexture;
  48741. /**
  48742. * Defines the alpha limits in alpha test mode.
  48743. */
  48744. alphaCutOff: number;
  48745. /**
  48746. * Gets the current double sided mode.
  48747. */
  48748. /**
  48749. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48750. */
  48751. doubleSided: boolean;
  48752. /**
  48753. * Stores the pre-calculated light information of a mesh in a texture.
  48754. */
  48755. lightmapTexture: BaseTexture;
  48756. /**
  48757. * If true, the light map contains occlusion information instead of lighting info.
  48758. */
  48759. useLightmapAsShadowmap: boolean;
  48760. /**
  48761. * Instantiates a new PBRMaterial instance.
  48762. *
  48763. * @param name The material name
  48764. * @param scene The scene the material will be use in.
  48765. */
  48766. constructor(name: string, scene: Scene);
  48767. getClassName(): string;
  48768. }
  48769. }
  48770. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48771. import { Scene } from "babylonjs/scene";
  48772. import { Color3 } from "babylonjs/Maths/math";
  48773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48774. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48775. /**
  48776. * The PBR material of BJS following the metal roughness convention.
  48777. *
  48778. * This fits to the PBR convention in the GLTF definition:
  48779. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48780. */
  48781. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48782. /**
  48783. * The base color has two different interpretations depending on the value of metalness.
  48784. * When the material is a metal, the base color is the specific measured reflectance value
  48785. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48786. * of the material.
  48787. */
  48788. baseColor: Color3;
  48789. /**
  48790. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48791. * well as opacity information in the alpha channel.
  48792. */
  48793. baseTexture: BaseTexture;
  48794. /**
  48795. * Specifies the metallic scalar value of the material.
  48796. * Can also be used to scale the metalness values of the metallic texture.
  48797. */
  48798. metallic: number;
  48799. /**
  48800. * Specifies the roughness scalar value of the material.
  48801. * Can also be used to scale the roughness values of the metallic texture.
  48802. */
  48803. roughness: number;
  48804. /**
  48805. * Texture containing both the metallic value in the B channel and the
  48806. * roughness value in the G channel to keep better precision.
  48807. */
  48808. metallicRoughnessTexture: BaseTexture;
  48809. /**
  48810. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48811. *
  48812. * @param name The material name
  48813. * @param scene The scene the material will be use in.
  48814. */
  48815. constructor(name: string, scene: Scene);
  48816. /**
  48817. * Return the currrent class name of the material.
  48818. */
  48819. getClassName(): string;
  48820. /**
  48821. * Makes a duplicate of the current material.
  48822. * @param name - name to use for the new material.
  48823. */
  48824. clone(name: string): PBRMetallicRoughnessMaterial;
  48825. /**
  48826. * Serialize the material to a parsable JSON object.
  48827. */
  48828. serialize(): any;
  48829. /**
  48830. * Parses a JSON object correponding to the serialize function.
  48831. */
  48832. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48833. }
  48834. }
  48835. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48836. import { Scene } from "babylonjs/scene";
  48837. import { Color3 } from "babylonjs/Maths/math";
  48838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48839. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48840. /**
  48841. * The PBR material of BJS following the specular glossiness convention.
  48842. *
  48843. * This fits to the PBR convention in the GLTF definition:
  48844. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48845. */
  48846. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48847. /**
  48848. * Specifies the diffuse color of the material.
  48849. */
  48850. diffuseColor: Color3;
  48851. /**
  48852. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48853. * channel.
  48854. */
  48855. diffuseTexture: BaseTexture;
  48856. /**
  48857. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48858. */
  48859. specularColor: Color3;
  48860. /**
  48861. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48862. */
  48863. glossiness: number;
  48864. /**
  48865. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48866. */
  48867. specularGlossinessTexture: BaseTexture;
  48868. /**
  48869. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48870. *
  48871. * @param name The material name
  48872. * @param scene The scene the material will be use in.
  48873. */
  48874. constructor(name: string, scene: Scene);
  48875. /**
  48876. * Return the currrent class name of the material.
  48877. */
  48878. getClassName(): string;
  48879. /**
  48880. * Makes a duplicate of the current material.
  48881. * @param name - name to use for the new material.
  48882. */
  48883. clone(name: string): PBRSpecularGlossinessMaterial;
  48884. /**
  48885. * Serialize the material to a parsable JSON object.
  48886. */
  48887. serialize(): any;
  48888. /**
  48889. * Parses a JSON object correponding to the serialize function.
  48890. */
  48891. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48892. }
  48893. }
  48894. declare module "babylonjs/Materials/PBR/index" {
  48895. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48896. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48897. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48898. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48899. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48900. }
  48901. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48902. import { Nullable } from "babylonjs/types";
  48903. import { Scene } from "babylonjs/scene";
  48904. import { Matrix } from "babylonjs/Maths/math";
  48905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48906. /**
  48907. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48908. * It can help converting any input color in a desired output one. This can then be used to create effects
  48909. * from sepia, black and white to sixties or futuristic rendering...
  48910. *
  48911. * The only supported format is currently 3dl.
  48912. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48913. */
  48914. export class ColorGradingTexture extends BaseTexture {
  48915. /**
  48916. * The current texture matrix. (will always be identity in color grading texture)
  48917. */
  48918. private _textureMatrix;
  48919. /**
  48920. * The texture URL.
  48921. */
  48922. url: string;
  48923. /**
  48924. * Empty line regex stored for GC.
  48925. */
  48926. private static _noneEmptyLineRegex;
  48927. private _engine;
  48928. /**
  48929. * Instantiates a ColorGradingTexture from the following parameters.
  48930. *
  48931. * @param url The location of the color gradind data (currently only supporting 3dl)
  48932. * @param scene The scene the texture will be used in
  48933. */
  48934. constructor(url: string, scene: Scene);
  48935. /**
  48936. * Returns the texture matrix used in most of the material.
  48937. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48938. */
  48939. getTextureMatrix(): Matrix;
  48940. /**
  48941. * Occurs when the file being loaded is a .3dl LUT file.
  48942. */
  48943. private load3dlTexture;
  48944. /**
  48945. * Starts the loading process of the texture.
  48946. */
  48947. private loadTexture;
  48948. /**
  48949. * Clones the color gradind texture.
  48950. */
  48951. clone(): ColorGradingTexture;
  48952. /**
  48953. * Called during delayed load for textures.
  48954. */
  48955. delayLoad(): void;
  48956. /**
  48957. * Parses a color grading texture serialized by Babylon.
  48958. * @param parsedTexture The texture information being parsedTexture
  48959. * @param scene The scene to load the texture in
  48960. * @param rootUrl The root url of the data assets to load
  48961. * @return A color gradind texture
  48962. */
  48963. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48964. /**
  48965. * Serializes the LUT texture to json format.
  48966. */
  48967. serialize(): any;
  48968. }
  48969. }
  48970. declare module "babylonjs/Misc/tga" {
  48971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48972. /**
  48973. * Based on jsTGALoader - Javascript loader for TGA file
  48974. * By Vincent Thibault
  48975. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48976. */
  48977. export class TGATools {
  48978. private static _TYPE_INDEXED;
  48979. private static _TYPE_RGB;
  48980. private static _TYPE_GREY;
  48981. private static _TYPE_RLE_INDEXED;
  48982. private static _TYPE_RLE_RGB;
  48983. private static _TYPE_RLE_GREY;
  48984. private static _ORIGIN_MASK;
  48985. private static _ORIGIN_SHIFT;
  48986. private static _ORIGIN_BL;
  48987. private static _ORIGIN_BR;
  48988. private static _ORIGIN_UL;
  48989. private static _ORIGIN_UR;
  48990. /**
  48991. * Gets the header of a TGA file
  48992. * @param data defines the TGA data
  48993. * @returns the header
  48994. */
  48995. static GetTGAHeader(data: Uint8Array): any;
  48996. /**
  48997. * Uploads TGA content to a Babylon Texture
  48998. * @hidden
  48999. */
  49000. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49001. /** @hidden */
  49002. 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;
  49003. /** @hidden */
  49004. 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;
  49005. /** @hidden */
  49006. 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;
  49007. /** @hidden */
  49008. 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;
  49009. /** @hidden */
  49010. 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;
  49011. /** @hidden */
  49012. 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;
  49013. }
  49014. }
  49015. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49016. import { Nullable } from "babylonjs/types";
  49017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49018. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49019. /**
  49020. * Implementation of the TGA Texture Loader.
  49021. * @hidden
  49022. */
  49023. export class _TGATextureLoader implements IInternalTextureLoader {
  49024. /**
  49025. * Defines wether the loader supports cascade loading the different faces.
  49026. */
  49027. readonly supportCascades: boolean;
  49028. /**
  49029. * This returns if the loader support the current file information.
  49030. * @param extension defines the file extension of the file being loaded
  49031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49032. * @param fallback defines the fallback internal texture if any
  49033. * @param isBase64 defines whether the texture is encoded as a base64
  49034. * @param isBuffer defines whether the texture data are stored as a buffer
  49035. * @returns true if the loader can load the specified file
  49036. */
  49037. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49038. /**
  49039. * Transform the url before loading if required.
  49040. * @param rootUrl the url of the texture
  49041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49042. * @returns the transformed texture
  49043. */
  49044. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49045. /**
  49046. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49047. * @param rootUrl the url of the texture
  49048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49049. * @returns the fallback texture
  49050. */
  49051. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49052. /**
  49053. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49054. * @param data contains the texture data
  49055. * @param texture defines the BabylonJS internal texture
  49056. * @param createPolynomials will be true if polynomials have been requested
  49057. * @param onLoad defines the callback to trigger once the texture is ready
  49058. * @param onError defines the callback to trigger in case of error
  49059. */
  49060. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49061. /**
  49062. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49063. * @param data contains the texture data
  49064. * @param texture defines the BabylonJS internal texture
  49065. * @param callback defines the method to call once ready to upload
  49066. */
  49067. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49068. }
  49069. }
  49070. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49071. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49072. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49073. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49074. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49075. }
  49076. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49077. import { Scene } from "babylonjs/scene";
  49078. import { Texture } from "babylonjs/Materials/Textures/texture";
  49079. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49080. /**
  49081. * 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.
  49082. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49083. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49084. */
  49085. export class CustomProceduralTexture extends ProceduralTexture {
  49086. private _animate;
  49087. private _time;
  49088. private _config;
  49089. private _texturePath;
  49090. /**
  49091. * Instantiates a new Custom Procedural Texture.
  49092. * 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.
  49093. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49094. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49095. * @param name Define the name of the texture
  49096. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49097. * @param size Define the size of the texture to create
  49098. * @param scene Define the scene the texture belongs to
  49099. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49100. * @param generateMipMaps Define if the texture should creates mip maps or not
  49101. */
  49102. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49103. private _loadJson;
  49104. /**
  49105. * Is the texture ready to be used ? (rendered at least once)
  49106. * @returns true if ready, otherwise, false.
  49107. */
  49108. isReady(): boolean;
  49109. /**
  49110. * Render the texture to its associated render target.
  49111. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49112. */
  49113. render(useCameraPostProcess?: boolean): void;
  49114. /**
  49115. * Update the list of dependant textures samplers in the shader.
  49116. */
  49117. updateTextures(): void;
  49118. /**
  49119. * Update the uniform values of the procedural texture in the shader.
  49120. */
  49121. updateShaderUniforms(): void;
  49122. /**
  49123. * Define if the texture animates or not.
  49124. */
  49125. animate: boolean;
  49126. }
  49127. }
  49128. declare module "babylonjs/Shaders/noise.fragment" {
  49129. /** @hidden */
  49130. export var noisePixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49136. import { Nullable } from "babylonjs/types";
  49137. import { Scene } from "babylonjs/scene";
  49138. import { Texture } from "babylonjs/Materials/Textures/texture";
  49139. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49140. import "babylonjs/Shaders/noise.fragment";
  49141. /**
  49142. * Class used to generate noise procedural textures
  49143. */
  49144. export class NoiseProceduralTexture extends ProceduralTexture {
  49145. private _time;
  49146. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49147. brightness: number;
  49148. /** Defines the number of octaves to process */
  49149. octaves: number;
  49150. /** Defines the level of persistence (0.8 by default) */
  49151. persistence: number;
  49152. /** Gets or sets animation speed factor (default is 1) */
  49153. animationSpeedFactor: number;
  49154. /**
  49155. * Creates a new NoiseProceduralTexture
  49156. * @param name defines the name fo the texture
  49157. * @param size defines the size of the texture (default is 256)
  49158. * @param scene defines the hosting scene
  49159. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49160. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49161. */
  49162. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49163. private _updateShaderUniforms;
  49164. protected _getDefines(): string;
  49165. /** Generate the current state of the procedural texture */
  49166. render(useCameraPostProcess?: boolean): void;
  49167. /**
  49168. * Serializes this noise procedural texture
  49169. * @returns a serialized noise procedural texture object
  49170. */
  49171. serialize(): any;
  49172. /**
  49173. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49174. * @param parsedTexture defines parsed texture data
  49175. * @param scene defines the current scene
  49176. * @param rootUrl defines the root URL containing noise procedural texture information
  49177. * @returns a parsed NoiseProceduralTexture
  49178. */
  49179. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49180. }
  49181. }
  49182. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49183. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49184. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49185. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49186. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49187. }
  49188. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49189. import { Nullable } from "babylonjs/types";
  49190. import { Scene } from "babylonjs/scene";
  49191. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49193. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49194. /**
  49195. * Raw cube texture where the raw buffers are passed in
  49196. */
  49197. export class RawCubeTexture extends CubeTexture {
  49198. /**
  49199. * Creates a cube texture where the raw buffers are passed in.
  49200. * @param scene defines the scene the texture is attached to
  49201. * @param data defines the array of data to use to create each face
  49202. * @param size defines the size of the textures
  49203. * @param format defines the format of the data
  49204. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49205. * @param generateMipMaps defines if the engine should generate the mip levels
  49206. * @param invertY defines if data must be stored with Y axis inverted
  49207. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49208. * @param compression defines the compression used (null by default)
  49209. */
  49210. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49211. /**
  49212. * Updates the raw cube texture.
  49213. * @param data defines the data to store
  49214. * @param format defines the data format
  49215. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49216. * @param invertY defines if data must be stored with Y axis inverted
  49217. * @param compression defines the compression used (null by default)
  49218. * @param level defines which level of the texture to update
  49219. */
  49220. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49221. /**
  49222. * Updates a raw cube texture with RGBD encoded data.
  49223. * @param data defines the array of data [mipmap][face] to use to create each face
  49224. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49225. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49226. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49227. * @returns a promsie that resolves when the operation is complete
  49228. */
  49229. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49230. /**
  49231. * Clones the raw cube texture.
  49232. * @return a new cube texture
  49233. */
  49234. clone(): CubeTexture;
  49235. /** @hidden */
  49236. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49237. }
  49238. }
  49239. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49240. import { Scene } from "babylonjs/scene";
  49241. import { Texture } from "babylonjs/Materials/Textures/texture";
  49242. /**
  49243. * Class used to store 3D textures containing user data
  49244. */
  49245. export class RawTexture3D extends Texture {
  49246. /** Gets or sets the texture format to use */
  49247. format: number;
  49248. private _engine;
  49249. /**
  49250. * Create a new RawTexture3D
  49251. * @param data defines the data of the texture
  49252. * @param width defines the width of the texture
  49253. * @param height defines the height of the texture
  49254. * @param depth defines the depth of the texture
  49255. * @param format defines the texture format to use
  49256. * @param scene defines the hosting scene
  49257. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49258. * @param invertY defines if texture must be stored with Y axis inverted
  49259. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49260. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49261. */
  49262. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49263. /** Gets or sets the texture format to use */
  49264. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49265. /**
  49266. * Update the texture with new data
  49267. * @param data defines the data to store in the texture
  49268. */
  49269. update(data: ArrayBufferView): void;
  49270. }
  49271. }
  49272. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49273. import { Scene } from "babylonjs/scene";
  49274. import { Plane } from "babylonjs/Maths/math";
  49275. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49276. /**
  49277. * Creates a refraction texture used by refraction channel of the standard material.
  49278. * It is like a mirror but to see through a material.
  49279. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49280. */
  49281. export class RefractionTexture extends RenderTargetTexture {
  49282. /**
  49283. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49284. * 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.
  49285. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49286. */
  49287. refractionPlane: Plane;
  49288. /**
  49289. * Define how deep under the surface we should see.
  49290. */
  49291. depth: number;
  49292. /**
  49293. * Creates a refraction texture used by refraction channel of the standard material.
  49294. * It is like a mirror but to see through a material.
  49295. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49296. * @param name Define the texture name
  49297. * @param size Define the size of the underlying texture
  49298. * @param scene Define the scene the refraction belongs to
  49299. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49300. */
  49301. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49302. /**
  49303. * Clone the refraction texture.
  49304. * @returns the cloned texture
  49305. */
  49306. clone(): RefractionTexture;
  49307. /**
  49308. * Serialize the texture to a JSON representation you could use in Parse later on
  49309. * @returns the serialized JSON representation
  49310. */
  49311. serialize(): any;
  49312. }
  49313. }
  49314. declare module "babylonjs/Materials/Textures/index" {
  49315. export * from "babylonjs/Materials/Textures/baseTexture";
  49316. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49317. export * from "babylonjs/Materials/Textures/cubeTexture";
  49318. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49319. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49320. export * from "babylonjs/Materials/Textures/internalTexture";
  49321. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49322. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49323. export * from "babylonjs/Materials/Textures/Loaders/index";
  49324. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49325. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49326. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49327. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49328. export * from "babylonjs/Materials/Textures/rawTexture";
  49329. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49330. export * from "babylonjs/Materials/Textures/refractionTexture";
  49331. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49332. export * from "babylonjs/Materials/Textures/texture";
  49333. export * from "babylonjs/Materials/Textures/videoTexture";
  49334. }
  49335. declare module "babylonjs/Materials/index" {
  49336. export * from "babylonjs/Materials/Background/index";
  49337. export * from "babylonjs/Materials/colorCurves";
  49338. export * from "babylonjs/Materials/effect";
  49339. export * from "babylonjs/Materials/fresnelParameters";
  49340. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49341. export * from "babylonjs/Materials/material";
  49342. export * from "babylonjs/Materials/materialDefines";
  49343. export * from "babylonjs/Materials/materialHelper";
  49344. export * from "babylonjs/Materials/multiMaterial";
  49345. export * from "babylonjs/Materials/PBR/index";
  49346. export * from "babylonjs/Materials/pushMaterial";
  49347. export * from "babylonjs/Materials/shaderMaterial";
  49348. export * from "babylonjs/Materials/standardMaterial";
  49349. export * from "babylonjs/Materials/Textures/index";
  49350. export * from "babylonjs/Materials/uniformBuffer";
  49351. export * from "babylonjs/Materials/materialFlags";
  49352. }
  49353. declare module "babylonjs/Maths/index" {
  49354. export * from "babylonjs/Maths/math.scalar";
  49355. export * from "babylonjs/Maths/math";
  49356. export * from "babylonjs/Maths/sphericalPolynomial";
  49357. }
  49358. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49359. import { IDisposable } from "babylonjs/scene";
  49360. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49361. /**
  49362. * Configuration for Draco compression
  49363. */
  49364. export interface IDracoCompressionConfiguration {
  49365. /**
  49366. * Configuration for the decoder.
  49367. */
  49368. decoder?: {
  49369. /**
  49370. * The url to the WebAssembly module.
  49371. */
  49372. wasmUrl?: string;
  49373. /**
  49374. * The url to the WebAssembly binary.
  49375. */
  49376. wasmBinaryUrl?: string;
  49377. /**
  49378. * The url to the fallback JavaScript module.
  49379. */
  49380. fallbackUrl?: string;
  49381. };
  49382. }
  49383. /**
  49384. * Draco compression (https://google.github.io/draco/)
  49385. *
  49386. * This class wraps the Draco module.
  49387. *
  49388. * **Encoder**
  49389. *
  49390. * The encoder is not currently implemented.
  49391. *
  49392. * **Decoder**
  49393. *
  49394. * 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.
  49395. *
  49396. * To update the configuration, use the following code:
  49397. * ```javascript
  49398. * DracoCompression.Configuration = {
  49399. * decoder: {
  49400. * wasmUrl: "<url to the WebAssembly library>",
  49401. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49402. * fallbackUrl: "<url to the fallback JavaScript library>",
  49403. * }
  49404. * };
  49405. * ```
  49406. *
  49407. * 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.
  49408. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49409. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49410. *
  49411. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49412. * ```javascript
  49413. * var dracoCompression = new DracoCompression();
  49414. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49415. * [VertexBuffer.PositionKind]: 0
  49416. * });
  49417. * ```
  49418. *
  49419. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49420. */
  49421. export class DracoCompression implements IDisposable {
  49422. private static _DecoderModulePromise;
  49423. /**
  49424. * The configuration. Defaults to the following urls:
  49425. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49426. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49427. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49428. */
  49429. static Configuration: IDracoCompressionConfiguration;
  49430. /**
  49431. * Returns true if the decoder is available.
  49432. */
  49433. static readonly DecoderAvailable: boolean;
  49434. /**
  49435. * Constructor
  49436. */
  49437. constructor();
  49438. /**
  49439. * Stop all async operations and release resources.
  49440. */
  49441. dispose(): void;
  49442. /**
  49443. * Decode Draco compressed mesh data to vertex data.
  49444. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49445. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49446. * @returns A promise that resolves with the decoded vertex data
  49447. */
  49448. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49449. [kind: string]: number;
  49450. }): Promise<VertexData>;
  49451. private static _GetDecoderModule;
  49452. private static _LoadScriptAsync;
  49453. private static _LoadFileAsync;
  49454. }
  49455. }
  49456. declare module "babylonjs/Meshes/Compression/index" {
  49457. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49458. }
  49459. declare module "babylonjs/Meshes/csg" {
  49460. import { Nullable } from "babylonjs/types";
  49461. import { Scene } from "babylonjs/scene";
  49462. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49463. import { Mesh } from "babylonjs/Meshes/mesh";
  49464. import { Material } from "babylonjs/Materials/material";
  49465. /**
  49466. * Class for building Constructive Solid Geometry
  49467. */
  49468. export class CSG {
  49469. private polygons;
  49470. /**
  49471. * The world matrix
  49472. */
  49473. matrix: Matrix;
  49474. /**
  49475. * Stores the position
  49476. */
  49477. position: Vector3;
  49478. /**
  49479. * Stores the rotation
  49480. */
  49481. rotation: Vector3;
  49482. /**
  49483. * Stores the rotation quaternion
  49484. */
  49485. rotationQuaternion: Nullable<Quaternion>;
  49486. /**
  49487. * Stores the scaling vector
  49488. */
  49489. scaling: Vector3;
  49490. /**
  49491. * Convert the Mesh to CSG
  49492. * @param mesh The Mesh to convert to CSG
  49493. * @returns A new CSG from the Mesh
  49494. */
  49495. static FromMesh(mesh: Mesh): CSG;
  49496. /**
  49497. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49498. * @param polygons Polygons used to construct a CSG solid
  49499. */
  49500. private static FromPolygons;
  49501. /**
  49502. * Clones, or makes a deep copy, of the CSG
  49503. * @returns A new CSG
  49504. */
  49505. clone(): CSG;
  49506. /**
  49507. * Unions this CSG with another CSG
  49508. * @param csg The CSG to union against this CSG
  49509. * @returns The unioned CSG
  49510. */
  49511. union(csg: CSG): CSG;
  49512. /**
  49513. * Unions this CSG with another CSG in place
  49514. * @param csg The CSG to union against this CSG
  49515. */
  49516. unionInPlace(csg: CSG): void;
  49517. /**
  49518. * Subtracts this CSG with another CSG
  49519. * @param csg The CSG to subtract against this CSG
  49520. * @returns A new CSG
  49521. */
  49522. subtract(csg: CSG): CSG;
  49523. /**
  49524. * Subtracts this CSG with another CSG in place
  49525. * @param csg The CSG to subtact against this CSG
  49526. */
  49527. subtractInPlace(csg: CSG): void;
  49528. /**
  49529. * Intersect this CSG with another CSG
  49530. * @param csg The CSG to intersect against this CSG
  49531. * @returns A new CSG
  49532. */
  49533. intersect(csg: CSG): CSG;
  49534. /**
  49535. * Intersects this CSG with another CSG in place
  49536. * @param csg The CSG to intersect against this CSG
  49537. */
  49538. intersectInPlace(csg: CSG): void;
  49539. /**
  49540. * Return a new CSG solid with solid and empty space switched. This solid is
  49541. * not modified.
  49542. * @returns A new CSG solid with solid and empty space switched
  49543. */
  49544. inverse(): CSG;
  49545. /**
  49546. * Inverses the CSG in place
  49547. */
  49548. inverseInPlace(): void;
  49549. /**
  49550. * This is used to keep meshes transformations so they can be restored
  49551. * when we build back a Babylon Mesh
  49552. * NB : All CSG operations are performed in world coordinates
  49553. * @param csg The CSG to copy the transform attributes from
  49554. * @returns This CSG
  49555. */
  49556. copyTransformAttributes(csg: CSG): CSG;
  49557. /**
  49558. * Build Raw mesh from CSG
  49559. * Coordinates here are in world space
  49560. * @param name The name of the mesh geometry
  49561. * @param scene The Scene
  49562. * @param keepSubMeshes Specifies if the submeshes should be kept
  49563. * @returns A new Mesh
  49564. */
  49565. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49566. /**
  49567. * Build Mesh from CSG taking material and transforms into account
  49568. * @param name The name of the Mesh
  49569. * @param material The material of the Mesh
  49570. * @param scene The Scene
  49571. * @param keepSubMeshes Specifies if submeshes should be kept
  49572. * @returns The new Mesh
  49573. */
  49574. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49575. }
  49576. }
  49577. declare module "babylonjs/Meshes/trailMesh" {
  49578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49579. import { Mesh } from "babylonjs/Meshes/mesh";
  49580. import { Scene } from "babylonjs/scene";
  49581. /**
  49582. * Class used to create a trail following a mesh
  49583. */
  49584. export class TrailMesh extends Mesh {
  49585. private _generator;
  49586. private _autoStart;
  49587. private _running;
  49588. private _diameter;
  49589. private _length;
  49590. private _sectionPolygonPointsCount;
  49591. private _sectionVectors;
  49592. private _sectionNormalVectors;
  49593. private _beforeRenderObserver;
  49594. /**
  49595. * @constructor
  49596. * @param name The value used by scene.getMeshByName() to do a lookup.
  49597. * @param generator The mesh to generate a trail.
  49598. * @param scene The scene to add this mesh to.
  49599. * @param diameter Diameter of trailing mesh. Default is 1.
  49600. * @param length Length of trailing mesh. Default is 60.
  49601. * @param autoStart Automatically start trailing mesh. Default true.
  49602. */
  49603. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49604. /**
  49605. * "TrailMesh"
  49606. * @returns "TrailMesh"
  49607. */
  49608. getClassName(): string;
  49609. private _createMesh;
  49610. /**
  49611. * Start trailing mesh.
  49612. */
  49613. start(): void;
  49614. /**
  49615. * Stop trailing mesh.
  49616. */
  49617. stop(): void;
  49618. /**
  49619. * Update trailing mesh geometry.
  49620. */
  49621. update(): void;
  49622. /**
  49623. * Returns a new TrailMesh object.
  49624. * @param name is a string, the name given to the new mesh
  49625. * @param newGenerator use new generator object for cloned trail mesh
  49626. * @returns a new mesh
  49627. */
  49628. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49629. /**
  49630. * Serializes this trail mesh
  49631. * @param serializationObject object to write serialization to
  49632. */
  49633. serialize(serializationObject: any): void;
  49634. /**
  49635. * Parses a serialized trail mesh
  49636. * @param parsedMesh the serialized mesh
  49637. * @param scene the scene to create the trail mesh in
  49638. * @returns the created trail mesh
  49639. */
  49640. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49641. }
  49642. }
  49643. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49644. import { Nullable } from "babylonjs/types";
  49645. import { Scene } from "babylonjs/scene";
  49646. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49647. import { Mesh } from "babylonjs/Meshes/mesh";
  49648. /**
  49649. * Class containing static functions to help procedurally build meshes
  49650. */
  49651. export class RibbonBuilder {
  49652. /**
  49653. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49654. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49655. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49656. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49657. * * 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
  49658. * * 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
  49659. * * 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
  49660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49661. * * If you create a double-sided mesh, you can choose what parts of 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
  49662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49663. * * 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
  49664. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49665. * * 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
  49666. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49668. * @param name defines the name of the mesh
  49669. * @param options defines the options used to create the mesh
  49670. * @param scene defines the hosting scene
  49671. * @returns the ribbon mesh
  49672. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49674. */
  49675. static CreateRibbon(name: string, options: {
  49676. pathArray: Vector3[][];
  49677. closeArray?: boolean;
  49678. closePath?: boolean;
  49679. offset?: number;
  49680. updatable?: boolean;
  49681. sideOrientation?: number;
  49682. frontUVs?: Vector4;
  49683. backUVs?: Vector4;
  49684. instance?: Mesh;
  49685. invertUV?: boolean;
  49686. uvs?: Vector2[];
  49687. colors?: Color4[];
  49688. }, scene?: Nullable<Scene>): Mesh;
  49689. }
  49690. }
  49691. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49692. import { Vector4 } from "babylonjs/Maths/math";
  49693. import { Mesh } from "babylonjs/Meshes/mesh";
  49694. /**
  49695. * Class containing static functions to help procedurally build meshes
  49696. */
  49697. export class TorusKnotBuilder {
  49698. /**
  49699. * Creates a torus knot mesh
  49700. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49701. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49702. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49703. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49705. * * If you create a double-sided mesh, you can choose what parts of 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
  49706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49707. * @param name defines the name of the mesh
  49708. * @param options defines the options used to create the mesh
  49709. * @param scene defines the hosting scene
  49710. * @returns the torus knot mesh
  49711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49712. */
  49713. static CreateTorusKnot(name: string, options: {
  49714. radius?: number;
  49715. tube?: number;
  49716. radialSegments?: number;
  49717. tubularSegments?: number;
  49718. p?: number;
  49719. q?: number;
  49720. updatable?: boolean;
  49721. sideOrientation?: number;
  49722. frontUVs?: Vector4;
  49723. backUVs?: Vector4;
  49724. }, scene: any): Mesh;
  49725. }
  49726. }
  49727. declare module "babylonjs/Meshes/polygonMesh" {
  49728. import { Scene } from "babylonjs/scene";
  49729. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49730. import { Mesh } from "babylonjs/Meshes/mesh";
  49731. /**
  49732. * Polygon
  49733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49734. */
  49735. export class Polygon {
  49736. /**
  49737. * Creates a rectangle
  49738. * @param xmin bottom X coord
  49739. * @param ymin bottom Y coord
  49740. * @param xmax top X coord
  49741. * @param ymax top Y coord
  49742. * @returns points that make the resulting rectation
  49743. */
  49744. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49745. /**
  49746. * Creates a circle
  49747. * @param radius radius of circle
  49748. * @param cx scale in x
  49749. * @param cy scale in y
  49750. * @param numberOfSides number of sides that make up the circle
  49751. * @returns points that make the resulting circle
  49752. */
  49753. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49754. /**
  49755. * Creates a polygon from input string
  49756. * @param input Input polygon data
  49757. * @returns the parsed points
  49758. */
  49759. static Parse(input: string): Vector2[];
  49760. /**
  49761. * Starts building a polygon from x and y coordinates
  49762. * @param x x coordinate
  49763. * @param y y coordinate
  49764. * @returns the started path2
  49765. */
  49766. static StartingAt(x: number, y: number): Path2;
  49767. }
  49768. /**
  49769. * Builds a polygon
  49770. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49771. */
  49772. export class PolygonMeshBuilder {
  49773. private _points;
  49774. private _outlinepoints;
  49775. private _holes;
  49776. private _name;
  49777. private _scene;
  49778. private _epoints;
  49779. private _eholes;
  49780. private _addToepoint;
  49781. /**
  49782. * Babylon reference to the earcut plugin.
  49783. */
  49784. bjsEarcut: any;
  49785. /**
  49786. * Creates a PolygonMeshBuilder
  49787. * @param name name of the builder
  49788. * @param contours Path of the polygon
  49789. * @param scene scene to add to
  49790. * @param earcutInjection can be used to inject your own earcut reference
  49791. */
  49792. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49793. /**
  49794. * Adds a whole within the polygon
  49795. * @param hole Array of points defining the hole
  49796. * @returns this
  49797. */
  49798. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49799. /**
  49800. * Creates the polygon
  49801. * @param updatable If the mesh should be updatable
  49802. * @param depth The depth of the mesh created
  49803. * @returns the created mesh
  49804. */
  49805. build(updatable?: boolean, depth?: number): Mesh;
  49806. /**
  49807. * Adds a side to the polygon
  49808. * @param positions points that make the polygon
  49809. * @param normals normals of the polygon
  49810. * @param uvs uvs of the polygon
  49811. * @param indices indices of the polygon
  49812. * @param bounds bounds of the polygon
  49813. * @param points points of the polygon
  49814. * @param depth depth of the polygon
  49815. * @param flip flip of the polygon
  49816. */
  49817. private addSide;
  49818. }
  49819. }
  49820. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49821. import { Scene } from "babylonjs/scene";
  49822. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49823. import { Mesh } from "babylonjs/Meshes/mesh";
  49824. /**
  49825. * Class containing static functions to help procedurally build meshes
  49826. */
  49827. export class PolygonBuilder {
  49828. /**
  49829. * Creates a polygon mesh
  49830. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49831. * * 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
  49832. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49835. * * Remember you can only change the shape positions, not their number when updating a polygon
  49836. * @param name defines the name of the mesh
  49837. * @param options defines the options used to create the mesh
  49838. * @param scene defines the hosting scene
  49839. * @param earcutInjection can be used to inject your own earcut reference
  49840. * @returns the polygon mesh
  49841. */
  49842. static CreatePolygon(name: string, options: {
  49843. shape: Vector3[];
  49844. holes?: Vector3[][];
  49845. depth?: number;
  49846. faceUV?: Vector4[];
  49847. faceColors?: Color4[];
  49848. updatable?: boolean;
  49849. sideOrientation?: number;
  49850. frontUVs?: Vector4;
  49851. backUVs?: Vector4;
  49852. }, scene: Scene, earcutInjection?: any): Mesh;
  49853. /**
  49854. * Creates an extruded polygon mesh, with depth in the Y direction.
  49855. * * 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)
  49856. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49857. * @param name defines the name of the mesh
  49858. * @param options defines the options used to create the mesh
  49859. * @param scene defines the hosting scene
  49860. * @param earcutInjection can be used to inject your own earcut reference
  49861. * @returns the polygon mesh
  49862. */
  49863. static ExtrudePolygon(name: string, options: {
  49864. shape: Vector3[];
  49865. holes?: Vector3[][];
  49866. depth?: number;
  49867. faceUV?: Vector4[];
  49868. faceColors?: Color4[];
  49869. updatable?: boolean;
  49870. sideOrientation?: number;
  49871. frontUVs?: Vector4;
  49872. backUVs?: Vector4;
  49873. }, scene: Scene, earcutInjection?: any): Mesh;
  49874. }
  49875. }
  49876. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49877. import { Nullable } from "babylonjs/types";
  49878. import { Scene } from "babylonjs/scene";
  49879. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49880. import { Mesh } from "babylonjs/Meshes/mesh";
  49881. /**
  49882. * Class containing static functions to help procedurally build meshes
  49883. */
  49884. export class ShapeBuilder {
  49885. /**
  49886. * 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.
  49887. * * 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.
  49888. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49889. * * 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.
  49890. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49891. * * 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
  49892. * * 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
  49893. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49895. * * If you create a double-sided mesh, you can choose what parts of 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
  49896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49898. * @param name defines the name of the mesh
  49899. * @param options defines the options used to create the mesh
  49900. * @param scene defines the hosting scene
  49901. * @returns the extruded shape mesh
  49902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49904. */
  49905. static ExtrudeShape(name: string, options: {
  49906. shape: Vector3[];
  49907. path: Vector3[];
  49908. scale?: number;
  49909. rotation?: number;
  49910. cap?: number;
  49911. updatable?: boolean;
  49912. sideOrientation?: number;
  49913. frontUVs?: Vector4;
  49914. backUVs?: Vector4;
  49915. instance?: Mesh;
  49916. invertUV?: boolean;
  49917. }, scene?: Nullable<Scene>): Mesh;
  49918. /**
  49919. * Creates an custom extruded shape mesh.
  49920. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49921. * * 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.
  49922. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49923. * * 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
  49924. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49925. * * 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
  49926. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49927. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49928. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49929. * * 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
  49930. * * 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
  49931. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49933. * * If you create a double-sided mesh, you can choose what parts of 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
  49934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49936. * @param name defines the name of the mesh
  49937. * @param options defines the options used to create the mesh
  49938. * @param scene defines the hosting scene
  49939. * @returns the custom extruded shape mesh
  49940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49943. */
  49944. static ExtrudeShapeCustom(name: string, options: {
  49945. shape: Vector3[];
  49946. path: Vector3[];
  49947. scaleFunction?: any;
  49948. rotationFunction?: any;
  49949. ribbonCloseArray?: boolean;
  49950. ribbonClosePath?: boolean;
  49951. cap?: number;
  49952. updatable?: boolean;
  49953. sideOrientation?: number;
  49954. frontUVs?: Vector4;
  49955. backUVs?: Vector4;
  49956. instance?: Mesh;
  49957. invertUV?: boolean;
  49958. }, scene: Scene): Mesh;
  49959. private static _ExtrudeShapeGeneric;
  49960. }
  49961. }
  49962. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49963. import { Scene } from "babylonjs/scene";
  49964. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49965. import { Mesh } from "babylonjs/Meshes/mesh";
  49966. /**
  49967. * Class containing static functions to help procedurally build meshes
  49968. */
  49969. export class LatheBuilder {
  49970. /**
  49971. * Creates lathe mesh.
  49972. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49973. * * 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
  49974. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49975. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49976. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49977. * * 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
  49978. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49979. * * 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
  49980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49981. * * If you create a double-sided mesh, you can choose what parts of 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
  49982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49984. * @param name defines the name of the mesh
  49985. * @param options defines the options used to create the mesh
  49986. * @param scene defines the hosting scene
  49987. * @returns the lathe mesh
  49988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49989. */
  49990. static CreateLathe(name: string, options: {
  49991. shape: Vector3[];
  49992. radius?: number;
  49993. tessellation?: number;
  49994. clip?: number;
  49995. arc?: number;
  49996. closed?: boolean;
  49997. updatable?: boolean;
  49998. sideOrientation?: number;
  49999. frontUVs?: Vector4;
  50000. backUVs?: Vector4;
  50001. cap?: number;
  50002. invertUV?: boolean;
  50003. }, scene: Scene): Mesh;
  50004. }
  50005. }
  50006. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50007. import { Scene } from "babylonjs/scene";
  50008. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50009. import { Mesh } from "babylonjs/Meshes/mesh";
  50010. /**
  50011. * Class containing static functions to help procedurally build meshes
  50012. */
  50013. export class TubeBuilder {
  50014. /**
  50015. * Creates a tube mesh.
  50016. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50017. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50018. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50019. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50020. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50021. * * 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)
  50022. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50023. * * 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
  50024. * * 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
  50025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50026. * * If you create a double-sided mesh, you can choose what parts of 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
  50027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50029. * @param name defines the name of the mesh
  50030. * @param options defines the options used to create the mesh
  50031. * @param scene defines the hosting scene
  50032. * @returns the tube mesh
  50033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50034. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50035. */
  50036. static CreateTube(name: string, options: {
  50037. path: Vector3[];
  50038. radius?: number;
  50039. tessellation?: number;
  50040. radiusFunction?: {
  50041. (i: number, distance: number): number;
  50042. };
  50043. cap?: number;
  50044. arc?: number;
  50045. updatable?: boolean;
  50046. sideOrientation?: number;
  50047. frontUVs?: Vector4;
  50048. backUVs?: Vector4;
  50049. instance?: Mesh;
  50050. invertUV?: boolean;
  50051. }, scene: Scene): Mesh;
  50052. }
  50053. }
  50054. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50055. import { Scene } from "babylonjs/scene";
  50056. import { Vector4 } from "babylonjs/Maths/math";
  50057. import { Mesh } from "babylonjs/Meshes/mesh";
  50058. /**
  50059. * Class containing static functions to help procedurally build meshes
  50060. */
  50061. export class IcoSphereBuilder {
  50062. /**
  50063. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50064. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50065. * * 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`)
  50066. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50067. * * 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
  50068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50069. * * If you create a double-sided mesh, you can choose what parts of 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
  50070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50071. * @param name defines the name of the mesh
  50072. * @param options defines the options used to create the mesh
  50073. * @param scene defines the hosting scene
  50074. * @returns the icosahedron mesh
  50075. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50076. */
  50077. static CreateIcoSphere(name: string, options: {
  50078. radius?: number;
  50079. radiusX?: number;
  50080. radiusY?: number;
  50081. radiusZ?: number;
  50082. flat?: boolean;
  50083. subdivisions?: number;
  50084. sideOrientation?: number;
  50085. frontUVs?: Vector4;
  50086. backUVs?: Vector4;
  50087. updatable?: boolean;
  50088. }, scene: Scene): Mesh;
  50089. }
  50090. }
  50091. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50092. import { Vector3 } from "babylonjs/Maths/math";
  50093. import { Mesh } from "babylonjs/Meshes/mesh";
  50094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50095. /**
  50096. * Class containing static functions to help procedurally build meshes
  50097. */
  50098. export class DecalBuilder {
  50099. /**
  50100. * Creates a decal mesh.
  50101. * 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
  50102. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50103. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50104. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50105. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50106. * @param name defines the name of the mesh
  50107. * @param sourceMesh defines the mesh where the decal must be applied
  50108. * @param options defines the options used to create the mesh
  50109. * @param scene defines the hosting scene
  50110. * @returns the decal mesh
  50111. * @see https://doc.babylonjs.com/how_to/decals
  50112. */
  50113. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50114. position?: Vector3;
  50115. normal?: Vector3;
  50116. size?: Vector3;
  50117. angle?: number;
  50118. }): Mesh;
  50119. }
  50120. }
  50121. declare module "babylonjs/Meshes/meshBuilder" {
  50122. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50123. import { Nullable } from "babylonjs/types";
  50124. import { Scene } from "babylonjs/scene";
  50125. import { Mesh } from "babylonjs/Meshes/mesh";
  50126. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50127. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50129. /**
  50130. * Class containing static functions to help procedurally build meshes
  50131. */
  50132. export class MeshBuilder {
  50133. /**
  50134. * Creates a box mesh
  50135. * * The parameter `size` sets the size (float) of each box side (default 1)
  50136. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50137. * * 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)
  50138. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50140. * * If you create a double-sided mesh, you can choose what parts of 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
  50141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50142. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50143. * @param name defines the name of the mesh
  50144. * @param options defines the options used to create the mesh
  50145. * @param scene defines the hosting scene
  50146. * @returns the box mesh
  50147. */
  50148. static CreateBox(name: string, options: {
  50149. size?: number;
  50150. width?: number;
  50151. height?: number;
  50152. depth?: number;
  50153. faceUV?: Vector4[];
  50154. faceColors?: Color4[];
  50155. sideOrientation?: number;
  50156. frontUVs?: Vector4;
  50157. backUVs?: Vector4;
  50158. updatable?: boolean;
  50159. }, scene?: Nullable<Scene>): Mesh;
  50160. /**
  50161. * Creates a sphere mesh
  50162. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50163. * * 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`)
  50164. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50165. * * 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
  50166. * * 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)
  50167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50168. * * If you create a double-sided mesh, you can choose what parts of 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
  50169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50170. * @param name defines the name of the mesh
  50171. * @param options defines the options used to create the mesh
  50172. * @param scene defines the hosting scene
  50173. * @returns the sphere mesh
  50174. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50175. */
  50176. static CreateSphere(name: string, options: {
  50177. segments?: number;
  50178. diameter?: number;
  50179. diameterX?: number;
  50180. diameterY?: number;
  50181. diameterZ?: number;
  50182. arc?: number;
  50183. slice?: number;
  50184. sideOrientation?: number;
  50185. frontUVs?: Vector4;
  50186. backUVs?: Vector4;
  50187. updatable?: boolean;
  50188. }, scene: any): Mesh;
  50189. /**
  50190. * Creates a plane polygonal mesh. By default, this is a disc
  50191. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50192. * * 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
  50193. * * 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
  50194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50195. * * If you create a double-sided mesh, you can choose what parts of 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
  50196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50197. * @param name defines the name of the mesh
  50198. * @param options defines the options used to create the mesh
  50199. * @param scene defines the hosting scene
  50200. * @returns the plane polygonal mesh
  50201. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50202. */
  50203. static CreateDisc(name: string, options: {
  50204. radius?: number;
  50205. tessellation?: number;
  50206. arc?: number;
  50207. updatable?: boolean;
  50208. sideOrientation?: number;
  50209. frontUVs?: Vector4;
  50210. backUVs?: Vector4;
  50211. }, scene?: Nullable<Scene>): Mesh;
  50212. /**
  50213. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50214. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50215. * * 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`)
  50216. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50217. * * 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
  50218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50219. * * If you create a double-sided mesh, you can choose what parts of 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
  50220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50221. * @param name defines the name of the mesh
  50222. * @param options defines the options used to create the mesh
  50223. * @param scene defines the hosting scene
  50224. * @returns the icosahedron mesh
  50225. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50226. */
  50227. static CreateIcoSphere(name: string, options: {
  50228. radius?: number;
  50229. radiusX?: number;
  50230. radiusY?: number;
  50231. radiusZ?: number;
  50232. flat?: boolean;
  50233. subdivisions?: number;
  50234. sideOrientation?: number;
  50235. frontUVs?: Vector4;
  50236. backUVs?: Vector4;
  50237. updatable?: boolean;
  50238. }, scene: Scene): Mesh;
  50239. /**
  50240. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50241. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50242. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50243. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50244. * * 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
  50245. * * 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
  50246. * * 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
  50247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50248. * * If you create a double-sided mesh, you can choose what parts of 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
  50249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50250. * * 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
  50251. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50252. * * 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
  50253. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50255. * @param name defines the name of the mesh
  50256. * @param options defines the options used to create the mesh
  50257. * @param scene defines the hosting scene
  50258. * @returns the ribbon mesh
  50259. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50261. */
  50262. static CreateRibbon(name: string, options: {
  50263. pathArray: Vector3[][];
  50264. closeArray?: boolean;
  50265. closePath?: boolean;
  50266. offset?: number;
  50267. updatable?: boolean;
  50268. sideOrientation?: number;
  50269. frontUVs?: Vector4;
  50270. backUVs?: Vector4;
  50271. instance?: Mesh;
  50272. invertUV?: boolean;
  50273. uvs?: Vector2[];
  50274. colors?: Color4[];
  50275. }, scene?: Nullable<Scene>): Mesh;
  50276. /**
  50277. * Creates a cylinder or a cone mesh
  50278. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50279. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50280. * * 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.
  50281. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50282. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50283. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50284. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50285. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50286. * * 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).
  50287. * * 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
  50288. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50289. * * 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
  50290. * * 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.
  50291. * * If `enclose` is false, a ring surface is one element.
  50292. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50293. * * 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
  50294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50295. * * If you create a double-sided mesh, you can choose what parts of 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
  50296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50297. * @param name defines the name of the mesh
  50298. * @param options defines the options used to create the mesh
  50299. * @param scene defines the hosting scene
  50300. * @returns the cylinder mesh
  50301. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50302. */
  50303. static CreateCylinder(name: string, options: {
  50304. height?: number;
  50305. diameterTop?: number;
  50306. diameterBottom?: number;
  50307. diameter?: number;
  50308. tessellation?: number;
  50309. subdivisions?: number;
  50310. arc?: number;
  50311. faceColors?: Color4[];
  50312. faceUV?: Vector4[];
  50313. updatable?: boolean;
  50314. hasRings?: boolean;
  50315. enclose?: boolean;
  50316. sideOrientation?: number;
  50317. frontUVs?: Vector4;
  50318. backUVs?: Vector4;
  50319. }, scene: any): Mesh;
  50320. /**
  50321. * Creates a torus mesh
  50322. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50323. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50324. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50326. * * If you create a double-sided mesh, you can choose what parts of 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
  50327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50328. * @param name defines the name of the mesh
  50329. * @param options defines the options used to create the mesh
  50330. * @param scene defines the hosting scene
  50331. * @returns the torus mesh
  50332. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50333. */
  50334. static CreateTorus(name: string, options: {
  50335. diameter?: number;
  50336. thickness?: number;
  50337. tessellation?: number;
  50338. updatable?: boolean;
  50339. sideOrientation?: number;
  50340. frontUVs?: Vector4;
  50341. backUVs?: Vector4;
  50342. }, scene: any): Mesh;
  50343. /**
  50344. * Creates a torus knot mesh
  50345. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50346. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50347. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50348. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50350. * * If you create a double-sided mesh, you can choose what parts of 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
  50351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50352. * @param name defines the name of the mesh
  50353. * @param options defines the options used to create the mesh
  50354. * @param scene defines the hosting scene
  50355. * @returns the torus knot mesh
  50356. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50357. */
  50358. static CreateTorusKnot(name: string, options: {
  50359. radius?: number;
  50360. tube?: number;
  50361. radialSegments?: number;
  50362. tubularSegments?: number;
  50363. p?: number;
  50364. q?: number;
  50365. updatable?: boolean;
  50366. sideOrientation?: number;
  50367. frontUVs?: Vector4;
  50368. backUVs?: Vector4;
  50369. }, scene: any): Mesh;
  50370. /**
  50371. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50372. * * 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
  50373. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50374. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50375. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50376. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50377. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50378. * * 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
  50379. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50382. * @param name defines the name of the new line system
  50383. * @param options defines the options used to create the line system
  50384. * @param scene defines the hosting scene
  50385. * @returns a new line system mesh
  50386. */
  50387. static CreateLineSystem(name: string, options: {
  50388. lines: Vector3[][];
  50389. updatable?: boolean;
  50390. instance?: Nullable<LinesMesh>;
  50391. colors?: Nullable<Color4[][]>;
  50392. useVertexAlpha?: boolean;
  50393. }, scene: Nullable<Scene>): LinesMesh;
  50394. /**
  50395. * Creates a line mesh
  50396. * 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
  50397. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50398. * * The parameter `points` is an array successive Vector3
  50399. * * 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
  50400. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50401. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50402. * * When updating an instance, remember that only point positions can change, not the number of points
  50403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50405. * @param name defines the name of the new line system
  50406. * @param options defines the options used to create the line system
  50407. * @param scene defines the hosting scene
  50408. * @returns a new line mesh
  50409. */
  50410. static CreateLines(name: string, options: {
  50411. points: Vector3[];
  50412. updatable?: boolean;
  50413. instance?: Nullable<LinesMesh>;
  50414. colors?: Color4[];
  50415. useVertexAlpha?: boolean;
  50416. }, scene?: Nullable<Scene>): LinesMesh;
  50417. /**
  50418. * Creates a dashed line mesh
  50419. * * 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
  50420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50421. * * The parameter `points` is an array successive Vector3
  50422. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50423. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50424. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50425. * * 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
  50426. * * When updating an instance, remember that only point positions can change, not the number of points
  50427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50428. * @param name defines the name of the mesh
  50429. * @param options defines the options used to create the mesh
  50430. * @param scene defines the hosting scene
  50431. * @returns the dashed line mesh
  50432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50433. */
  50434. static CreateDashedLines(name: string, options: {
  50435. points: Vector3[];
  50436. dashSize?: number;
  50437. gapSize?: number;
  50438. dashNb?: number;
  50439. updatable?: boolean;
  50440. instance?: LinesMesh;
  50441. }, scene?: Nullable<Scene>): LinesMesh;
  50442. /**
  50443. * 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.
  50444. * * 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.
  50445. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50446. * * 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.
  50447. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50448. * * 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
  50449. * * 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
  50450. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50452. * * If you create a double-sided mesh, you can choose what parts of 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
  50453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50455. * @param name defines the name of the mesh
  50456. * @param options defines the options used to create the mesh
  50457. * @param scene defines the hosting scene
  50458. * @returns the extruded shape mesh
  50459. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50461. */
  50462. static ExtrudeShape(name: string, options: {
  50463. shape: Vector3[];
  50464. path: Vector3[];
  50465. scale?: number;
  50466. rotation?: number;
  50467. cap?: number;
  50468. updatable?: boolean;
  50469. sideOrientation?: number;
  50470. frontUVs?: Vector4;
  50471. backUVs?: Vector4;
  50472. instance?: Mesh;
  50473. invertUV?: boolean;
  50474. }, scene?: Nullable<Scene>): Mesh;
  50475. /**
  50476. * Creates an custom extruded shape mesh.
  50477. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50478. * * 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.
  50479. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50480. * * 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
  50481. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50482. * * 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
  50483. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50484. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50485. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50486. * * 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
  50487. * * 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
  50488. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50490. * * If you create a double-sided mesh, you can choose what parts of 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
  50491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50493. * @param name defines the name of the mesh
  50494. * @param options defines the options used to create the mesh
  50495. * @param scene defines the hosting scene
  50496. * @returns the custom extruded shape mesh
  50497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50498. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50500. */
  50501. static ExtrudeShapeCustom(name: string, options: {
  50502. shape: Vector3[];
  50503. path: Vector3[];
  50504. scaleFunction?: any;
  50505. rotationFunction?: any;
  50506. ribbonCloseArray?: boolean;
  50507. ribbonClosePath?: boolean;
  50508. cap?: number;
  50509. updatable?: boolean;
  50510. sideOrientation?: number;
  50511. frontUVs?: Vector4;
  50512. backUVs?: Vector4;
  50513. instance?: Mesh;
  50514. invertUV?: boolean;
  50515. }, scene: Scene): Mesh;
  50516. /**
  50517. * Creates lathe mesh.
  50518. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50519. * * 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
  50520. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50521. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50522. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50523. * * 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
  50524. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50525. * * 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
  50526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50527. * * If you create a double-sided mesh, you can choose what parts of 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
  50528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50530. * @param name defines the name of the mesh
  50531. * @param options defines the options used to create the mesh
  50532. * @param scene defines the hosting scene
  50533. * @returns the lathe mesh
  50534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50535. */
  50536. static CreateLathe(name: string, options: {
  50537. shape: Vector3[];
  50538. radius?: number;
  50539. tessellation?: number;
  50540. clip?: number;
  50541. arc?: number;
  50542. closed?: boolean;
  50543. updatable?: boolean;
  50544. sideOrientation?: number;
  50545. frontUVs?: Vector4;
  50546. backUVs?: Vector4;
  50547. cap?: number;
  50548. invertUV?: boolean;
  50549. }, scene: Scene): Mesh;
  50550. /**
  50551. * Creates a plane mesh
  50552. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50553. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50554. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50556. * * If you create a double-sided mesh, you can choose what parts of 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
  50557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50558. * @param name defines the name of the mesh
  50559. * @param options defines the options used to create the mesh
  50560. * @param scene defines the hosting scene
  50561. * @returns the plane mesh
  50562. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50563. */
  50564. static CreatePlane(name: string, options: {
  50565. size?: number;
  50566. width?: number;
  50567. height?: number;
  50568. sideOrientation?: number;
  50569. frontUVs?: Vector4;
  50570. backUVs?: Vector4;
  50571. updatable?: boolean;
  50572. sourcePlane?: Plane;
  50573. }, scene: Scene): Mesh;
  50574. /**
  50575. * Creates a ground mesh
  50576. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50577. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50579. * @param name defines the name of the mesh
  50580. * @param options defines the options used to create the mesh
  50581. * @param scene defines the hosting scene
  50582. * @returns the ground mesh
  50583. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50584. */
  50585. static CreateGround(name: string, options: {
  50586. width?: number;
  50587. height?: number;
  50588. subdivisions?: number;
  50589. subdivisionsX?: number;
  50590. subdivisionsY?: number;
  50591. updatable?: boolean;
  50592. }, scene: any): Mesh;
  50593. /**
  50594. * Creates a tiled ground mesh
  50595. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50596. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50597. * * 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
  50598. * * 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
  50599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50600. * @param name defines the name of the mesh
  50601. * @param options defines the options used to create the mesh
  50602. * @param scene defines the hosting scene
  50603. * @returns the tiled ground mesh
  50604. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50605. */
  50606. static CreateTiledGround(name: string, options: {
  50607. xmin: number;
  50608. zmin: number;
  50609. xmax: number;
  50610. zmax: number;
  50611. subdivisions?: {
  50612. w: number;
  50613. h: number;
  50614. };
  50615. precision?: {
  50616. w: number;
  50617. h: number;
  50618. };
  50619. updatable?: boolean;
  50620. }, scene: Scene): Mesh;
  50621. /**
  50622. * Creates a ground mesh from a height map
  50623. * * The parameter `url` sets the URL of the height map image resource.
  50624. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50625. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50626. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50627. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50628. * * 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.
  50629. * * 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).
  50630. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50632. * @param name defines the name of the mesh
  50633. * @param url defines the url to the height map
  50634. * @param options defines the options used to create the mesh
  50635. * @param scene defines the hosting scene
  50636. * @returns the ground mesh
  50637. * @see https://doc.babylonjs.com/babylon101/height_map
  50638. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50639. */
  50640. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50641. width?: number;
  50642. height?: number;
  50643. subdivisions?: number;
  50644. minHeight?: number;
  50645. maxHeight?: number;
  50646. colorFilter?: Color3;
  50647. alphaFilter?: number;
  50648. updatable?: boolean;
  50649. onReady?: (mesh: GroundMesh) => void;
  50650. }, scene: Scene): GroundMesh;
  50651. /**
  50652. * Creates a polygon mesh
  50653. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50654. * * 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
  50655. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50658. * * Remember you can only change the shape positions, not their number when updating a polygon
  50659. * @param name defines the name of the mesh
  50660. * @param options defines the options used to create the mesh
  50661. * @param scene defines the hosting scene
  50662. * @param earcutInjection can be used to inject your own earcut reference
  50663. * @returns the polygon mesh
  50664. */
  50665. static CreatePolygon(name: string, options: {
  50666. shape: Vector3[];
  50667. holes?: Vector3[][];
  50668. depth?: number;
  50669. faceUV?: Vector4[];
  50670. faceColors?: Color4[];
  50671. updatable?: boolean;
  50672. sideOrientation?: number;
  50673. frontUVs?: Vector4;
  50674. backUVs?: Vector4;
  50675. }, scene: Scene, earcutInjection?: any): Mesh;
  50676. /**
  50677. * Creates an extruded polygon mesh, with depth in the Y direction.
  50678. * * 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)
  50679. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50680. * @param name defines the name of the mesh
  50681. * @param options defines the options used to create the mesh
  50682. * @param scene defines the hosting scene
  50683. * @param earcutInjection can be used to inject your own earcut reference
  50684. * @returns the polygon mesh
  50685. */
  50686. static ExtrudePolygon(name: string, options: {
  50687. shape: Vector3[];
  50688. holes?: Vector3[][];
  50689. depth?: number;
  50690. faceUV?: Vector4[];
  50691. faceColors?: Color4[];
  50692. updatable?: boolean;
  50693. sideOrientation?: number;
  50694. frontUVs?: Vector4;
  50695. backUVs?: Vector4;
  50696. }, scene: Scene, earcutInjection?: any): Mesh;
  50697. /**
  50698. * Creates a tube mesh.
  50699. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50700. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50701. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50702. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50703. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50704. * * 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)
  50705. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50706. * * 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
  50707. * * 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
  50708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50709. * * If you create a double-sided mesh, you can choose what parts of 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
  50710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50712. * @param name defines the name of the mesh
  50713. * @param options defines the options used to create the mesh
  50714. * @param scene defines the hosting scene
  50715. * @returns the tube mesh
  50716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50717. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50718. */
  50719. static CreateTube(name: string, options: {
  50720. path: Vector3[];
  50721. radius?: number;
  50722. tessellation?: number;
  50723. radiusFunction?: {
  50724. (i: number, distance: number): number;
  50725. };
  50726. cap?: number;
  50727. arc?: number;
  50728. updatable?: boolean;
  50729. sideOrientation?: number;
  50730. frontUVs?: Vector4;
  50731. backUVs?: Vector4;
  50732. instance?: Mesh;
  50733. invertUV?: boolean;
  50734. }, scene: Scene): Mesh;
  50735. /**
  50736. * Creates a polyhedron mesh
  50737. * * 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
  50738. * * The parameter `size` (positive float, default 1) sets the polygon size
  50739. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50740. * * 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`
  50741. * * 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
  50742. * * 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)`)
  50743. * * 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
  50744. * * 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
  50745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50746. * * If you create a double-sided mesh, you can choose what parts of 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
  50747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50748. * @param name defines the name of the mesh
  50749. * @param options defines the options used to create the mesh
  50750. * @param scene defines the hosting scene
  50751. * @returns the polyhedron mesh
  50752. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50753. */
  50754. static CreatePolyhedron(name: string, options: {
  50755. type?: number;
  50756. size?: number;
  50757. sizeX?: number;
  50758. sizeY?: number;
  50759. sizeZ?: number;
  50760. custom?: any;
  50761. faceUV?: Vector4[];
  50762. faceColors?: Color4[];
  50763. flat?: boolean;
  50764. updatable?: boolean;
  50765. sideOrientation?: number;
  50766. frontUVs?: Vector4;
  50767. backUVs?: Vector4;
  50768. }, scene: Scene): Mesh;
  50769. /**
  50770. * Creates a decal mesh.
  50771. * 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
  50772. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50773. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50774. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50775. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50776. * @param name defines the name of the mesh
  50777. * @param sourceMesh defines the mesh where the decal must be applied
  50778. * @param options defines the options used to create the mesh
  50779. * @param scene defines the hosting scene
  50780. * @returns the decal mesh
  50781. * @see https://doc.babylonjs.com/how_to/decals
  50782. */
  50783. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50784. position?: Vector3;
  50785. normal?: Vector3;
  50786. size?: Vector3;
  50787. angle?: number;
  50788. }): Mesh;
  50789. }
  50790. }
  50791. declare module "babylonjs/Meshes/meshSimplification" {
  50792. import { Mesh } from "babylonjs/Meshes/mesh";
  50793. /**
  50794. * A simplifier interface for future simplification implementations
  50795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50796. */
  50797. export interface ISimplifier {
  50798. /**
  50799. * Simplification of a given mesh according to the given settings.
  50800. * Since this requires computation, it is assumed that the function runs async.
  50801. * @param settings The settings of the simplification, including quality and distance
  50802. * @param successCallback A callback that will be called after the mesh was simplified.
  50803. * @param errorCallback in case of an error, this callback will be called. optional.
  50804. */
  50805. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50806. }
  50807. /**
  50808. * Expected simplification settings.
  50809. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50810. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50811. */
  50812. export interface ISimplificationSettings {
  50813. /**
  50814. * Gets or sets the expected quality
  50815. */
  50816. quality: number;
  50817. /**
  50818. * Gets or sets the distance when this optimized version should be used
  50819. */
  50820. distance: number;
  50821. /**
  50822. * Gets an already optimized mesh
  50823. */
  50824. optimizeMesh?: boolean;
  50825. }
  50826. /**
  50827. * Class used to specify simplification options
  50828. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50829. */
  50830. export class SimplificationSettings implements ISimplificationSettings {
  50831. /** expected quality */
  50832. quality: number;
  50833. /** distance when this optimized version should be used */
  50834. distance: number;
  50835. /** already optimized mesh */
  50836. optimizeMesh?: boolean | undefined;
  50837. /**
  50838. * Creates a SimplificationSettings
  50839. * @param quality expected quality
  50840. * @param distance distance when this optimized version should be used
  50841. * @param optimizeMesh already optimized mesh
  50842. */
  50843. constructor(
  50844. /** expected quality */
  50845. quality: number,
  50846. /** distance when this optimized version should be used */
  50847. distance: number,
  50848. /** already optimized mesh */
  50849. optimizeMesh?: boolean | undefined);
  50850. }
  50851. /**
  50852. * Interface used to define a simplification task
  50853. */
  50854. export interface ISimplificationTask {
  50855. /**
  50856. * Array of settings
  50857. */
  50858. settings: Array<ISimplificationSettings>;
  50859. /**
  50860. * Simplification type
  50861. */
  50862. simplificationType: SimplificationType;
  50863. /**
  50864. * Mesh to simplify
  50865. */
  50866. mesh: Mesh;
  50867. /**
  50868. * Callback called on success
  50869. */
  50870. successCallback?: () => void;
  50871. /**
  50872. * Defines if parallel processing can be used
  50873. */
  50874. parallelProcessing: boolean;
  50875. }
  50876. /**
  50877. * Queue used to order the simplification tasks
  50878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50879. */
  50880. export class SimplificationQueue {
  50881. private _simplificationArray;
  50882. /**
  50883. * Gets a boolean indicating that the process is still running
  50884. */
  50885. running: boolean;
  50886. /**
  50887. * Creates a new queue
  50888. */
  50889. constructor();
  50890. /**
  50891. * Adds a new simplification task
  50892. * @param task defines a task to add
  50893. */
  50894. addTask(task: ISimplificationTask): void;
  50895. /**
  50896. * Execute next task
  50897. */
  50898. executeNext(): void;
  50899. /**
  50900. * Execute a simplification task
  50901. * @param task defines the task to run
  50902. */
  50903. runSimplification(task: ISimplificationTask): void;
  50904. private getSimplifier;
  50905. }
  50906. /**
  50907. * The implemented types of simplification
  50908. * At the moment only Quadratic Error Decimation is implemented
  50909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50910. */
  50911. export enum SimplificationType {
  50912. /** Quadratic error decimation */
  50913. QUADRATIC = 0
  50914. }
  50915. }
  50916. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50917. import { Scene } from "babylonjs/scene";
  50918. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50919. import { ISceneComponent } from "babylonjs/sceneComponent";
  50920. module "babylonjs/scene" {
  50921. interface Scene {
  50922. /** @hidden (Backing field) */
  50923. _simplificationQueue: SimplificationQueue;
  50924. /**
  50925. * Gets or sets the simplification queue attached to the scene
  50926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50927. */
  50928. simplificationQueue: SimplificationQueue;
  50929. }
  50930. }
  50931. module "babylonjs/Meshes/mesh" {
  50932. interface Mesh {
  50933. /**
  50934. * Simplify the mesh according to the given array of settings.
  50935. * Function will return immediately and will simplify async
  50936. * @param settings a collection of simplification settings
  50937. * @param parallelProcessing should all levels calculate parallel or one after the other
  50938. * @param simplificationType the type of simplification to run
  50939. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50940. * @returns the current mesh
  50941. */
  50942. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50943. }
  50944. }
  50945. /**
  50946. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50947. * created in a scene
  50948. */
  50949. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50950. /**
  50951. * The component name helpfull to identify the component in the list of scene components.
  50952. */
  50953. readonly name: string;
  50954. /**
  50955. * The scene the component belongs to.
  50956. */
  50957. scene: Scene;
  50958. /**
  50959. * Creates a new instance of the component for the given scene
  50960. * @param scene Defines the scene to register the component in
  50961. */
  50962. constructor(scene: Scene);
  50963. /**
  50964. * Registers the component in a given scene
  50965. */
  50966. register(): void;
  50967. /**
  50968. * Rebuilds the elements related to this component in case of
  50969. * context lost for instance.
  50970. */
  50971. rebuild(): void;
  50972. /**
  50973. * Disposes the component and the associated ressources
  50974. */
  50975. dispose(): void;
  50976. private _beforeCameraUpdate;
  50977. }
  50978. }
  50979. declare module "babylonjs/Meshes/Builders/index" {
  50980. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50981. export * from "babylonjs/Meshes/Builders/discBuilder";
  50982. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50983. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50984. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50985. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50986. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50987. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50988. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50989. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50990. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50991. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50992. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50993. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50994. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50995. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50996. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50997. }
  50998. declare module "babylonjs/Meshes/index" {
  50999. export * from "babylonjs/Meshes/abstractMesh";
  51000. export * from "babylonjs/Meshes/buffer";
  51001. export * from "babylonjs/Meshes/Compression/index";
  51002. export * from "babylonjs/Meshes/csg";
  51003. export * from "babylonjs/Meshes/geometry";
  51004. export * from "babylonjs/Meshes/groundMesh";
  51005. export * from "babylonjs/Meshes/trailMesh";
  51006. export * from "babylonjs/Meshes/instancedMesh";
  51007. export * from "babylonjs/Meshes/linesMesh";
  51008. export * from "babylonjs/Meshes/mesh";
  51009. export * from "babylonjs/Meshes/mesh.vertexData";
  51010. export * from "babylonjs/Meshes/meshBuilder";
  51011. export * from "babylonjs/Meshes/meshSimplification";
  51012. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51013. export * from "babylonjs/Meshes/polygonMesh";
  51014. export * from "babylonjs/Meshes/subMesh";
  51015. export * from "babylonjs/Meshes/transformNode";
  51016. export * from "babylonjs/Meshes/Builders/index";
  51017. }
  51018. declare module "babylonjs/Morph/index" {
  51019. export * from "babylonjs/Morph/morphTarget";
  51020. export * from "babylonjs/Morph/morphTargetManager";
  51021. }
  51022. declare module "babylonjs/Offline/database" {
  51023. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51024. /**
  51025. * Class used to enable access to IndexedDB
  51026. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51027. */
  51028. export class Database implements IOfflineProvider {
  51029. private _callbackManifestChecked;
  51030. private _currentSceneUrl;
  51031. private _db;
  51032. private _enableSceneOffline;
  51033. private _enableTexturesOffline;
  51034. private _manifestVersionFound;
  51035. private _mustUpdateRessources;
  51036. private _hasReachedQuota;
  51037. private _isSupported;
  51038. private _idbFactory;
  51039. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51040. private static IsUASupportingBlobStorage;
  51041. /**
  51042. * Gets a boolean indicating if Database storate is enabled (off by default)
  51043. */
  51044. static IDBStorageEnabled: boolean;
  51045. /**
  51046. * Gets a boolean indicating if scene must be saved in the database
  51047. */
  51048. readonly enableSceneOffline: boolean;
  51049. /**
  51050. * Gets a boolean indicating if textures must be saved in the database
  51051. */
  51052. readonly enableTexturesOffline: boolean;
  51053. /**
  51054. * Creates a new Database
  51055. * @param urlToScene defines the url to load the scene
  51056. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51057. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51058. */
  51059. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51060. private static _ParseURL;
  51061. private static _ReturnFullUrlLocation;
  51062. private _checkManifestFile;
  51063. /**
  51064. * Open the database and make it available
  51065. * @param successCallback defines the callback to call on success
  51066. * @param errorCallback defines the callback to call on error
  51067. */
  51068. open(successCallback: () => void, errorCallback: () => void): void;
  51069. /**
  51070. * Loads an image from the database
  51071. * @param url defines the url to load from
  51072. * @param image defines the target DOM image
  51073. */
  51074. loadImage(url: string, image: HTMLImageElement): void;
  51075. private _loadImageFromDBAsync;
  51076. private _saveImageIntoDBAsync;
  51077. private _checkVersionFromDB;
  51078. private _loadVersionFromDBAsync;
  51079. private _saveVersionIntoDBAsync;
  51080. /**
  51081. * Loads a file from database
  51082. * @param url defines the URL to load from
  51083. * @param sceneLoaded defines a callback to call on success
  51084. * @param progressCallBack defines a callback to call when progress changed
  51085. * @param errorCallback defines a callback to call on error
  51086. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51087. */
  51088. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51089. private _loadFileAsync;
  51090. private _saveFileAsync;
  51091. /**
  51092. * Validates if xhr data is correct
  51093. * @param xhr defines the request to validate
  51094. * @param dataType defines the expected data type
  51095. * @returns true if data is correct
  51096. */
  51097. private static _ValidateXHRData;
  51098. }
  51099. }
  51100. declare module "babylonjs/Offline/index" {
  51101. export * from "babylonjs/Offline/database";
  51102. export * from "babylonjs/Offline/IOfflineProvider";
  51103. }
  51104. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51105. /** @hidden */
  51106. export var gpuUpdateParticlesPixelShader: {
  51107. name: string;
  51108. shader: string;
  51109. };
  51110. }
  51111. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51112. /** @hidden */
  51113. export var gpuUpdateParticlesVertexShader: {
  51114. name: string;
  51115. shader: string;
  51116. };
  51117. }
  51118. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51119. /** @hidden */
  51120. export var clipPlaneFragmentDeclaration2: {
  51121. name: string;
  51122. shader: string;
  51123. };
  51124. }
  51125. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51126. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51129. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51130. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51131. /** @hidden */
  51132. export var gpuRenderParticlesPixelShader: {
  51133. name: string;
  51134. shader: string;
  51135. };
  51136. }
  51137. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51138. /** @hidden */
  51139. export var clipPlaneVertexDeclaration2: {
  51140. name: string;
  51141. shader: string;
  51142. };
  51143. }
  51144. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51145. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51147. /** @hidden */
  51148. export var gpuRenderParticlesVertexShader: {
  51149. name: string;
  51150. shader: string;
  51151. };
  51152. }
  51153. declare module "babylonjs/Particles/gpuParticleSystem" {
  51154. import { Nullable } from "babylonjs/types";
  51155. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51156. import { Observable } from "babylonjs/Misc/observable";
  51157. import { Color4, Color3 } from "babylonjs/Maths/math";
  51158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51159. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51160. import { Scene, IDisposable } from "babylonjs/scene";
  51161. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51162. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51163. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51164. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51165. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51166. /**
  51167. * This represents a GPU particle system in Babylon
  51168. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51169. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51170. */
  51171. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51172. /**
  51173. * The layer mask we are rendering the particles through.
  51174. */
  51175. layerMask: number;
  51176. private _capacity;
  51177. private _activeCount;
  51178. private _currentActiveCount;
  51179. private _accumulatedCount;
  51180. private _renderEffect;
  51181. private _updateEffect;
  51182. private _buffer0;
  51183. private _buffer1;
  51184. private _spriteBuffer;
  51185. private _updateVAO;
  51186. private _renderVAO;
  51187. private _targetIndex;
  51188. private _sourceBuffer;
  51189. private _targetBuffer;
  51190. private _engine;
  51191. private _currentRenderId;
  51192. private _started;
  51193. private _stopped;
  51194. private _timeDelta;
  51195. private _randomTexture;
  51196. private _randomTexture2;
  51197. private _attributesStrideSize;
  51198. private _updateEffectOptions;
  51199. private _randomTextureSize;
  51200. private _actualFrame;
  51201. private readonly _rawTextureWidth;
  51202. /**
  51203. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51204. */
  51205. static readonly IsSupported: boolean;
  51206. /**
  51207. * An event triggered when the system is disposed.
  51208. */
  51209. onDisposeObservable: Observable<GPUParticleSystem>;
  51210. /**
  51211. * Gets the maximum number of particles active at the same time.
  51212. * @returns The max number of active particles.
  51213. */
  51214. getCapacity(): number;
  51215. /**
  51216. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51217. * to override the particles.
  51218. */
  51219. forceDepthWrite: boolean;
  51220. /**
  51221. * Gets or set the number of active particles
  51222. */
  51223. activeParticleCount: number;
  51224. private _preWarmDone;
  51225. /**
  51226. * Is this system ready to be used/rendered
  51227. * @return true if the system is ready
  51228. */
  51229. isReady(): boolean;
  51230. /**
  51231. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51232. * @returns True if it has been started, otherwise false.
  51233. */
  51234. isStarted(): boolean;
  51235. /**
  51236. * Starts the particle system and begins to emit
  51237. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51238. */
  51239. start(delay?: number): void;
  51240. /**
  51241. * Stops the particle system.
  51242. */
  51243. stop(): void;
  51244. /**
  51245. * Remove all active particles
  51246. */
  51247. reset(): void;
  51248. /**
  51249. * Returns the string "GPUParticleSystem"
  51250. * @returns a string containing the class name
  51251. */
  51252. getClassName(): string;
  51253. private _colorGradientsTexture;
  51254. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51255. /**
  51256. * Adds a new color gradient
  51257. * @param gradient defines the gradient to use (between 0 and 1)
  51258. * @param color1 defines the color to affect to the specified gradient
  51259. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51260. * @returns the current particle system
  51261. */
  51262. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51263. /**
  51264. * Remove a specific color gradient
  51265. * @param gradient defines the gradient to remove
  51266. * @returns the current particle system
  51267. */
  51268. removeColorGradient(gradient: number): GPUParticleSystem;
  51269. private _angularSpeedGradientsTexture;
  51270. private _sizeGradientsTexture;
  51271. private _velocityGradientsTexture;
  51272. private _limitVelocityGradientsTexture;
  51273. private _dragGradientsTexture;
  51274. private _addFactorGradient;
  51275. /**
  51276. * Adds a new size gradient
  51277. * @param gradient defines the gradient to use (between 0 and 1)
  51278. * @param factor defines the size factor to affect to the specified gradient
  51279. * @returns the current particle system
  51280. */
  51281. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51282. /**
  51283. * Remove a specific size gradient
  51284. * @param gradient defines the gradient to remove
  51285. * @returns the current particle system
  51286. */
  51287. removeSizeGradient(gradient: number): GPUParticleSystem;
  51288. /**
  51289. * Adds a new angular speed gradient
  51290. * @param gradient defines the gradient to use (between 0 and 1)
  51291. * @param factor defines the angular speed to affect to the specified gradient
  51292. * @returns the current particle system
  51293. */
  51294. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51295. /**
  51296. * Remove a specific angular speed gradient
  51297. * @param gradient defines the gradient to remove
  51298. * @returns the current particle system
  51299. */
  51300. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51301. /**
  51302. * Adds a new velocity gradient
  51303. * @param gradient defines the gradient to use (between 0 and 1)
  51304. * @param factor defines the velocity to affect to the specified gradient
  51305. * @returns the current particle system
  51306. */
  51307. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51308. /**
  51309. * Remove a specific velocity gradient
  51310. * @param gradient defines the gradient to remove
  51311. * @returns the current particle system
  51312. */
  51313. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51314. /**
  51315. * Adds a new limit velocity gradient
  51316. * @param gradient defines the gradient to use (between 0 and 1)
  51317. * @param factor defines the limit velocity value to affect to the specified gradient
  51318. * @returns the current particle system
  51319. */
  51320. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51321. /**
  51322. * Remove a specific limit velocity gradient
  51323. * @param gradient defines the gradient to remove
  51324. * @returns the current particle system
  51325. */
  51326. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51327. /**
  51328. * Adds a new drag gradient
  51329. * @param gradient defines the gradient to use (between 0 and 1)
  51330. * @param factor defines the drag value to affect to the specified gradient
  51331. * @returns the current particle system
  51332. */
  51333. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51334. /**
  51335. * Remove a specific drag gradient
  51336. * @param gradient defines the gradient to remove
  51337. * @returns the current particle system
  51338. */
  51339. removeDragGradient(gradient: number): GPUParticleSystem;
  51340. /**
  51341. * Not supported by GPUParticleSystem
  51342. * @param gradient defines the gradient to use (between 0 and 1)
  51343. * @param factor defines the emit rate value to affect to the specified gradient
  51344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51345. * @returns the current particle system
  51346. */
  51347. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51348. /**
  51349. * Not supported by GPUParticleSystem
  51350. * @param gradient defines the gradient to remove
  51351. * @returns the current particle system
  51352. */
  51353. removeEmitRateGradient(gradient: number): IParticleSystem;
  51354. /**
  51355. * Not supported by GPUParticleSystem
  51356. * @param gradient defines the gradient to use (between 0 and 1)
  51357. * @param factor defines the start size value to affect to the specified gradient
  51358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51359. * @returns the current particle system
  51360. */
  51361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51362. /**
  51363. * Not supported by GPUParticleSystem
  51364. * @param gradient defines the gradient to remove
  51365. * @returns the current particle system
  51366. */
  51367. removeStartSizeGradient(gradient: number): IParticleSystem;
  51368. /**
  51369. * Not supported by GPUParticleSystem
  51370. * @param gradient defines the gradient to use (between 0 and 1)
  51371. * @param min defines the color remap minimal range
  51372. * @param max defines the color remap maximal range
  51373. * @returns the current particle system
  51374. */
  51375. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51376. /**
  51377. * Not supported by GPUParticleSystem
  51378. * @param gradient defines the gradient to remove
  51379. * @returns the current particle system
  51380. */
  51381. removeColorRemapGradient(): IParticleSystem;
  51382. /**
  51383. * Not supported by GPUParticleSystem
  51384. * @param gradient defines the gradient to use (between 0 and 1)
  51385. * @param min defines the alpha remap minimal range
  51386. * @param max defines the alpha remap maximal range
  51387. * @returns the current particle system
  51388. */
  51389. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51390. /**
  51391. * Not supported by GPUParticleSystem
  51392. * @param gradient defines the gradient to remove
  51393. * @returns the current particle system
  51394. */
  51395. removeAlphaRemapGradient(): IParticleSystem;
  51396. /**
  51397. * Not supported by GPUParticleSystem
  51398. * @param gradient defines the gradient to use (between 0 and 1)
  51399. * @param color defines the color to affect to the specified gradient
  51400. * @returns the current particle system
  51401. */
  51402. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51403. /**
  51404. * Not supported by GPUParticleSystem
  51405. * @param gradient defines the gradient to remove
  51406. * @returns the current particle system
  51407. */
  51408. removeRampGradient(): IParticleSystem;
  51409. /**
  51410. * Not supported by GPUParticleSystem
  51411. * @returns the list of ramp gradients
  51412. */
  51413. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51414. /**
  51415. * Not supported by GPUParticleSystem
  51416. * Gets or sets a boolean indicating that ramp gradients must be used
  51417. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51418. */
  51419. useRampGradients: boolean;
  51420. /**
  51421. * Not supported by GPUParticleSystem
  51422. * @param gradient defines the gradient to use (between 0 and 1)
  51423. * @param factor defines the life time factor to affect to the specified gradient
  51424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51425. * @returns the current particle system
  51426. */
  51427. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51428. /**
  51429. * Not supported by GPUParticleSystem
  51430. * @param gradient defines the gradient to remove
  51431. * @returns the current particle system
  51432. */
  51433. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51434. /**
  51435. * Instantiates a GPU particle system.
  51436. * 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.
  51437. * @param name The name of the particle system
  51438. * @param options The options used to create the system
  51439. * @param scene The scene the particle system belongs to
  51440. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51441. */
  51442. constructor(name: string, options: Partial<{
  51443. capacity: number;
  51444. randomTextureSize: number;
  51445. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51446. protected _reset(): void;
  51447. private _createUpdateVAO;
  51448. private _createRenderVAO;
  51449. private _initialize;
  51450. /** @hidden */
  51451. _recreateUpdateEffect(): void;
  51452. /** @hidden */
  51453. _recreateRenderEffect(): void;
  51454. /**
  51455. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51456. * @param preWarm defines if we are in the pre-warmimg phase
  51457. */
  51458. animate(preWarm?: boolean): void;
  51459. private _createFactorGradientTexture;
  51460. private _createSizeGradientTexture;
  51461. private _createAngularSpeedGradientTexture;
  51462. private _createVelocityGradientTexture;
  51463. private _createLimitVelocityGradientTexture;
  51464. private _createDragGradientTexture;
  51465. private _createColorGradientTexture;
  51466. /**
  51467. * Renders the particle system in its current state
  51468. * @param preWarm defines if the system should only update the particles but not render them
  51469. * @returns the current number of particles
  51470. */
  51471. render(preWarm?: boolean): number;
  51472. /**
  51473. * Rebuilds the particle system
  51474. */
  51475. rebuild(): void;
  51476. private _releaseBuffers;
  51477. private _releaseVAOs;
  51478. /**
  51479. * Disposes the particle system and free the associated resources
  51480. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51481. */
  51482. dispose(disposeTexture?: boolean): void;
  51483. /**
  51484. * Clones the particle system.
  51485. * @param name The name of the cloned object
  51486. * @param newEmitter The new emitter to use
  51487. * @returns the cloned particle system
  51488. */
  51489. clone(name: string, newEmitter: any): GPUParticleSystem;
  51490. /**
  51491. * Serializes the particle system to a JSON object.
  51492. * @returns the JSON object
  51493. */
  51494. serialize(): any;
  51495. /**
  51496. * Parses a JSON object to create a GPU particle system.
  51497. * @param parsedParticleSystem The JSON object to parse
  51498. * @param scene The scene to create the particle system in
  51499. * @param rootUrl The root url to use to load external dependencies like texture
  51500. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51501. * @returns the parsed GPU particle system
  51502. */
  51503. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51504. }
  51505. }
  51506. declare module "babylonjs/Particles/particleSystemSet" {
  51507. import { Nullable } from "babylonjs/types";
  51508. import { Color3 } from "babylonjs/Maths/math";
  51509. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51511. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51512. import { Scene, IDisposable } from "babylonjs/scene";
  51513. /**
  51514. * Represents a set of particle systems working together to create a specific effect
  51515. */
  51516. export class ParticleSystemSet implements IDisposable {
  51517. private _emitterCreationOptions;
  51518. private _emitterNode;
  51519. /**
  51520. * Gets the particle system list
  51521. */
  51522. systems: IParticleSystem[];
  51523. /**
  51524. * Gets the emitter node used with this set
  51525. */
  51526. readonly emitterNode: Nullable<TransformNode>;
  51527. /**
  51528. * Creates a new emitter mesh as a sphere
  51529. * @param options defines the options used to create the sphere
  51530. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51531. * @param scene defines the hosting scene
  51532. */
  51533. setEmitterAsSphere(options: {
  51534. diameter: number;
  51535. segments: number;
  51536. color: Color3;
  51537. }, renderingGroupId: number, scene: Scene): void;
  51538. /**
  51539. * Starts all particle systems of the set
  51540. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51541. */
  51542. start(emitter?: AbstractMesh): void;
  51543. /**
  51544. * Release all associated resources
  51545. */
  51546. dispose(): void;
  51547. /**
  51548. * Serialize the set into a JSON compatible object
  51549. * @returns a JSON compatible representation of the set
  51550. */
  51551. serialize(): any;
  51552. /**
  51553. * Parse a new ParticleSystemSet from a serialized source
  51554. * @param data defines a JSON compatible representation of the set
  51555. * @param scene defines the hosting scene
  51556. * @param gpu defines if we want GPU particles or CPU particles
  51557. * @returns a new ParticleSystemSet
  51558. */
  51559. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51560. }
  51561. }
  51562. declare module "babylonjs/Particles/particleHelper" {
  51563. import { Nullable } from "babylonjs/types";
  51564. import { Scene } from "babylonjs/scene";
  51565. import { Vector3 } from "babylonjs/Maths/math";
  51566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51567. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51568. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51569. /**
  51570. * This class is made for on one-liner static method to help creating particle system set.
  51571. */
  51572. export class ParticleHelper {
  51573. /**
  51574. * Gets or sets base Assets URL
  51575. */
  51576. static BaseAssetsUrl: string;
  51577. /**
  51578. * Create a default particle system that you can tweak
  51579. * @param emitter defines the emitter to use
  51580. * @param capacity defines the system capacity (default is 500 particles)
  51581. * @param scene defines the hosting scene
  51582. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51583. * @returns the new Particle system
  51584. */
  51585. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51586. /**
  51587. * This is the main static method (one-liner) of this helper to create different particle systems
  51588. * @param type This string represents the type to the particle system to create
  51589. * @param scene The scene where the particle system should live
  51590. * @param gpu If the system will use gpu
  51591. * @returns the ParticleSystemSet created
  51592. */
  51593. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51594. /**
  51595. * Static function used to export a particle system to a ParticleSystemSet variable.
  51596. * Please note that the emitter shape is not exported
  51597. * @param systems defines the particle systems to export
  51598. * @returns the created particle system set
  51599. */
  51600. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51601. }
  51602. }
  51603. declare module "babylonjs/Particles/particleSystemComponent" {
  51604. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51605. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51606. import "babylonjs/Shaders/particles.vertex";
  51607. module "babylonjs/Engines/engine" {
  51608. interface Engine {
  51609. /**
  51610. * Create an effect to use with particle systems.
  51611. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51612. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51613. * @param uniformsNames defines a list of attribute names
  51614. * @param samplers defines an array of string used to represent textures
  51615. * @param defines defines the string containing the defines to use to compile the shaders
  51616. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51617. * @param onCompiled defines a function to call when the effect creation is successful
  51618. * @param onError defines a function to call when the effect creation has failed
  51619. * @returns the new Effect
  51620. */
  51621. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51622. }
  51623. }
  51624. module "babylonjs/Meshes/mesh" {
  51625. interface Mesh {
  51626. /**
  51627. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51628. * @returns an array of IParticleSystem
  51629. */
  51630. getEmittedParticleSystems(): IParticleSystem[];
  51631. /**
  51632. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51633. * @returns an array of IParticleSystem
  51634. */
  51635. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51636. }
  51637. }
  51638. /**
  51639. * @hidden
  51640. */
  51641. export var _IDoNeedToBeInTheBuild: number;
  51642. }
  51643. declare module "babylonjs/Particles/index" {
  51644. export * from "babylonjs/Particles/baseParticleSystem";
  51645. export * from "babylonjs/Particles/EmitterTypes/index";
  51646. export * from "babylonjs/Particles/gpuParticleSystem";
  51647. export * from "babylonjs/Particles/IParticleSystem";
  51648. export * from "babylonjs/Particles/particle";
  51649. export * from "babylonjs/Particles/particleHelper";
  51650. export * from "babylonjs/Particles/particleSystem";
  51651. export * from "babylonjs/Particles/particleSystemComponent";
  51652. export * from "babylonjs/Particles/particleSystemSet";
  51653. export * from "babylonjs/Particles/solidParticle";
  51654. export * from "babylonjs/Particles/solidParticleSystem";
  51655. export * from "babylonjs/Particles/subEmitter";
  51656. }
  51657. declare module "babylonjs/Physics/physicsEngineComponent" {
  51658. import { Nullable } from "babylonjs/types";
  51659. import { Observable, Observer } from "babylonjs/Misc/observable";
  51660. import { Vector3 } from "babylonjs/Maths/math";
  51661. import { Mesh } from "babylonjs/Meshes/mesh";
  51662. import { ISceneComponent } from "babylonjs/sceneComponent";
  51663. import { Scene } from "babylonjs/scene";
  51664. import { Node } from "babylonjs/node";
  51665. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51666. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51667. module "babylonjs/scene" {
  51668. interface Scene {
  51669. /** @hidden (Backing field) */
  51670. _physicsEngine: Nullable<IPhysicsEngine>;
  51671. /**
  51672. * Gets the current physics engine
  51673. * @returns a IPhysicsEngine or null if none attached
  51674. */
  51675. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51676. /**
  51677. * Enables physics to the current scene
  51678. * @param gravity defines the scene's gravity for the physics engine
  51679. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51680. * @return a boolean indicating if the physics engine was initialized
  51681. */
  51682. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51683. /**
  51684. * Disables and disposes the physics engine associated with the scene
  51685. */
  51686. disablePhysicsEngine(): void;
  51687. /**
  51688. * Gets a boolean indicating if there is an active physics engine
  51689. * @returns a boolean indicating if there is an active physics engine
  51690. */
  51691. isPhysicsEnabled(): boolean;
  51692. /**
  51693. * Deletes a physics compound impostor
  51694. * @param compound defines the compound to delete
  51695. */
  51696. deleteCompoundImpostor(compound: any): void;
  51697. /**
  51698. * An event triggered when physic simulation is about to be run
  51699. */
  51700. onBeforePhysicsObservable: Observable<Scene>;
  51701. /**
  51702. * An event triggered when physic simulation has been done
  51703. */
  51704. onAfterPhysicsObservable: Observable<Scene>;
  51705. }
  51706. }
  51707. module "babylonjs/Meshes/abstractMesh" {
  51708. interface AbstractMesh {
  51709. /** @hidden */
  51710. _physicsImpostor: Nullable<PhysicsImpostor>;
  51711. /**
  51712. * Gets or sets impostor used for physic simulation
  51713. * @see http://doc.babylonjs.com/features/physics_engine
  51714. */
  51715. physicsImpostor: Nullable<PhysicsImpostor>;
  51716. /**
  51717. * Gets the current physics impostor
  51718. * @see http://doc.babylonjs.com/features/physics_engine
  51719. * @returns a physics impostor or null
  51720. */
  51721. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51722. /** Apply a physic impulse to the mesh
  51723. * @param force defines the force to apply
  51724. * @param contactPoint defines where to apply the force
  51725. * @returns the current mesh
  51726. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51727. */
  51728. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51729. /**
  51730. * Creates a physic joint between two meshes
  51731. * @param otherMesh defines the other mesh to use
  51732. * @param pivot1 defines the pivot to use on this mesh
  51733. * @param pivot2 defines the pivot to use on the other mesh
  51734. * @param options defines additional options (can be plugin dependent)
  51735. * @returns the current mesh
  51736. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51737. */
  51738. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51739. /** @hidden */
  51740. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51741. }
  51742. }
  51743. /**
  51744. * Defines the physics engine scene component responsible to manage a physics engine
  51745. */
  51746. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51747. /**
  51748. * The component name helpful to identify the component in the list of scene components.
  51749. */
  51750. readonly name: string;
  51751. /**
  51752. * The scene the component belongs to.
  51753. */
  51754. scene: Scene;
  51755. /**
  51756. * Creates a new instance of the component for the given scene
  51757. * @param scene Defines the scene to register the component in
  51758. */
  51759. constructor(scene: Scene);
  51760. /**
  51761. * Registers the component in a given scene
  51762. */
  51763. register(): void;
  51764. /**
  51765. * Rebuilds the elements related to this component in case of
  51766. * context lost for instance.
  51767. */
  51768. rebuild(): void;
  51769. /**
  51770. * Disposes the component and the associated ressources
  51771. */
  51772. dispose(): void;
  51773. }
  51774. }
  51775. declare module "babylonjs/Physics/physicsHelper" {
  51776. import { Nullable } from "babylonjs/types";
  51777. import { Vector3 } from "babylonjs/Maths/math";
  51778. import { Mesh } from "babylonjs/Meshes/mesh";
  51779. import { Ray } from "babylonjs/Culling/ray";
  51780. import { Scene } from "babylonjs/scene";
  51781. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51782. /**
  51783. * A helper for physics simulations
  51784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51785. */
  51786. export class PhysicsHelper {
  51787. private _scene;
  51788. private _physicsEngine;
  51789. /**
  51790. * Initializes the Physics helper
  51791. * @param scene Babylon.js scene
  51792. */
  51793. constructor(scene: Scene);
  51794. /**
  51795. * Applies a radial explosion impulse
  51796. * @param origin the origin of the explosion
  51797. * @param radius the explosion radius
  51798. * @param strength the explosion strength
  51799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51800. * @returns A physics radial explosion event, or null
  51801. */
  51802. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51803. /**
  51804. * Applies a radial explosion force
  51805. * @param origin the origin of the explosion
  51806. * @param radius the explosion radius
  51807. * @param strength the explosion strength
  51808. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51809. * @returns A physics radial explosion event, or null
  51810. */
  51811. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51812. /**
  51813. * Creates a gravitational field
  51814. * @param origin the origin of the explosion
  51815. * @param radius the explosion radius
  51816. * @param strength the explosion strength
  51817. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51818. * @returns A physics gravitational field event, or null
  51819. */
  51820. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51821. /**
  51822. * Creates a physics updraft event
  51823. * @param origin the origin of the updraft
  51824. * @param radius the radius of the updraft
  51825. * @param strength the strength of the updraft
  51826. * @param height the height of the updraft
  51827. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51828. * @returns A physics updraft event, or null
  51829. */
  51830. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51831. /**
  51832. * Creates a physics vortex event
  51833. * @param origin the of the vortex
  51834. * @param radius the radius of the vortex
  51835. * @param strength the strength of the vortex
  51836. * @param height the height of the vortex
  51837. * @returns a Physics vortex event, or null
  51838. * A physics vortex event or null
  51839. */
  51840. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51841. }
  51842. /**
  51843. * Represents a physics radial explosion event
  51844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51845. */
  51846. export class PhysicsRadialExplosionEvent {
  51847. private _scene;
  51848. private _sphere;
  51849. private _sphereOptions;
  51850. private _rays;
  51851. private _dataFetched;
  51852. /**
  51853. * Initializes a radial explosioin event
  51854. * @param scene BabylonJS scene
  51855. */
  51856. constructor(scene: Scene);
  51857. /**
  51858. * Returns the data related to the radial explosion event (sphere & rays).
  51859. * @returns The radial explosion event data
  51860. */
  51861. getData(): PhysicsRadialExplosionEventData;
  51862. /**
  51863. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51864. * @param impostor A physics imposter
  51865. * @param origin the origin of the explosion
  51866. * @param radius the explosion radius
  51867. * @param strength the explosion strength
  51868. * @param falloff possible options: Constant & Linear
  51869. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51870. */
  51871. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51872. /**
  51873. * Disposes the sphere.
  51874. * @param force Specifies if the sphere should be disposed by force
  51875. */
  51876. dispose(force?: boolean): void;
  51877. /*** Helpers ***/
  51878. private _prepareSphere;
  51879. private _intersectsWithSphere;
  51880. }
  51881. /**
  51882. * Represents a gravitational field event
  51883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51884. */
  51885. export class PhysicsGravitationalFieldEvent {
  51886. private _physicsHelper;
  51887. private _scene;
  51888. private _origin;
  51889. private _radius;
  51890. private _strength;
  51891. private _falloff;
  51892. private _tickCallback;
  51893. private _sphere;
  51894. private _dataFetched;
  51895. /**
  51896. * Initializes the physics gravitational field event
  51897. * @param physicsHelper A physics helper
  51898. * @param scene BabylonJS scene
  51899. * @param origin The origin position of the gravitational field event
  51900. * @param radius The radius of the gravitational field event
  51901. * @param strength The strength of the gravitational field event
  51902. * @param falloff The falloff for the gravitational field event
  51903. */
  51904. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51905. /**
  51906. * Returns the data related to the gravitational field event (sphere).
  51907. * @returns A gravitational field event
  51908. */
  51909. getData(): PhysicsGravitationalFieldEventData;
  51910. /**
  51911. * Enables the gravitational field.
  51912. */
  51913. enable(): void;
  51914. /**
  51915. * Disables the gravitational field.
  51916. */
  51917. disable(): void;
  51918. /**
  51919. * Disposes the sphere.
  51920. * @param force The force to dispose from the gravitational field event
  51921. */
  51922. dispose(force?: boolean): void;
  51923. private _tick;
  51924. }
  51925. /**
  51926. * Represents a physics updraft event
  51927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51928. */
  51929. export class PhysicsUpdraftEvent {
  51930. private _scene;
  51931. private _origin;
  51932. private _radius;
  51933. private _strength;
  51934. private _height;
  51935. private _updraftMode;
  51936. private _physicsEngine;
  51937. private _originTop;
  51938. private _originDirection;
  51939. private _tickCallback;
  51940. private _cylinder;
  51941. private _cylinderPosition;
  51942. private _dataFetched;
  51943. /**
  51944. * Initializes the physics updraft event
  51945. * @param _scene BabylonJS scene
  51946. * @param _origin The origin position of the updraft
  51947. * @param _radius The radius of the updraft
  51948. * @param _strength The strength of the updraft
  51949. * @param _height The height of the updraft
  51950. * @param _updraftMode The mode of the updraft
  51951. */
  51952. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51953. /**
  51954. * Returns the data related to the updraft event (cylinder).
  51955. * @returns A physics updraft event
  51956. */
  51957. getData(): PhysicsUpdraftEventData;
  51958. /**
  51959. * Enables the updraft.
  51960. */
  51961. enable(): void;
  51962. /**
  51963. * Disables the cortex.
  51964. */
  51965. disable(): void;
  51966. /**
  51967. * Disposes the sphere.
  51968. * @param force Specifies if the updraft should be disposed by force
  51969. */
  51970. dispose(force?: boolean): void;
  51971. private getImpostorForceAndContactPoint;
  51972. private _tick;
  51973. /*** Helpers ***/
  51974. private _prepareCylinder;
  51975. private _intersectsWithCylinder;
  51976. }
  51977. /**
  51978. * Represents a physics vortex event
  51979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51980. */
  51981. export class PhysicsVortexEvent {
  51982. private _scene;
  51983. private _origin;
  51984. private _radius;
  51985. private _strength;
  51986. private _height;
  51987. private _physicsEngine;
  51988. private _originTop;
  51989. private _centripetalForceThreshold;
  51990. private _updraftMultiplier;
  51991. private _tickCallback;
  51992. private _cylinder;
  51993. private _cylinderPosition;
  51994. private _dataFetched;
  51995. /**
  51996. * Initializes the physics vortex event
  51997. * @param _scene The BabylonJS scene
  51998. * @param _origin The origin position of the vortex
  51999. * @param _radius The radius of the vortex
  52000. * @param _strength The strength of the vortex
  52001. * @param _height The height of the vortex
  52002. */
  52003. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52004. /**
  52005. * Returns the data related to the vortex event (cylinder).
  52006. * @returns The physics vortex event data
  52007. */
  52008. getData(): PhysicsVortexEventData;
  52009. /**
  52010. * Enables the vortex.
  52011. */
  52012. enable(): void;
  52013. /**
  52014. * Disables the cortex.
  52015. */
  52016. disable(): void;
  52017. /**
  52018. * Disposes the sphere.
  52019. * @param force
  52020. */
  52021. dispose(force?: boolean): void;
  52022. private getImpostorForceAndContactPoint;
  52023. private _tick;
  52024. /*** Helpers ***/
  52025. private _prepareCylinder;
  52026. private _intersectsWithCylinder;
  52027. }
  52028. /**
  52029. * The strenght 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 PhysicsRadialImpulseFalloff {
  52033. /** Defines that impulse is constant in strength across it's whole radius */
  52034. Constant = 0,
  52035. /** DEfines that impulse gets weaker if it's further from the origin */
  52036. Linear = 1
  52037. }
  52038. /**
  52039. * The strength of the force in correspondence to the distance of the affected object
  52040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52041. */
  52042. export enum PhysicsUpdraftMode {
  52043. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52044. Center = 0,
  52045. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52046. Perpendicular = 1
  52047. }
  52048. /**
  52049. * Interface for a physics force and contact point
  52050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52051. */
  52052. export interface PhysicsForceAndContactPoint {
  52053. /**
  52054. * The force applied at the contact point
  52055. */
  52056. force: Vector3;
  52057. /**
  52058. * The contact point
  52059. */
  52060. contactPoint: Vector3;
  52061. }
  52062. /**
  52063. * Interface for radial explosion event data
  52064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52065. */
  52066. export interface PhysicsRadialExplosionEventData {
  52067. /**
  52068. * A sphere used for the radial explosion event
  52069. */
  52070. sphere: Mesh;
  52071. /**
  52072. * An array of rays for the radial explosion event
  52073. */
  52074. rays: Array<Ray>;
  52075. }
  52076. /**
  52077. * Interface for gravitational field event data
  52078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52079. */
  52080. export interface PhysicsGravitationalFieldEventData {
  52081. /**
  52082. * A sphere mesh used for the gravitational field event
  52083. */
  52084. sphere: Mesh;
  52085. }
  52086. /**
  52087. * Interface for updraft event data
  52088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52089. */
  52090. export interface PhysicsUpdraftEventData {
  52091. /**
  52092. * A cylinder used for the updraft event
  52093. */
  52094. cylinder: Mesh;
  52095. }
  52096. /**
  52097. * Interface for vortex event data
  52098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52099. */
  52100. export interface PhysicsVortexEventData {
  52101. /**
  52102. * A cylinder used for the vortex event
  52103. */
  52104. cylinder: Mesh;
  52105. }
  52106. }
  52107. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52108. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52109. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52110. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52111. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52112. import { Nullable } from "babylonjs/types";
  52113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52114. /**
  52115. * AmmoJS Physics plugin
  52116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52117. * @see https://github.com/kripken/ammo.js/
  52118. */
  52119. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52120. private _useDeltaForWorldStep;
  52121. /**
  52122. * Reference to the Ammo library
  52123. */
  52124. bjsAMMO: any;
  52125. /**
  52126. * Created ammoJS world which physics bodies are added to
  52127. */
  52128. world: any;
  52129. /**
  52130. * Name of the plugin
  52131. */
  52132. name: string;
  52133. private _timeStep;
  52134. private _fixedTimeStep;
  52135. private _maxSteps;
  52136. private _tmpQuaternion;
  52137. private _tmpAmmoTransform;
  52138. private _tmpAmmoQuaternion;
  52139. private _tmpAmmoConcreteContactResultCallback;
  52140. private _collisionConfiguration;
  52141. private _dispatcher;
  52142. private _overlappingPairCache;
  52143. private _solver;
  52144. private _tmpAmmoVectorA;
  52145. private _tmpAmmoVectorB;
  52146. private _tmpAmmoVectorC;
  52147. private _tmpContactCallbackResult;
  52148. private static readonly DISABLE_COLLISION_FLAG;
  52149. private static readonly KINEMATIC_FLAG;
  52150. private static readonly DISABLE_DEACTIVATION_FLAG;
  52151. /**
  52152. * Initializes the ammoJS plugin
  52153. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52154. * @param ammoInjection can be used to inject your own ammo reference
  52155. */
  52156. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52157. /**
  52158. * Sets the gravity of the physics world (m/(s^2))
  52159. * @param gravity Gravity to set
  52160. */
  52161. setGravity(gravity: Vector3): void;
  52162. /**
  52163. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52164. * @param timeStep timestep to use in seconds
  52165. */
  52166. setTimeStep(timeStep: number): void;
  52167. /**
  52168. * 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)
  52169. * @param fixedTimeStep fixedTimeStep to use in seconds
  52170. */
  52171. setFixedTimeStep(fixedTimeStep: number): void;
  52172. /**
  52173. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52174. * @param maxSteps the maximum number of steps by the physics engine per frame
  52175. */
  52176. setMaxSteps(maxSteps: number): void;
  52177. /**
  52178. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52179. * @returns the current timestep in seconds
  52180. */
  52181. getTimeStep(): number;
  52182. private _isImpostorInContact;
  52183. private _isImpostorPairInContact;
  52184. private _stepSimulation;
  52185. /**
  52186. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52187. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52188. * After the step the babylon meshes are set to the position of the physics imposters
  52189. * @param delta amount of time to step forward
  52190. * @param impostors array of imposters to update before/after the step
  52191. */
  52192. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52193. private _tmpVector;
  52194. private _tmpMatrix;
  52195. /**
  52196. * Applies an implulse on the imposter
  52197. * @param impostor imposter to apply impulse
  52198. * @param force amount of force to be applied to the imposter
  52199. * @param contactPoint the location to apply the impulse on the imposter
  52200. */
  52201. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52202. /**
  52203. * Applies a force on the imposter
  52204. * @param impostor imposter to apply force
  52205. * @param force amount of force to be applied to the imposter
  52206. * @param contactPoint the location to apply the force on the imposter
  52207. */
  52208. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52209. /**
  52210. * Creates a physics body using the plugin
  52211. * @param impostor the imposter to create the physics body on
  52212. */
  52213. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52214. /**
  52215. * Removes the physics body from the imposter and disposes of the body's memory
  52216. * @param impostor imposter to remove the physics body from
  52217. */
  52218. removePhysicsBody(impostor: PhysicsImpostor): void;
  52219. /**
  52220. * Generates a joint
  52221. * @param impostorJoint the imposter joint to create the joint with
  52222. */
  52223. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52224. /**
  52225. * Removes a joint
  52226. * @param impostorJoint the imposter joint to remove the joint from
  52227. */
  52228. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52229. private _addMeshVerts;
  52230. private _createShape;
  52231. /**
  52232. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52233. * @param impostor imposter containing the physics body and babylon object
  52234. */
  52235. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52236. /**
  52237. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52238. * @param impostor imposter containing the physics body and babylon object
  52239. * @param newPosition new position
  52240. * @param newRotation new rotation
  52241. */
  52242. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52243. /**
  52244. * If this plugin is supported
  52245. * @returns true if its supported
  52246. */
  52247. isSupported(): boolean;
  52248. /**
  52249. * Sets the linear velocity of the physics body
  52250. * @param impostor imposter to set the velocity on
  52251. * @param velocity velocity to set
  52252. */
  52253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52254. /**
  52255. * Sets the angular velocity of the physics body
  52256. * @param impostor imposter to set the velocity on
  52257. * @param velocity velocity to set
  52258. */
  52259. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52260. /**
  52261. * gets the linear velocity
  52262. * @param impostor imposter to get linear velocity from
  52263. * @returns linear velocity
  52264. */
  52265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52266. /**
  52267. * gets the angular velocity
  52268. * @param impostor imposter to get angular velocity from
  52269. * @returns angular velocity
  52270. */
  52271. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52272. /**
  52273. * Sets the mass of physics body
  52274. * @param impostor imposter to set the mass on
  52275. * @param mass mass to set
  52276. */
  52277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52278. /**
  52279. * Gets the mass of the physics body
  52280. * @param impostor imposter to get the mass from
  52281. * @returns mass
  52282. */
  52283. getBodyMass(impostor: PhysicsImpostor): number;
  52284. /**
  52285. * Gets friction of the impostor
  52286. * @param impostor impostor to get friction from
  52287. * @returns friction value
  52288. */
  52289. getBodyFriction(impostor: PhysicsImpostor): number;
  52290. /**
  52291. * Sets friction of the impostor
  52292. * @param impostor impostor to set friction on
  52293. * @param friction friction value
  52294. */
  52295. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52296. /**
  52297. * Gets restitution of the impostor
  52298. * @param impostor impostor to get restitution from
  52299. * @returns restitution value
  52300. */
  52301. getBodyRestitution(impostor: PhysicsImpostor): number;
  52302. /**
  52303. * Sets resitution of the impostor
  52304. * @param impostor impostor to set resitution on
  52305. * @param restitution resitution value
  52306. */
  52307. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52308. /**
  52309. * Sleeps the physics body and stops it from being active
  52310. * @param impostor impostor to sleep
  52311. */
  52312. sleepBody(impostor: PhysicsImpostor): void;
  52313. /**
  52314. * Activates the physics body
  52315. * @param impostor impostor to activate
  52316. */
  52317. wakeUpBody(impostor: PhysicsImpostor): void;
  52318. /**
  52319. * Updates the distance parameters of the joint
  52320. * @param joint joint to update
  52321. * @param maxDistance maximum distance of the joint
  52322. * @param minDistance minimum distance of the joint
  52323. */
  52324. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52325. /**
  52326. * Sets a motor on the joint
  52327. * @param joint joint to set motor on
  52328. * @param speed speed of the motor
  52329. * @param maxForce maximum force of the motor
  52330. * @param motorIndex index of the motor
  52331. */
  52332. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52333. /**
  52334. * Sets the motors limit
  52335. * @param joint joint to set limit on
  52336. * @param upperLimit upper limit
  52337. * @param lowerLimit lower limit
  52338. */
  52339. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52340. /**
  52341. * Syncs the position and rotation of a mesh with the impostor
  52342. * @param mesh mesh to sync
  52343. * @param impostor impostor to update the mesh with
  52344. */
  52345. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52346. /**
  52347. * Gets the radius of the impostor
  52348. * @param impostor impostor to get radius from
  52349. * @returns the radius
  52350. */
  52351. getRadius(impostor: PhysicsImpostor): number;
  52352. /**
  52353. * Gets the box size of the impostor
  52354. * @param impostor impostor to get box size from
  52355. * @param result the resulting box size
  52356. */
  52357. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52358. /**
  52359. * Disposes of the impostor
  52360. */
  52361. dispose(): void;
  52362. }
  52363. }
  52364. declare module "babylonjs/Physics/Plugins/index" {
  52365. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52366. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52367. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52368. }
  52369. declare module "babylonjs/Physics/index" {
  52370. export * from "babylonjs/Physics/IPhysicsEngine";
  52371. export * from "babylonjs/Physics/physicsEngine";
  52372. export * from "babylonjs/Physics/physicsEngineComponent";
  52373. export * from "babylonjs/Physics/physicsHelper";
  52374. export * from "babylonjs/Physics/physicsImpostor";
  52375. export * from "babylonjs/Physics/physicsJoint";
  52376. export * from "babylonjs/Physics/Plugins/index";
  52377. }
  52378. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52379. /** @hidden */
  52380. export var blackAndWhitePixelShader: {
  52381. name: string;
  52382. shader: string;
  52383. };
  52384. }
  52385. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52386. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52387. import { Camera } from "babylonjs/Cameras/camera";
  52388. import { Engine } from "babylonjs/Engines/engine";
  52389. import "babylonjs/Shaders/blackAndWhite.fragment";
  52390. /**
  52391. * Post process used to render in black and white
  52392. */
  52393. export class BlackAndWhitePostProcess extends PostProcess {
  52394. /**
  52395. * Linear about to convert he result to black and white (default: 1)
  52396. */
  52397. degree: number;
  52398. /**
  52399. * Creates a black and white post process
  52400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52401. * @param name The name of the effect.
  52402. * @param options The required width/height ratio to downsize to before computing the render pass.
  52403. * @param camera The camera to apply the render pass to.
  52404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52405. * @param engine The engine which the post process will be applied. (default: current engine)
  52406. * @param reusable If the post process can be reused on the same frame. (default: false)
  52407. */
  52408. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52409. }
  52410. }
  52411. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52412. import { Nullable } from "babylonjs/types";
  52413. import { Camera } from "babylonjs/Cameras/camera";
  52414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52415. import { Engine } from "babylonjs/Engines/engine";
  52416. /**
  52417. * This represents a set of one or more post processes in Babylon.
  52418. * A post process can be used to apply a shader to a texture after it is rendered.
  52419. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52420. */
  52421. export class PostProcessRenderEffect {
  52422. private _postProcesses;
  52423. private _getPostProcesses;
  52424. private _singleInstance;
  52425. private _cameras;
  52426. private _indicesForCamera;
  52427. /**
  52428. * Name of the effect
  52429. * @hidden
  52430. */
  52431. _name: string;
  52432. /**
  52433. * Instantiates a post process render effect.
  52434. * A post process can be used to apply a shader to a texture after it is rendered.
  52435. * @param engine The engine the effect is tied to
  52436. * @param name The name of the effect
  52437. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52438. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52439. */
  52440. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52441. /**
  52442. * Checks if all the post processes in the effect are supported.
  52443. */
  52444. readonly isSupported: boolean;
  52445. /**
  52446. * Updates the current state of the effect
  52447. * @hidden
  52448. */
  52449. _update(): void;
  52450. /**
  52451. * Attaches the effect on cameras
  52452. * @param cameras The camera to attach to.
  52453. * @hidden
  52454. */
  52455. _attachCameras(cameras: Camera): void;
  52456. /**
  52457. * Attaches the effect on cameras
  52458. * @param cameras The camera to attach to.
  52459. * @hidden
  52460. */
  52461. _attachCameras(cameras: Camera[]): void;
  52462. /**
  52463. * Detatches the effect on cameras
  52464. * @param cameras The camera to detatch from.
  52465. * @hidden
  52466. */
  52467. _detachCameras(cameras: Camera): void;
  52468. /**
  52469. * Detatches the effect on cameras
  52470. * @param cameras The camera to detatch from.
  52471. * @hidden
  52472. */
  52473. _detachCameras(cameras: Camera[]): void;
  52474. /**
  52475. * Enables the effect on given cameras
  52476. * @param cameras The camera to enable.
  52477. * @hidden
  52478. */
  52479. _enable(cameras: Camera): void;
  52480. /**
  52481. * Enables the effect on given cameras
  52482. * @param cameras The camera to enable.
  52483. * @hidden
  52484. */
  52485. _enable(cameras: Nullable<Camera[]>): void;
  52486. /**
  52487. * Disables the effect on the given cameras
  52488. * @param cameras The camera to disable.
  52489. * @hidden
  52490. */
  52491. _disable(cameras: Camera): void;
  52492. /**
  52493. * Disables the effect on the given cameras
  52494. * @param cameras The camera to disable.
  52495. * @hidden
  52496. */
  52497. _disable(cameras: Nullable<Camera[]>): void;
  52498. /**
  52499. * Gets a list of the post processes contained in the effect.
  52500. * @param camera The camera to get the post processes on.
  52501. * @returns The list of the post processes in the effect.
  52502. */
  52503. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52504. }
  52505. }
  52506. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52507. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52508. /** @hidden */
  52509. export var extractHighlightsPixelShader: {
  52510. name: string;
  52511. shader: string;
  52512. };
  52513. }
  52514. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52515. import { Nullable } from "babylonjs/types";
  52516. import { Camera } from "babylonjs/Cameras/camera";
  52517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52518. import { Engine } from "babylonjs/Engines/engine";
  52519. import "babylonjs/Shaders/extractHighlights.fragment";
  52520. /**
  52521. * 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.
  52522. */
  52523. export class ExtractHighlightsPostProcess extends PostProcess {
  52524. /**
  52525. * The luminance threshold, pixels below this value will be set to black.
  52526. */
  52527. threshold: number;
  52528. /** @hidden */
  52529. _exposure: number;
  52530. /**
  52531. * Post process which has the input texture to be used when performing highlight extraction
  52532. * @hidden
  52533. */
  52534. _inputPostProcess: Nullable<PostProcess>;
  52535. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52536. }
  52537. }
  52538. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52539. /** @hidden */
  52540. export var bloomMergePixelShader: {
  52541. name: string;
  52542. shader: string;
  52543. };
  52544. }
  52545. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52547. import { Nullable } from "babylonjs/types";
  52548. import { Engine } from "babylonjs/Engines/engine";
  52549. import { Camera } from "babylonjs/Cameras/camera";
  52550. import "babylonjs/Shaders/bloomMerge.fragment";
  52551. /**
  52552. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52553. */
  52554. export class BloomMergePostProcess extends PostProcess {
  52555. /** Weight of the bloom to be added to the original input. */
  52556. weight: number;
  52557. /**
  52558. * Creates a new instance of @see BloomMergePostProcess
  52559. * @param name The name of the effect.
  52560. * @param originalFromInput Post process which's input will be used for the merge.
  52561. * @param blurred Blurred highlights post process which's output will be used.
  52562. * @param weight Weight of the bloom to be added to the original input.
  52563. * @param options The required width/height ratio to downsize to before computing the render pass.
  52564. * @param camera The camera to apply the render pass to.
  52565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52566. * @param engine The engine which the post process will be applied. (default: current engine)
  52567. * @param reusable If the post process can be reused on the same frame. (default: false)
  52568. * @param textureType Type of textures used when performing the post process. (default: 0)
  52569. * @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)
  52570. */
  52571. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52572. /** Weight of the bloom to be added to the original input. */
  52573. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52574. }
  52575. }
  52576. declare module "babylonjs/PostProcesses/bloomEffect" {
  52577. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52578. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52579. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52580. import { Camera } from "babylonjs/Cameras/camera";
  52581. import { Scene } from "babylonjs/scene";
  52582. /**
  52583. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52584. */
  52585. export class BloomEffect extends PostProcessRenderEffect {
  52586. private bloomScale;
  52587. /**
  52588. * @hidden Internal
  52589. */
  52590. _effects: Array<PostProcess>;
  52591. /**
  52592. * @hidden Internal
  52593. */
  52594. _downscale: ExtractHighlightsPostProcess;
  52595. private _blurX;
  52596. private _blurY;
  52597. private _merge;
  52598. /**
  52599. * The luminance threshold to find bright areas of the image to bloom.
  52600. */
  52601. threshold: number;
  52602. /**
  52603. * The strength of the bloom.
  52604. */
  52605. weight: number;
  52606. /**
  52607. * Specifies the size of the bloom blur kernel, relative to the final output size
  52608. */
  52609. kernel: number;
  52610. /**
  52611. * Creates a new instance of @see BloomEffect
  52612. * @param scene The scene the effect belongs to.
  52613. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52614. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52615. * @param bloomWeight The the strength of bloom.
  52616. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52617. * @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)
  52618. */
  52619. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52620. /**
  52621. * Disposes each of the internal effects for a given camera.
  52622. * @param camera The camera to dispose the effect on.
  52623. */
  52624. disposeEffects(camera: Camera): void;
  52625. /**
  52626. * @hidden Internal
  52627. */
  52628. _updateEffects(): void;
  52629. /**
  52630. * Internal
  52631. * @returns if all the contained post processes are ready.
  52632. * @hidden
  52633. */
  52634. _isReady(): boolean;
  52635. }
  52636. }
  52637. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52638. /** @hidden */
  52639. export var chromaticAberrationPixelShader: {
  52640. name: string;
  52641. shader: string;
  52642. };
  52643. }
  52644. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52645. import { Vector2 } from "babylonjs/Maths/math";
  52646. import { Nullable } from "babylonjs/types";
  52647. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52648. import { Camera } from "babylonjs/Cameras/camera";
  52649. import { Engine } from "babylonjs/Engines/engine";
  52650. import "babylonjs/Shaders/chromaticAberration.fragment";
  52651. /**
  52652. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52653. */
  52654. export class ChromaticAberrationPostProcess extends PostProcess {
  52655. /**
  52656. * The amount of seperation of rgb channels (default: 30)
  52657. */
  52658. aberrationAmount: number;
  52659. /**
  52660. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52661. */
  52662. radialIntensity: number;
  52663. /**
  52664. * 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))
  52665. */
  52666. direction: Vector2;
  52667. /**
  52668. * 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))
  52669. */
  52670. centerPosition: Vector2;
  52671. /**
  52672. * Creates a new instance ChromaticAberrationPostProcess
  52673. * @param name The name of the effect.
  52674. * @param screenWidth The width of the screen to apply the effect on.
  52675. * @param screenHeight The height of the screen to apply the effect on.
  52676. * @param options The required width/height ratio to downsize to before computing the render pass.
  52677. * @param camera The camera to apply the render pass to.
  52678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52679. * @param engine The engine which the post process will be applied. (default: current engine)
  52680. * @param reusable If the post process can be reused on the same frame. (default: false)
  52681. * @param textureType Type of textures used when performing the post process. (default: 0)
  52682. * @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)
  52683. */
  52684. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52685. }
  52686. }
  52687. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52688. /** @hidden */
  52689. export var circleOfConfusionPixelShader: {
  52690. name: string;
  52691. shader: string;
  52692. };
  52693. }
  52694. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52695. import { Nullable } from "babylonjs/types";
  52696. import { Engine } from "babylonjs/Engines/engine";
  52697. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52699. import { Camera } from "babylonjs/Cameras/camera";
  52700. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52701. /**
  52702. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52703. */
  52704. export class CircleOfConfusionPostProcess extends PostProcess {
  52705. /**
  52706. * 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.
  52707. */
  52708. lensSize: number;
  52709. /**
  52710. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52711. */
  52712. fStop: number;
  52713. /**
  52714. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52715. */
  52716. focusDistance: number;
  52717. /**
  52718. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52719. */
  52720. focalLength: number;
  52721. private _depthTexture;
  52722. /**
  52723. * Creates a new instance CircleOfConfusionPostProcess
  52724. * @param name The name of the effect.
  52725. * @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.
  52726. * @param options The required width/height ratio to downsize to before computing the render pass.
  52727. * @param camera The camera to apply the render pass to.
  52728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52729. * @param engine The engine which the post process will be applied. (default: current engine)
  52730. * @param reusable If the post process can be reused on the same frame. (default: false)
  52731. * @param textureType Type of textures used when performing the post process. (default: 0)
  52732. * @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)
  52733. */
  52734. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52735. /**
  52736. * 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.
  52737. */
  52738. depthTexture: RenderTargetTexture;
  52739. }
  52740. }
  52741. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52742. /** @hidden */
  52743. export var colorCorrectionPixelShader: {
  52744. name: string;
  52745. shader: string;
  52746. };
  52747. }
  52748. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52750. import { Engine } from "babylonjs/Engines/engine";
  52751. import { Camera } from "babylonjs/Cameras/camera";
  52752. import "babylonjs/Shaders/colorCorrection.fragment";
  52753. /**
  52754. *
  52755. * This post-process allows the modification of rendered colors by using
  52756. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52757. *
  52758. * The object needs to be provided an url to a texture containing the color
  52759. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52760. * Use an image editing software to tweak the LUT to match your needs.
  52761. *
  52762. * For an example of a color LUT, see here:
  52763. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52764. * For explanations on color grading, see here:
  52765. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52766. *
  52767. */
  52768. export class ColorCorrectionPostProcess extends PostProcess {
  52769. private _colorTableTexture;
  52770. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52771. }
  52772. }
  52773. declare module "babylonjs/Shaders/convolution.fragment" {
  52774. /** @hidden */
  52775. export var convolutionPixelShader: {
  52776. name: string;
  52777. shader: string;
  52778. };
  52779. }
  52780. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52781. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52782. import { Nullable } from "babylonjs/types";
  52783. import { Camera } from "babylonjs/Cameras/camera";
  52784. import { Engine } from "babylonjs/Engines/engine";
  52785. import "babylonjs/Shaders/convolution.fragment";
  52786. /**
  52787. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52788. * input texture to perform effects such as edge detection or sharpening
  52789. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52790. */
  52791. export class ConvolutionPostProcess extends PostProcess {
  52792. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52793. kernel: number[];
  52794. /**
  52795. * Creates a new instance ConvolutionPostProcess
  52796. * @param name The name of the effect.
  52797. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52798. * @param options The required width/height ratio to downsize to before computing the render pass.
  52799. * @param camera The camera to apply the render pass to.
  52800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52801. * @param engine The engine which the post process will be applied. (default: current engine)
  52802. * @param reusable If the post process can be reused on the same frame. (default: false)
  52803. * @param textureType Type of textures used when performing the post process. (default: 0)
  52804. */
  52805. constructor(name: string,
  52806. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52807. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52808. /**
  52809. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52810. */
  52811. static EdgeDetect0Kernel: number[];
  52812. /**
  52813. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52814. */
  52815. static EdgeDetect1Kernel: number[];
  52816. /**
  52817. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52818. */
  52819. static EdgeDetect2Kernel: number[];
  52820. /**
  52821. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52822. */
  52823. static SharpenKernel: number[];
  52824. /**
  52825. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52826. */
  52827. static EmbossKernel: number[];
  52828. /**
  52829. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52830. */
  52831. static GaussianKernel: number[];
  52832. }
  52833. }
  52834. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52835. import { Nullable } from "babylonjs/types";
  52836. import { Vector2 } from "babylonjs/Maths/math";
  52837. import { Camera } from "babylonjs/Cameras/camera";
  52838. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52839. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52840. import { Engine } from "babylonjs/Engines/engine";
  52841. import { Scene } from "babylonjs/scene";
  52842. /**
  52843. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52844. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52845. * based on samples that have a large difference in distance than the center pixel.
  52846. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52847. */
  52848. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52849. direction: Vector2;
  52850. /**
  52851. * Creates a new instance CircleOfConfusionPostProcess
  52852. * @param name The name of the effect.
  52853. * @param scene The scene the effect belongs to.
  52854. * @param direction The direction the blur should be applied.
  52855. * @param kernel The size of the kernel used to blur.
  52856. * @param options The required width/height ratio to downsize to before computing the render pass.
  52857. * @param camera The camera to apply the render pass to.
  52858. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52859. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52861. * @param engine The engine which the post process will be applied. (default: current engine)
  52862. * @param reusable If the post process can be reused on the same frame. (default: false)
  52863. * @param textureType Type of textures used when performing the post process. (default: 0)
  52864. * @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)
  52865. */
  52866. 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);
  52867. }
  52868. }
  52869. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52870. /** @hidden */
  52871. export var depthOfFieldMergePixelShader: {
  52872. name: string;
  52873. shader: string;
  52874. };
  52875. }
  52876. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52877. import { Nullable } from "babylonjs/types";
  52878. import { Camera } from "babylonjs/Cameras/camera";
  52879. import { Effect } from "babylonjs/Materials/effect";
  52880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52881. import { Engine } from "babylonjs/Engines/engine";
  52882. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52883. /**
  52884. * Options to be set when merging outputs from the default pipeline.
  52885. */
  52886. export class DepthOfFieldMergePostProcessOptions {
  52887. /**
  52888. * The original image to merge on top of
  52889. */
  52890. originalFromInput: PostProcess;
  52891. /**
  52892. * Parameters to perform the merge of the depth of field effect
  52893. */
  52894. depthOfField?: {
  52895. circleOfConfusion: PostProcess;
  52896. blurSteps: Array<PostProcess>;
  52897. };
  52898. /**
  52899. * Parameters to perform the merge of bloom effect
  52900. */
  52901. bloom?: {
  52902. blurred: PostProcess;
  52903. weight: number;
  52904. };
  52905. }
  52906. /**
  52907. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52908. */
  52909. export class DepthOfFieldMergePostProcess extends PostProcess {
  52910. private blurSteps;
  52911. /**
  52912. * Creates a new instance of DepthOfFieldMergePostProcess
  52913. * @param name The name of the effect.
  52914. * @param originalFromInput Post process which's input will be used for the merge.
  52915. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52916. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52917. * @param options The required width/height ratio to downsize to before computing the render pass.
  52918. * @param camera The camera to apply the render pass to.
  52919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52920. * @param engine The engine which the post process will be applied. (default: current engine)
  52921. * @param reusable If the post process can be reused on the same frame. (default: false)
  52922. * @param textureType Type of textures used when performing the post process. (default: 0)
  52923. * @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)
  52924. */
  52925. 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);
  52926. /**
  52927. * Updates the effect with the current post process compile time values and recompiles the shader.
  52928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52931. * @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
  52932. * @param onCompiled Called when the shader has been compiled.
  52933. * @param onError Called if there is an error when compiling a shader.
  52934. */
  52935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52936. }
  52937. }
  52938. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52939. import { Nullable } from "babylonjs/types";
  52940. import { Camera } from "babylonjs/Cameras/camera";
  52941. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52942. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52943. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52944. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52945. import { Scene } from "babylonjs/scene";
  52946. /**
  52947. * Specifies the level of max blur that should be applied when using the depth of field effect
  52948. */
  52949. export enum DepthOfFieldEffectBlurLevel {
  52950. /**
  52951. * Subtle blur
  52952. */
  52953. Low = 0,
  52954. /**
  52955. * Medium blur
  52956. */
  52957. Medium = 1,
  52958. /**
  52959. * Large blur
  52960. */
  52961. High = 2
  52962. }
  52963. /**
  52964. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52965. */
  52966. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52967. private _circleOfConfusion;
  52968. /**
  52969. * @hidden Internal, blurs from high to low
  52970. */
  52971. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52972. private _depthOfFieldBlurY;
  52973. private _dofMerge;
  52974. /**
  52975. * @hidden Internal post processes in depth of field effect
  52976. */
  52977. _effects: Array<PostProcess>;
  52978. /**
  52979. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52980. */
  52981. focalLength: number;
  52982. /**
  52983. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52984. */
  52985. fStop: number;
  52986. /**
  52987. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52988. */
  52989. focusDistance: number;
  52990. /**
  52991. * 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.
  52992. */
  52993. lensSize: number;
  52994. /**
  52995. * Creates a new instance DepthOfFieldEffect
  52996. * @param scene The scene the effect belongs to.
  52997. * @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.
  52998. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52999. * @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)
  53000. */
  53001. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53002. /**
  53003. * 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.
  53004. */
  53005. depthTexture: RenderTargetTexture;
  53006. /**
  53007. * Disposes each of the internal effects for a given camera.
  53008. * @param camera The camera to dispose the effect on.
  53009. */
  53010. disposeEffects(camera: Camera): void;
  53011. /**
  53012. * @hidden Internal
  53013. */
  53014. _updateEffects(): void;
  53015. /**
  53016. * Internal
  53017. * @returns if all the contained post processes are ready.
  53018. * @hidden
  53019. */
  53020. _isReady(): boolean;
  53021. }
  53022. }
  53023. declare module "babylonjs/Shaders/displayPass.fragment" {
  53024. /** @hidden */
  53025. export var displayPassPixelShader: {
  53026. name: string;
  53027. shader: string;
  53028. };
  53029. }
  53030. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53031. import { Nullable } from "babylonjs/types";
  53032. import { Camera } from "babylonjs/Cameras/camera";
  53033. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53034. import { Engine } from "babylonjs/Engines/engine";
  53035. import "babylonjs/Shaders/displayPass.fragment";
  53036. /**
  53037. * DisplayPassPostProcess which produces an output the same as it's input
  53038. */
  53039. export class DisplayPassPostProcess extends PostProcess {
  53040. /**
  53041. * Creates the DisplayPassPostProcess
  53042. * @param name The name of the effect.
  53043. * @param options The required width/height ratio to downsize to before computing the render pass.
  53044. * @param camera The camera to apply the render pass to.
  53045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53046. * @param engine The engine which the post process will be applied. (default: current engine)
  53047. * @param reusable If the post process can be reused on the same frame. (default: false)
  53048. */
  53049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53050. }
  53051. }
  53052. declare module "babylonjs/Shaders/filter.fragment" {
  53053. /** @hidden */
  53054. export var filterPixelShader: {
  53055. name: string;
  53056. shader: string;
  53057. };
  53058. }
  53059. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53060. import { Nullable } from "babylonjs/types";
  53061. import { Matrix } from "babylonjs/Maths/math";
  53062. import { Camera } from "babylonjs/Cameras/camera";
  53063. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53064. import { Engine } from "babylonjs/Engines/engine";
  53065. import "babylonjs/Shaders/filter.fragment";
  53066. /**
  53067. * Applies a kernel filter to the image
  53068. */
  53069. export class FilterPostProcess extends PostProcess {
  53070. /** The matrix to be applied to the image */
  53071. kernelMatrix: Matrix;
  53072. /**
  53073. *
  53074. * @param name The name of the effect.
  53075. * @param kernelMatrix The matrix to be applied to the image
  53076. * @param options The required width/height ratio to downsize to before computing the render pass.
  53077. * @param camera The camera to apply the render pass to.
  53078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53079. * @param engine The engine which the post process will be applied. (default: current engine)
  53080. * @param reusable If the post process can be reused on the same frame. (default: false)
  53081. */
  53082. constructor(name: string,
  53083. /** The matrix to be applied to the image */
  53084. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53085. }
  53086. }
  53087. declare module "babylonjs/Shaders/fxaa.fragment" {
  53088. /** @hidden */
  53089. export var fxaaPixelShader: {
  53090. name: string;
  53091. shader: string;
  53092. };
  53093. }
  53094. declare module "babylonjs/Shaders/fxaa.vertex" {
  53095. /** @hidden */
  53096. export var fxaaVertexShader: {
  53097. name: string;
  53098. shader: string;
  53099. };
  53100. }
  53101. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53102. import { Nullable } from "babylonjs/types";
  53103. import { Camera } from "babylonjs/Cameras/camera";
  53104. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53105. import { Engine } from "babylonjs/Engines/engine";
  53106. import "babylonjs/Shaders/fxaa.fragment";
  53107. import "babylonjs/Shaders/fxaa.vertex";
  53108. /**
  53109. * Fxaa post process
  53110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53111. */
  53112. export class FxaaPostProcess extends PostProcess {
  53113. /** @hidden */
  53114. texelWidth: number;
  53115. /** @hidden */
  53116. texelHeight: number;
  53117. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53118. private _getDefines;
  53119. }
  53120. }
  53121. declare module "babylonjs/Shaders/grain.fragment" {
  53122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53123. /** @hidden */
  53124. export var grainPixelShader: {
  53125. name: string;
  53126. shader: string;
  53127. };
  53128. }
  53129. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53130. import { Nullable } from "babylonjs/types";
  53131. import { Camera } from "babylonjs/Cameras/camera";
  53132. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53133. import { Engine } from "babylonjs/Engines/engine";
  53134. import "babylonjs/Shaders/grain.fragment";
  53135. /**
  53136. * The GrainPostProcess adds noise to the image at mid luminance levels
  53137. */
  53138. export class GrainPostProcess extends PostProcess {
  53139. /**
  53140. * The intensity of the grain added (default: 30)
  53141. */
  53142. intensity: number;
  53143. /**
  53144. * If the grain should be randomized on every frame
  53145. */
  53146. animated: boolean;
  53147. /**
  53148. * Creates a new instance of @see GrainPostProcess
  53149. * @param name The name of the effect.
  53150. * @param options The required width/height ratio to downsize to before computing the render pass.
  53151. * @param camera The camera to apply the render pass to.
  53152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53153. * @param engine The engine which the post process will be applied. (default: current engine)
  53154. * @param reusable If the post process can be reused on the same frame. (default: false)
  53155. * @param textureType Type of textures used when performing the post process. (default: 0)
  53156. * @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)
  53157. */
  53158. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53159. }
  53160. }
  53161. declare module "babylonjs/Shaders/highlights.fragment" {
  53162. /** @hidden */
  53163. export var highlightsPixelShader: {
  53164. name: string;
  53165. shader: string;
  53166. };
  53167. }
  53168. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53169. import { Nullable } from "babylonjs/types";
  53170. import { Camera } from "babylonjs/Cameras/camera";
  53171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53172. import { Engine } from "babylonjs/Engines/engine";
  53173. import "babylonjs/Shaders/highlights.fragment";
  53174. /**
  53175. * Extracts highlights from the image
  53176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53177. */
  53178. export class HighlightsPostProcess extends PostProcess {
  53179. /**
  53180. * Extracts highlights from the image
  53181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53182. * @param name The name of the effect.
  53183. * @param options The required width/height ratio to downsize to before computing the render pass.
  53184. * @param camera The camera to apply the render pass to.
  53185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53186. * @param engine The engine which the post process will be applied. (default: current engine)
  53187. * @param reusable If the post process can be reused on the same frame. (default: false)
  53188. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53189. */
  53190. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53191. }
  53192. }
  53193. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53194. /** @hidden */
  53195. export var mrtFragmentDeclaration: {
  53196. name: string;
  53197. shader: string;
  53198. };
  53199. }
  53200. declare module "babylonjs/Shaders/geometry.fragment" {
  53201. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53202. /** @hidden */
  53203. export var geometryPixelShader: {
  53204. name: string;
  53205. shader: string;
  53206. };
  53207. }
  53208. declare module "babylonjs/Shaders/geometry.vertex" {
  53209. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53210. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53211. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53212. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53213. /** @hidden */
  53214. export var geometryVertexShader: {
  53215. name: string;
  53216. shader: string;
  53217. };
  53218. }
  53219. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53220. import { Matrix } from "babylonjs/Maths/math";
  53221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53222. import { Mesh } from "babylonjs/Meshes/mesh";
  53223. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53224. import { Effect } from "babylonjs/Materials/effect";
  53225. import { Scene } from "babylonjs/scene";
  53226. import "babylonjs/Shaders/geometry.fragment";
  53227. import "babylonjs/Shaders/geometry.vertex";
  53228. /**
  53229. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53230. */
  53231. export class GeometryBufferRenderer {
  53232. /**
  53233. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53234. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53235. */
  53236. static readonly POSITION_TEXTURE_TYPE: number;
  53237. /**
  53238. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53239. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53240. */
  53241. static readonly VELOCITY_TEXTURE_TYPE: number;
  53242. /**
  53243. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53244. * in order to compute objects velocities when enableVelocity is set to "true"
  53245. * @hidden
  53246. */
  53247. _previousTransformationMatrices: {
  53248. [index: number]: Matrix;
  53249. };
  53250. private _scene;
  53251. private _multiRenderTarget;
  53252. private _ratio;
  53253. private _enablePosition;
  53254. private _enableVelocity;
  53255. private _positionIndex;
  53256. private _velocityIndex;
  53257. protected _effect: Effect;
  53258. protected _cachedDefines: string;
  53259. /**
  53260. * Set the render list (meshes to be rendered) used in the G buffer.
  53261. */
  53262. renderList: Mesh[];
  53263. /**
  53264. * Gets wether or not G buffer are supported by the running hardware.
  53265. * This requires draw buffer supports
  53266. */
  53267. readonly isSupported: boolean;
  53268. /**
  53269. * Returns the index of the given texture type in the G-Buffer textures array
  53270. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53271. * @returns the index of the given texture type in the G-Buffer textures array
  53272. */
  53273. getTextureIndex(textureType: number): number;
  53274. /**
  53275. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53276. */
  53277. /**
  53278. * Sets whether or not objects positions are enabled for the G buffer.
  53279. */
  53280. enablePosition: boolean;
  53281. /**
  53282. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53283. */
  53284. /**
  53285. * Sets wether or not objects velocities are enabled for the G buffer.
  53286. */
  53287. enableVelocity: boolean;
  53288. /**
  53289. * Gets the scene associated with the buffer.
  53290. */
  53291. readonly scene: Scene;
  53292. /**
  53293. * Gets the ratio used by the buffer during its creation.
  53294. * How big is the buffer related to the main canvas.
  53295. */
  53296. readonly ratio: number;
  53297. /** @hidden */
  53298. static _SceneComponentInitialization: (scene: Scene) => void;
  53299. /**
  53300. * Creates a new G Buffer for the scene
  53301. * @param scene The scene the buffer belongs to
  53302. * @param ratio How big is the buffer related to the main canvas.
  53303. */
  53304. constructor(scene: Scene, ratio?: number);
  53305. /**
  53306. * Checks wether everything is ready to render a submesh to the G buffer.
  53307. * @param subMesh the submesh to check readiness for
  53308. * @param useInstances is the mesh drawn using instance or not
  53309. * @returns true if ready otherwise false
  53310. */
  53311. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53312. /**
  53313. * Gets the current underlying G Buffer.
  53314. * @returns the buffer
  53315. */
  53316. getGBuffer(): MultiRenderTarget;
  53317. /**
  53318. * Gets the number of samples used to render the buffer (anti aliasing).
  53319. */
  53320. /**
  53321. * Sets the number of samples used to render the buffer (anti aliasing).
  53322. */
  53323. samples: number;
  53324. /**
  53325. * Disposes the renderer and frees up associated resources.
  53326. */
  53327. dispose(): void;
  53328. protected _createRenderTargets(): void;
  53329. }
  53330. }
  53331. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53332. import { Nullable } from "babylonjs/types";
  53333. import { Scene } from "babylonjs/scene";
  53334. import { ISceneComponent } from "babylonjs/sceneComponent";
  53335. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53336. module "babylonjs/scene" {
  53337. interface Scene {
  53338. /** @hidden (Backing field) */
  53339. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53340. /**
  53341. * Gets or Sets the current geometry buffer associated to the scene.
  53342. */
  53343. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53344. /**
  53345. * Enables a GeometryBufferRender and associates it with the scene
  53346. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53347. * @returns the GeometryBufferRenderer
  53348. */
  53349. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53350. /**
  53351. * Disables the GeometryBufferRender associated with the scene
  53352. */
  53353. disableGeometryBufferRenderer(): void;
  53354. }
  53355. }
  53356. /**
  53357. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53358. * in several rendering techniques.
  53359. */
  53360. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53361. /**
  53362. * The component name helpful to identify the component in the list of scene components.
  53363. */
  53364. readonly name: string;
  53365. /**
  53366. * The scene the component belongs to.
  53367. */
  53368. scene: Scene;
  53369. /**
  53370. * Creates a new instance of the component for the given scene
  53371. * @param scene Defines the scene to register the component in
  53372. */
  53373. constructor(scene: Scene);
  53374. /**
  53375. * Registers the component in a given scene
  53376. */
  53377. register(): void;
  53378. /**
  53379. * Rebuilds the elements related to this component in case of
  53380. * context lost for instance.
  53381. */
  53382. rebuild(): void;
  53383. /**
  53384. * Disposes the component and the associated ressources
  53385. */
  53386. dispose(): void;
  53387. private _gatherRenderTargets;
  53388. }
  53389. }
  53390. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53391. /** @hidden */
  53392. export var motionBlurPixelShader: {
  53393. name: string;
  53394. shader: string;
  53395. };
  53396. }
  53397. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53398. import { Nullable } from "babylonjs/types";
  53399. import { Camera } from "babylonjs/Cameras/camera";
  53400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53401. import { Scene } from "babylonjs/scene";
  53402. import "babylonjs/Animations/animatable";
  53403. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53404. import "babylonjs/Shaders/motionBlur.fragment";
  53405. import { Engine } from "babylonjs/Engines/engine";
  53406. /**
  53407. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53408. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53409. * As an example, all you have to do is to create the post-process:
  53410. * var mb = new BABYLON.MotionBlurPostProcess(
  53411. * 'mb', // The name of the effect.
  53412. * scene, // The scene containing the objects to blur according to their velocity.
  53413. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53414. * camera // The camera to apply the render pass to.
  53415. * );
  53416. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53417. */
  53418. export class MotionBlurPostProcess extends PostProcess {
  53419. /**
  53420. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53421. */
  53422. motionStrength: number;
  53423. /**
  53424. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53425. */
  53426. /**
  53427. * Sets the number of iterations to be used for motion blur quality
  53428. */
  53429. motionBlurSamples: number;
  53430. private _motionBlurSamples;
  53431. private _geometryBufferRenderer;
  53432. /**
  53433. * Creates a new instance MotionBlurPostProcess
  53434. * @param name The name of the effect.
  53435. * @param scene The scene containing the objects to blur according to their velocity.
  53436. * @param options The required width/height ratio to downsize to before computing the render pass.
  53437. * @param camera The camera to apply the render pass to.
  53438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53439. * @param engine The engine which the post process will be applied. (default: current engine)
  53440. * @param reusable If the post process can be reused on the same frame. (default: false)
  53441. * @param textureType Type of textures used when performing the post process. (default: 0)
  53442. * @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)
  53443. */
  53444. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53445. /**
  53446. * Disposes the post process.
  53447. * @param camera The camera to dispose the post process on.
  53448. */
  53449. dispose(camera?: Camera): void;
  53450. }
  53451. }
  53452. declare module "babylonjs/Shaders/refraction.fragment" {
  53453. /** @hidden */
  53454. export var refractionPixelShader: {
  53455. name: string;
  53456. shader: string;
  53457. };
  53458. }
  53459. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53460. import { Color3 } from "babylonjs/Maths/math";
  53461. import { Camera } from "babylonjs/Cameras/camera";
  53462. import { Texture } from "babylonjs/Materials/Textures/texture";
  53463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53464. import { Engine } from "babylonjs/Engines/engine";
  53465. import "babylonjs/Shaders/refraction.fragment";
  53466. /**
  53467. * Post process which applies a refractin texture
  53468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53469. */
  53470. export class RefractionPostProcess extends PostProcess {
  53471. /** the base color of the refraction (used to taint the rendering) */
  53472. color: Color3;
  53473. /** simulated refraction depth */
  53474. depth: number;
  53475. /** the coefficient of the base color (0 to remove base color tainting) */
  53476. colorLevel: number;
  53477. private _refTexture;
  53478. private _ownRefractionTexture;
  53479. /**
  53480. * Gets or sets the refraction texture
  53481. * Please note that you are responsible for disposing the texture if you set it manually
  53482. */
  53483. refractionTexture: Texture;
  53484. /**
  53485. * Initializes the RefractionPostProcess
  53486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53487. * @param name The name of the effect.
  53488. * @param refractionTextureUrl Url of the refraction texture to use
  53489. * @param color the base color of the refraction (used to taint the rendering)
  53490. * @param depth simulated refraction depth
  53491. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53492. * @param camera The camera to apply the render pass to.
  53493. * @param options The required width/height ratio to downsize to before computing the render pass.
  53494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53495. * @param engine The engine which the post process will be applied. (default: current engine)
  53496. * @param reusable If the post process can be reused on the same frame. (default: false)
  53497. */
  53498. constructor(name: string, refractionTextureUrl: string,
  53499. /** the base color of the refraction (used to taint the rendering) */
  53500. color: Color3,
  53501. /** simulated refraction depth */
  53502. depth: number,
  53503. /** the coefficient of the base color (0 to remove base color tainting) */
  53504. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53505. /**
  53506. * Disposes of the post process
  53507. * @param camera Camera to dispose post process on
  53508. */
  53509. dispose(camera: Camera): void;
  53510. }
  53511. }
  53512. declare module "babylonjs/Shaders/sharpen.fragment" {
  53513. /** @hidden */
  53514. export var sharpenPixelShader: {
  53515. name: string;
  53516. shader: string;
  53517. };
  53518. }
  53519. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53520. import { Nullable } from "babylonjs/types";
  53521. import { Camera } from "babylonjs/Cameras/camera";
  53522. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53523. import "babylonjs/Shaders/sharpen.fragment";
  53524. import { Engine } from "babylonjs/Engines/engine";
  53525. /**
  53526. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53527. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53528. */
  53529. export class SharpenPostProcess extends PostProcess {
  53530. /**
  53531. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53532. */
  53533. colorAmount: number;
  53534. /**
  53535. * How much sharpness should be applied (default: 0.3)
  53536. */
  53537. edgeAmount: number;
  53538. /**
  53539. * Creates a new instance ConvolutionPostProcess
  53540. * @param name The name of the effect.
  53541. * @param options The required width/height ratio to downsize to before computing the render pass.
  53542. * @param camera The camera to apply the render pass to.
  53543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53544. * @param engine The engine which the post process will be applied. (default: current engine)
  53545. * @param reusable If the post process can be reused on the same frame. (default: false)
  53546. * @param textureType Type of textures used when performing the post process. (default: 0)
  53547. * @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)
  53548. */
  53549. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53550. }
  53551. }
  53552. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53553. import { Nullable } from "babylonjs/types";
  53554. import { Camera } from "babylonjs/Cameras/camera";
  53555. import { Engine } from "babylonjs/Engines/engine";
  53556. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53557. /**
  53558. * PostProcessRenderPipeline
  53559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53560. */
  53561. export class PostProcessRenderPipeline {
  53562. private engine;
  53563. private _renderEffects;
  53564. private _renderEffectsForIsolatedPass;
  53565. /**
  53566. * @hidden
  53567. */
  53568. protected _cameras: Camera[];
  53569. /** @hidden */
  53570. _name: string;
  53571. /**
  53572. * Gets pipeline name
  53573. */
  53574. readonly name: string;
  53575. /**
  53576. * Initializes a PostProcessRenderPipeline
  53577. * @param engine engine to add the pipeline to
  53578. * @param name name of the pipeline
  53579. */
  53580. constructor(engine: Engine, name: string);
  53581. /**
  53582. * Gets the class name
  53583. * @returns "PostProcessRenderPipeline"
  53584. */
  53585. getClassName(): string;
  53586. /**
  53587. * If all the render effects in the pipeline are supported
  53588. */
  53589. readonly isSupported: boolean;
  53590. /**
  53591. * Adds an effect to the pipeline
  53592. * @param renderEffect the effect to add
  53593. */
  53594. addEffect(renderEffect: PostProcessRenderEffect): void;
  53595. /** @hidden */
  53596. _rebuild(): void;
  53597. /** @hidden */
  53598. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53599. /** @hidden */
  53600. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53601. /** @hidden */
  53602. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53603. /** @hidden */
  53604. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53605. /** @hidden */
  53606. _attachCameras(cameras: Camera, unique: boolean): void;
  53607. /** @hidden */
  53608. _attachCameras(cameras: Camera[], unique: boolean): void;
  53609. /** @hidden */
  53610. _detachCameras(cameras: Camera): void;
  53611. /** @hidden */
  53612. _detachCameras(cameras: Nullable<Camera[]>): void;
  53613. /** @hidden */
  53614. _update(): void;
  53615. /** @hidden */
  53616. _reset(): void;
  53617. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53618. /**
  53619. * Disposes of the pipeline
  53620. */
  53621. dispose(): void;
  53622. }
  53623. }
  53624. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53625. import { Camera } from "babylonjs/Cameras/camera";
  53626. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53627. /**
  53628. * PostProcessRenderPipelineManager class
  53629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53630. */
  53631. export class PostProcessRenderPipelineManager {
  53632. private _renderPipelines;
  53633. /**
  53634. * Initializes a PostProcessRenderPipelineManager
  53635. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53636. */
  53637. constructor();
  53638. /**
  53639. * Gets the list of supported render pipelines
  53640. */
  53641. readonly supportedPipelines: PostProcessRenderPipeline[];
  53642. /**
  53643. * Adds a pipeline to the manager
  53644. * @param renderPipeline The pipeline to add
  53645. */
  53646. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53647. /**
  53648. * Attaches a camera to the pipeline
  53649. * @param renderPipelineName The name of the pipeline to attach to
  53650. * @param cameras the camera to attach
  53651. * @param unique if the camera can be attached multiple times to the pipeline
  53652. */
  53653. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53654. /**
  53655. * Detaches a camera from the pipeline
  53656. * @param renderPipelineName The name of the pipeline to detach from
  53657. * @param cameras the camera to detach
  53658. */
  53659. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53660. /**
  53661. * Enables an effect by name on a pipeline
  53662. * @param renderPipelineName the name of the pipeline to enable the effect in
  53663. * @param renderEffectName the name of the effect to enable
  53664. * @param cameras the cameras that the effect should be enabled on
  53665. */
  53666. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53667. /**
  53668. * Disables an effect by name on a pipeline
  53669. * @param renderPipelineName the name of the pipeline to disable the effect in
  53670. * @param renderEffectName the name of the effect to disable
  53671. * @param cameras the cameras that the effect should be disabled on
  53672. */
  53673. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53674. /**
  53675. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53676. */
  53677. update(): void;
  53678. /** @hidden */
  53679. _rebuild(): void;
  53680. /**
  53681. * Disposes of the manager and pipelines
  53682. */
  53683. dispose(): void;
  53684. }
  53685. }
  53686. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53687. import { ISceneComponent } from "babylonjs/sceneComponent";
  53688. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53689. import { Scene } from "babylonjs/scene";
  53690. module "babylonjs/scene" {
  53691. interface Scene {
  53692. /** @hidden (Backing field) */
  53693. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53694. /**
  53695. * Gets the postprocess render pipeline manager
  53696. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53697. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53698. */
  53699. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53700. }
  53701. }
  53702. /**
  53703. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53704. */
  53705. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53706. /**
  53707. * The component name helpfull to identify the component in the list of scene components.
  53708. */
  53709. readonly name: string;
  53710. /**
  53711. * The scene the component belongs to.
  53712. */
  53713. scene: Scene;
  53714. /**
  53715. * Creates a new instance of the component for the given scene
  53716. * @param scene Defines the scene to register the component in
  53717. */
  53718. constructor(scene: Scene);
  53719. /**
  53720. * Registers the component in a given scene
  53721. */
  53722. register(): void;
  53723. /**
  53724. * Rebuilds the elements related to this component in case of
  53725. * context lost for instance.
  53726. */
  53727. rebuild(): void;
  53728. /**
  53729. * Disposes the component and the associated ressources
  53730. */
  53731. dispose(): void;
  53732. private _gatherRenderTargets;
  53733. }
  53734. }
  53735. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53736. import { IAnimatable } from "babylonjs/Misc/tools";
  53737. import { Camera } from "babylonjs/Cameras/camera";
  53738. import { IDisposable } from "babylonjs/scene";
  53739. import { Scene } from "babylonjs/scene";
  53740. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53741. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53742. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53743. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53744. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53745. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53746. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53747. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53748. import { Animation } from "babylonjs/Animations/animation";
  53749. /**
  53750. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53751. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53752. */
  53753. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53754. private _scene;
  53755. private _camerasToBeAttached;
  53756. /**
  53757. * ID of the sharpen post process,
  53758. */
  53759. private readonly SharpenPostProcessId;
  53760. /**
  53761. * @ignore
  53762. * ID of the image processing post process;
  53763. */
  53764. readonly ImageProcessingPostProcessId: string;
  53765. /**
  53766. * @ignore
  53767. * ID of the Fast Approximate Anti-Aliasing post process;
  53768. */
  53769. readonly FxaaPostProcessId: string;
  53770. /**
  53771. * ID of the chromatic aberration post process,
  53772. */
  53773. private readonly ChromaticAberrationPostProcessId;
  53774. /**
  53775. * ID of the grain post process
  53776. */
  53777. private readonly GrainPostProcessId;
  53778. /**
  53779. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53780. */
  53781. sharpen: SharpenPostProcess;
  53782. private _sharpenEffect;
  53783. private bloom;
  53784. /**
  53785. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53786. */
  53787. depthOfField: DepthOfFieldEffect;
  53788. /**
  53789. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53790. */
  53791. fxaa: FxaaPostProcess;
  53792. /**
  53793. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53794. */
  53795. imageProcessing: ImageProcessingPostProcess;
  53796. /**
  53797. * Chromatic aberration post process which will shift rgb colors in the image
  53798. */
  53799. chromaticAberration: ChromaticAberrationPostProcess;
  53800. private _chromaticAberrationEffect;
  53801. /**
  53802. * Grain post process which add noise to the image
  53803. */
  53804. grain: GrainPostProcess;
  53805. private _grainEffect;
  53806. /**
  53807. * Glow post process which adds a glow to emissive areas of the image
  53808. */
  53809. private _glowLayer;
  53810. /**
  53811. * Animations which can be used to tweak settings over a period of time
  53812. */
  53813. animations: Animation[];
  53814. private _imageProcessingConfigurationObserver;
  53815. private _sharpenEnabled;
  53816. private _bloomEnabled;
  53817. private _depthOfFieldEnabled;
  53818. private _depthOfFieldBlurLevel;
  53819. private _fxaaEnabled;
  53820. private _imageProcessingEnabled;
  53821. private _defaultPipelineTextureType;
  53822. private _bloomScale;
  53823. private _chromaticAberrationEnabled;
  53824. private _grainEnabled;
  53825. private _buildAllowed;
  53826. /**
  53827. * Gets active scene
  53828. */
  53829. readonly scene: Scene;
  53830. /**
  53831. * Enable or disable the sharpen process from the pipeline
  53832. */
  53833. sharpenEnabled: boolean;
  53834. private _resizeObserver;
  53835. private _hardwareScaleLevel;
  53836. private _bloomKernel;
  53837. /**
  53838. * Specifies the size of the bloom blur kernel, relative to the final output size
  53839. */
  53840. bloomKernel: number;
  53841. /**
  53842. * Specifies the weight of the bloom in the final rendering
  53843. */
  53844. private _bloomWeight;
  53845. /**
  53846. * Specifies the luma threshold for the area that will be blurred by the bloom
  53847. */
  53848. private _bloomThreshold;
  53849. private _hdr;
  53850. /**
  53851. * The strength of the bloom.
  53852. */
  53853. bloomWeight: number;
  53854. /**
  53855. * The strength of the bloom.
  53856. */
  53857. bloomThreshold: number;
  53858. /**
  53859. * The scale of the bloom, lower value will provide better performance.
  53860. */
  53861. bloomScale: number;
  53862. /**
  53863. * Enable or disable the bloom from the pipeline
  53864. */
  53865. bloomEnabled: boolean;
  53866. private _rebuildBloom;
  53867. /**
  53868. * If the depth of field is enabled.
  53869. */
  53870. depthOfFieldEnabled: boolean;
  53871. /**
  53872. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53873. */
  53874. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53875. /**
  53876. * If the anti aliasing is enabled.
  53877. */
  53878. fxaaEnabled: boolean;
  53879. private _samples;
  53880. /**
  53881. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53882. */
  53883. samples: number;
  53884. /**
  53885. * If image processing is enabled.
  53886. */
  53887. imageProcessingEnabled: boolean;
  53888. /**
  53889. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53890. */
  53891. glowLayerEnabled: boolean;
  53892. /**
  53893. * Enable or disable the chromaticAberration process from the pipeline
  53894. */
  53895. chromaticAberrationEnabled: boolean;
  53896. /**
  53897. * Enable or disable the grain process from the pipeline
  53898. */
  53899. grainEnabled: boolean;
  53900. /**
  53901. * @constructor
  53902. * @param name - The rendering pipeline name (default: "")
  53903. * @param hdr - If high dynamic range textures should be used (default: true)
  53904. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53905. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53906. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53907. */
  53908. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53909. /**
  53910. * Get the class name
  53911. * @returns "DefaultRenderingPipeline"
  53912. */
  53913. getClassName(): string;
  53914. /**
  53915. * Force the compilation of the entire pipeline.
  53916. */
  53917. prepare(): void;
  53918. private _hasCleared;
  53919. private _prevPostProcess;
  53920. private _prevPrevPostProcess;
  53921. private _setAutoClearAndTextureSharing;
  53922. private _depthOfFieldSceneObserver;
  53923. private _buildPipeline;
  53924. private _disposePostProcesses;
  53925. /**
  53926. * Adds a camera to the pipeline
  53927. * @param camera the camera to be added
  53928. */
  53929. addCamera(camera: Camera): void;
  53930. /**
  53931. * Removes a camera from the pipeline
  53932. * @param camera the camera to remove
  53933. */
  53934. removeCamera(camera: Camera): void;
  53935. /**
  53936. * Dispose of the pipeline and stop all post processes
  53937. */
  53938. dispose(): void;
  53939. /**
  53940. * Serialize the rendering pipeline (Used when exporting)
  53941. * @returns the serialized object
  53942. */
  53943. serialize(): any;
  53944. /**
  53945. * Parse the serialized pipeline
  53946. * @param source Source pipeline.
  53947. * @param scene The scene to load the pipeline to.
  53948. * @param rootUrl The URL of the serialized pipeline.
  53949. * @returns An instantiated pipeline from the serialized object.
  53950. */
  53951. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53952. }
  53953. }
  53954. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53955. /** @hidden */
  53956. export var lensHighlightsPixelShader: {
  53957. name: string;
  53958. shader: string;
  53959. };
  53960. }
  53961. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53962. /** @hidden */
  53963. export var depthOfFieldPixelShader: {
  53964. name: string;
  53965. shader: string;
  53966. };
  53967. }
  53968. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  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/chromaticAberration.fragment";
  53973. import "babylonjs/Shaders/lensHighlights.fragment";
  53974. import "babylonjs/Shaders/depthOfField.fragment";
  53975. /**
  53976. * BABYLON.JS Chromatic Aberration GLSL Shader
  53977. * Author: Olivier Guyot
  53978. * Separates very slightly R, G and B colors on the edges of the screen
  53979. * Inspired by Francois Tarlier & Martins Upitis
  53980. */
  53981. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53982. /**
  53983. * @ignore
  53984. * The chromatic aberration PostProcess id in the pipeline
  53985. */
  53986. LensChromaticAberrationEffect: string;
  53987. /**
  53988. * @ignore
  53989. * The highlights enhancing PostProcess id in the pipeline
  53990. */
  53991. HighlightsEnhancingEffect: string;
  53992. /**
  53993. * @ignore
  53994. * The depth-of-field PostProcess id in the pipeline
  53995. */
  53996. LensDepthOfFieldEffect: string;
  53997. private _scene;
  53998. private _depthTexture;
  53999. private _grainTexture;
  54000. private _chromaticAberrationPostProcess;
  54001. private _highlightsPostProcess;
  54002. private _depthOfFieldPostProcess;
  54003. private _edgeBlur;
  54004. private _grainAmount;
  54005. private _chromaticAberration;
  54006. private _distortion;
  54007. private _highlightsGain;
  54008. private _highlightsThreshold;
  54009. private _dofDistance;
  54010. private _dofAperture;
  54011. private _dofDarken;
  54012. private _dofPentagon;
  54013. private _blurNoise;
  54014. /**
  54015. * @constructor
  54016. *
  54017. * Effect parameters are as follow:
  54018. * {
  54019. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54020. * edge_blur: number; // from 0 to x (1 for realism)
  54021. * distortion: number; // from 0 to x (1 for realism)
  54022. * grain_amount: number; // from 0 to 1
  54023. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54024. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54025. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54026. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54027. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54028. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54029. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54030. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54031. * }
  54032. * Note: if an effect parameter is unset, effect is disabled
  54033. *
  54034. * @param name The rendering pipeline name
  54035. * @param parameters - An object containing all parameters (see above)
  54036. * @param scene The scene linked to this pipeline
  54037. * @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)
  54038. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54039. */
  54040. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54041. /**
  54042. * Sets the amount of blur at the edges
  54043. * @param amount blur amount
  54044. */
  54045. setEdgeBlur(amount: number): void;
  54046. /**
  54047. * Sets edge blur to 0
  54048. */
  54049. disableEdgeBlur(): void;
  54050. /**
  54051. * Sets the amout of grain
  54052. * @param amount Amount of grain
  54053. */
  54054. setGrainAmount(amount: number): void;
  54055. /**
  54056. * Set grain amount to 0
  54057. */
  54058. disableGrain(): void;
  54059. /**
  54060. * Sets the chromatic aberration amount
  54061. * @param amount amount of chromatic aberration
  54062. */
  54063. setChromaticAberration(amount: number): void;
  54064. /**
  54065. * Sets chromatic aberration amount to 0
  54066. */
  54067. disableChromaticAberration(): void;
  54068. /**
  54069. * Sets the EdgeDistortion amount
  54070. * @param amount amount of EdgeDistortion
  54071. */
  54072. setEdgeDistortion(amount: number): void;
  54073. /**
  54074. * Sets edge distortion to 0
  54075. */
  54076. disableEdgeDistortion(): void;
  54077. /**
  54078. * Sets the FocusDistance amount
  54079. * @param amount amount of FocusDistance
  54080. */
  54081. setFocusDistance(amount: number): void;
  54082. /**
  54083. * Disables depth of field
  54084. */
  54085. disableDepthOfField(): void;
  54086. /**
  54087. * Sets the Aperture amount
  54088. * @param amount amount of Aperture
  54089. */
  54090. setAperture(amount: number): void;
  54091. /**
  54092. * Sets the DarkenOutOfFocus amount
  54093. * @param amount amount of DarkenOutOfFocus
  54094. */
  54095. setDarkenOutOfFocus(amount: number): void;
  54096. /**
  54097. * Creates a pentagon bokeh effect
  54098. */
  54099. enablePentagonBokeh(): void;
  54100. /**
  54101. * Disables the pentagon bokeh effect
  54102. */
  54103. disablePentagonBokeh(): void;
  54104. /**
  54105. * Enables noise blur
  54106. */
  54107. enableNoiseBlur(): void;
  54108. /**
  54109. * Disables noise blur
  54110. */
  54111. disableNoiseBlur(): void;
  54112. /**
  54113. * Sets the HighlightsGain amount
  54114. * @param amount amount of HighlightsGain
  54115. */
  54116. setHighlightsGain(amount: number): void;
  54117. /**
  54118. * Sets the HighlightsThreshold amount
  54119. * @param amount amount of HighlightsThreshold
  54120. */
  54121. setHighlightsThreshold(amount: number): void;
  54122. /**
  54123. * Disables highlights
  54124. */
  54125. disableHighlights(): void;
  54126. /**
  54127. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54128. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54129. */
  54130. dispose(disableDepthRender?: boolean): void;
  54131. private _createChromaticAberrationPostProcess;
  54132. private _createHighlightsPostProcess;
  54133. private _createDepthOfFieldPostProcess;
  54134. private _createGrainTexture;
  54135. }
  54136. }
  54137. declare module "babylonjs/Shaders/ssao2.fragment" {
  54138. /** @hidden */
  54139. export var ssao2PixelShader: {
  54140. name: string;
  54141. shader: string;
  54142. };
  54143. }
  54144. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54145. /** @hidden */
  54146. export var ssaoCombinePixelShader: {
  54147. name: string;
  54148. shader: string;
  54149. };
  54150. }
  54151. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54152. import { Camera } from "babylonjs/Cameras/camera";
  54153. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54154. import { Scene } from "babylonjs/scene";
  54155. import "babylonjs/Shaders/ssao2.fragment";
  54156. import "babylonjs/Shaders/ssaoCombine.fragment";
  54157. /**
  54158. * Render pipeline to produce ssao effect
  54159. */
  54160. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54161. /**
  54162. * @ignore
  54163. * The PassPostProcess id in the pipeline that contains the original scene color
  54164. */
  54165. SSAOOriginalSceneColorEffect: string;
  54166. /**
  54167. * @ignore
  54168. * The SSAO PostProcess id in the pipeline
  54169. */
  54170. SSAORenderEffect: string;
  54171. /**
  54172. * @ignore
  54173. * The horizontal blur PostProcess id in the pipeline
  54174. */
  54175. SSAOBlurHRenderEffect: string;
  54176. /**
  54177. * @ignore
  54178. * The vertical blur PostProcess id in the pipeline
  54179. */
  54180. SSAOBlurVRenderEffect: string;
  54181. /**
  54182. * @ignore
  54183. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54184. */
  54185. SSAOCombineRenderEffect: string;
  54186. /**
  54187. * The output strength of the SSAO post-process. Default value is 1.0.
  54188. */
  54189. totalStrength: number;
  54190. /**
  54191. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54192. */
  54193. maxZ: number;
  54194. /**
  54195. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54196. */
  54197. minZAspect: number;
  54198. private _samples;
  54199. /**
  54200. * Number of samples used for the SSAO calculations. Default value is 8
  54201. */
  54202. samples: number;
  54203. private _textureSamples;
  54204. /**
  54205. * Number of samples to use for antialiasing
  54206. */
  54207. textureSamples: number;
  54208. /**
  54209. * Ratio object used for SSAO ratio and blur ratio
  54210. */
  54211. private _ratio;
  54212. /**
  54213. * Dynamically generated sphere sampler.
  54214. */
  54215. private _sampleSphere;
  54216. /**
  54217. * Blur filter offsets
  54218. */
  54219. private _samplerOffsets;
  54220. private _expensiveBlur;
  54221. /**
  54222. * If bilateral blur should be used
  54223. */
  54224. expensiveBlur: boolean;
  54225. /**
  54226. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54227. */
  54228. radius: number;
  54229. /**
  54230. * The base color of the SSAO post-process
  54231. * The final result is "base + ssao" between [0, 1]
  54232. */
  54233. base: number;
  54234. /**
  54235. * Support test.
  54236. */
  54237. static readonly IsSupported: boolean;
  54238. private _scene;
  54239. private _depthTexture;
  54240. private _normalTexture;
  54241. private _randomTexture;
  54242. private _originalColorPostProcess;
  54243. private _ssaoPostProcess;
  54244. private _blurHPostProcess;
  54245. private _blurVPostProcess;
  54246. private _ssaoCombinePostProcess;
  54247. private _firstUpdate;
  54248. /**
  54249. * Gets active scene
  54250. */
  54251. readonly scene: Scene;
  54252. /**
  54253. * @constructor
  54254. * @param name The rendering pipeline name
  54255. * @param scene The scene linked to this pipeline
  54256. * @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 }
  54257. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54258. */
  54259. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54260. /**
  54261. * Get the class name
  54262. * @returns "SSAO2RenderingPipeline"
  54263. */
  54264. getClassName(): string;
  54265. /**
  54266. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54267. */
  54268. dispose(disableGeometryBufferRenderer?: boolean): void;
  54269. private _createBlurPostProcess;
  54270. /** @hidden */
  54271. _rebuild(): void;
  54272. private _bits;
  54273. private _radicalInverse_VdC;
  54274. private _hammersley;
  54275. private _hemisphereSample_uniform;
  54276. private _generateHemisphere;
  54277. private _createSSAOPostProcess;
  54278. private _createSSAOCombinePostProcess;
  54279. private _createRandomTexture;
  54280. /**
  54281. * Serialize the rendering pipeline (Used when exporting)
  54282. * @returns the serialized object
  54283. */
  54284. serialize(): any;
  54285. /**
  54286. * Parse the serialized pipeline
  54287. * @param source Source pipeline.
  54288. * @param scene The scene to load the pipeline to.
  54289. * @param rootUrl The URL of the serialized pipeline.
  54290. * @returns An instantiated pipeline from the serialized object.
  54291. */
  54292. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54293. }
  54294. }
  54295. declare module "babylonjs/Shaders/ssao.fragment" {
  54296. /** @hidden */
  54297. export var ssaoPixelShader: {
  54298. name: string;
  54299. shader: string;
  54300. };
  54301. }
  54302. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54303. import { Camera } from "babylonjs/Cameras/camera";
  54304. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54305. import { Scene } from "babylonjs/scene";
  54306. import "babylonjs/Shaders/ssao.fragment";
  54307. import "babylonjs/Shaders/ssaoCombine.fragment";
  54308. /**
  54309. * Render pipeline to produce ssao effect
  54310. */
  54311. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54312. /**
  54313. * @ignore
  54314. * The PassPostProcess id in the pipeline that contains the original scene color
  54315. */
  54316. SSAOOriginalSceneColorEffect: string;
  54317. /**
  54318. * @ignore
  54319. * The SSAO PostProcess id in the pipeline
  54320. */
  54321. SSAORenderEffect: string;
  54322. /**
  54323. * @ignore
  54324. * The horizontal blur PostProcess id in the pipeline
  54325. */
  54326. SSAOBlurHRenderEffect: string;
  54327. /**
  54328. * @ignore
  54329. * The vertical blur PostProcess id in the pipeline
  54330. */
  54331. SSAOBlurVRenderEffect: string;
  54332. /**
  54333. * @ignore
  54334. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54335. */
  54336. SSAOCombineRenderEffect: string;
  54337. /**
  54338. * The output strength of the SSAO post-process. Default value is 1.0.
  54339. */
  54340. totalStrength: number;
  54341. /**
  54342. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54343. */
  54344. radius: number;
  54345. /**
  54346. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54347. * Must not be equal to fallOff and superior to fallOff.
  54348. * Default value is 0.0075
  54349. */
  54350. area: number;
  54351. /**
  54352. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54353. * Must not be equal to area and inferior to area.
  54354. * Default value is 0.000001
  54355. */
  54356. fallOff: number;
  54357. /**
  54358. * The base color of the SSAO post-process
  54359. * The final result is "base + ssao" between [0, 1]
  54360. */
  54361. base: number;
  54362. private _scene;
  54363. private _depthTexture;
  54364. private _randomTexture;
  54365. private _originalColorPostProcess;
  54366. private _ssaoPostProcess;
  54367. private _blurHPostProcess;
  54368. private _blurVPostProcess;
  54369. private _ssaoCombinePostProcess;
  54370. private _firstUpdate;
  54371. /**
  54372. * Gets active scene
  54373. */
  54374. readonly scene: Scene;
  54375. /**
  54376. * @constructor
  54377. * @param name - The rendering pipeline name
  54378. * @param scene - The scene linked to this pipeline
  54379. * @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 }
  54380. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54381. */
  54382. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54383. /**
  54384. * Get the class name
  54385. * @returns "SSAORenderingPipeline"
  54386. */
  54387. getClassName(): string;
  54388. /**
  54389. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54390. */
  54391. dispose(disableDepthRender?: boolean): void;
  54392. private _createBlurPostProcess;
  54393. /** @hidden */
  54394. _rebuild(): void;
  54395. private _createSSAOPostProcess;
  54396. private _createSSAOCombinePostProcess;
  54397. private _createRandomTexture;
  54398. }
  54399. }
  54400. declare module "babylonjs/Shaders/standard.fragment" {
  54401. /** @hidden */
  54402. export var standardPixelShader: {
  54403. name: string;
  54404. shader: string;
  54405. };
  54406. }
  54407. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54408. import { Nullable } from "babylonjs/types";
  54409. import { IAnimatable } from "babylonjs/Misc/tools";
  54410. import { Camera } from "babylonjs/Cameras/camera";
  54411. import { Texture } from "babylonjs/Materials/Textures/texture";
  54412. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54413. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54414. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54415. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54416. import { IDisposable } from "babylonjs/scene";
  54417. import { SpotLight } from "babylonjs/Lights/spotLight";
  54418. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54419. import { Scene } from "babylonjs/scene";
  54420. import { Animation } from "babylonjs/Animations/animation";
  54421. import "babylonjs/Shaders/standard.fragment";
  54422. /**
  54423. * Standard rendering pipeline
  54424. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54425. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54426. */
  54427. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54428. /**
  54429. * Public members
  54430. */
  54431. /**
  54432. * Post-process which contains the original scene color before the pipeline applies all the effects
  54433. */
  54434. originalPostProcess: Nullable<PostProcess>;
  54435. /**
  54436. * Post-process used to down scale an image x4
  54437. */
  54438. downSampleX4PostProcess: Nullable<PostProcess>;
  54439. /**
  54440. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54441. */
  54442. brightPassPostProcess: Nullable<PostProcess>;
  54443. /**
  54444. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54445. */
  54446. blurHPostProcesses: PostProcess[];
  54447. /**
  54448. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54449. */
  54450. blurVPostProcesses: PostProcess[];
  54451. /**
  54452. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54453. */
  54454. textureAdderPostProcess: Nullable<PostProcess>;
  54455. /**
  54456. * Post-process used to create volumetric lighting effect
  54457. */
  54458. volumetricLightPostProcess: Nullable<PostProcess>;
  54459. /**
  54460. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54461. */
  54462. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54463. /**
  54464. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54465. */
  54466. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54467. /**
  54468. * Post-process used to merge the volumetric light effect and the real scene color
  54469. */
  54470. volumetricLightMergePostProces: Nullable<PostProcess>;
  54471. /**
  54472. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54473. */
  54474. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54475. /**
  54476. * Base post-process used to calculate the average luminance of the final image for HDR
  54477. */
  54478. luminancePostProcess: Nullable<PostProcess>;
  54479. /**
  54480. * Post-processes used to create down sample post-processes in order to get
  54481. * the average luminance of the final image for HDR
  54482. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54483. */
  54484. luminanceDownSamplePostProcesses: PostProcess[];
  54485. /**
  54486. * Post-process used to create a HDR effect (light adaptation)
  54487. */
  54488. hdrPostProcess: Nullable<PostProcess>;
  54489. /**
  54490. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54491. */
  54492. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54493. /**
  54494. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54495. */
  54496. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54497. /**
  54498. * Post-process used to merge the final HDR post-process and the real scene color
  54499. */
  54500. hdrFinalPostProcess: Nullable<PostProcess>;
  54501. /**
  54502. * Post-process used to create a lens flare effect
  54503. */
  54504. lensFlarePostProcess: Nullable<PostProcess>;
  54505. /**
  54506. * Post-process that merges the result of the lens flare post-process and the real scene color
  54507. */
  54508. lensFlareComposePostProcess: Nullable<PostProcess>;
  54509. /**
  54510. * Post-process used to create a motion blur effect
  54511. */
  54512. motionBlurPostProcess: Nullable<PostProcess>;
  54513. /**
  54514. * Post-process used to create a depth of field effect
  54515. */
  54516. depthOfFieldPostProcess: Nullable<PostProcess>;
  54517. /**
  54518. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54519. */
  54520. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54521. /**
  54522. * Represents the brightness threshold in order to configure the illuminated surfaces
  54523. */
  54524. brightThreshold: number;
  54525. /**
  54526. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54527. */
  54528. blurWidth: number;
  54529. /**
  54530. * Sets if the blur for highlighted surfaces must be only horizontal
  54531. */
  54532. horizontalBlur: boolean;
  54533. /**
  54534. * Sets the overall exposure used by the pipeline
  54535. */
  54536. exposure: number;
  54537. /**
  54538. * Texture used typically to simulate "dirty" on camera lens
  54539. */
  54540. lensTexture: Nullable<Texture>;
  54541. /**
  54542. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54543. */
  54544. volumetricLightCoefficient: number;
  54545. /**
  54546. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54547. */
  54548. volumetricLightPower: number;
  54549. /**
  54550. * Used the set the blur intensity to smooth the volumetric lights
  54551. */
  54552. volumetricLightBlurScale: number;
  54553. /**
  54554. * Light (spot or directional) used to generate the volumetric lights rays
  54555. * The source light must have a shadow generate so the pipeline can get its
  54556. * depth map
  54557. */
  54558. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54559. /**
  54560. * For eye adaptation, represents the minimum luminance the eye can see
  54561. */
  54562. hdrMinimumLuminance: number;
  54563. /**
  54564. * For eye adaptation, represents the decrease luminance speed
  54565. */
  54566. hdrDecreaseRate: number;
  54567. /**
  54568. * For eye adaptation, represents the increase luminance speed
  54569. */
  54570. hdrIncreaseRate: number;
  54571. /**
  54572. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54573. */
  54574. lensColorTexture: Nullable<Texture>;
  54575. /**
  54576. * The overall strengh for the lens flare effect
  54577. */
  54578. lensFlareStrength: number;
  54579. /**
  54580. * Dispersion coefficient for lens flare ghosts
  54581. */
  54582. lensFlareGhostDispersal: number;
  54583. /**
  54584. * Main lens flare halo width
  54585. */
  54586. lensFlareHaloWidth: number;
  54587. /**
  54588. * Based on the lens distortion effect, defines how much the lens flare result
  54589. * is distorted
  54590. */
  54591. lensFlareDistortionStrength: number;
  54592. /**
  54593. * Lens star texture must be used to simulate rays on the flares and is available
  54594. * in the documentation
  54595. */
  54596. lensStarTexture: Nullable<Texture>;
  54597. /**
  54598. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54599. * flare effect by taking account of the dirt texture
  54600. */
  54601. lensFlareDirtTexture: Nullable<Texture>;
  54602. /**
  54603. * Represents the focal length for the depth of field effect
  54604. */
  54605. depthOfFieldDistance: number;
  54606. /**
  54607. * Represents the blur intensity for the blurred part of the depth of field effect
  54608. */
  54609. depthOfFieldBlurWidth: number;
  54610. /**
  54611. * For motion blur, defines how much the image is blurred by the movement
  54612. */
  54613. motionStrength: number;
  54614. /**
  54615. * List of animations for the pipeline (IAnimatable implementation)
  54616. */
  54617. animations: Animation[];
  54618. /**
  54619. * Private members
  54620. */
  54621. private _scene;
  54622. private _currentDepthOfFieldSource;
  54623. private _basePostProcess;
  54624. private _hdrCurrentLuminance;
  54625. private _floatTextureType;
  54626. private _ratio;
  54627. private _bloomEnabled;
  54628. private _depthOfFieldEnabled;
  54629. private _vlsEnabled;
  54630. private _lensFlareEnabled;
  54631. private _hdrEnabled;
  54632. private _motionBlurEnabled;
  54633. private _fxaaEnabled;
  54634. private _motionBlurSamples;
  54635. private _volumetricLightStepsCount;
  54636. private _samples;
  54637. /**
  54638. * @ignore
  54639. * Specifies if the bloom pipeline is enabled
  54640. */
  54641. BloomEnabled: boolean;
  54642. /**
  54643. * @ignore
  54644. * Specifies if the depth of field pipeline is enabed
  54645. */
  54646. DepthOfFieldEnabled: boolean;
  54647. /**
  54648. * @ignore
  54649. * Specifies if the lens flare pipeline is enabed
  54650. */
  54651. LensFlareEnabled: boolean;
  54652. /**
  54653. * @ignore
  54654. * Specifies if the HDR pipeline is enabled
  54655. */
  54656. HDREnabled: boolean;
  54657. /**
  54658. * @ignore
  54659. * Specifies if the volumetric lights scattering effect is enabled
  54660. */
  54661. VLSEnabled: boolean;
  54662. /**
  54663. * @ignore
  54664. * Specifies if the motion blur effect is enabled
  54665. */
  54666. MotionBlurEnabled: boolean;
  54667. /**
  54668. * Specifies if anti-aliasing is enabled
  54669. */
  54670. fxaaEnabled: boolean;
  54671. /**
  54672. * Specifies the number of steps used to calculate the volumetric lights
  54673. * Typically in interval [50, 200]
  54674. */
  54675. volumetricLightStepsCount: number;
  54676. /**
  54677. * Specifies the number of samples used for the motion blur effect
  54678. * Typically in interval [16, 64]
  54679. */
  54680. motionBlurSamples: number;
  54681. /**
  54682. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54683. */
  54684. samples: number;
  54685. /**
  54686. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54687. * @constructor
  54688. * @param name The rendering pipeline name
  54689. * @param scene The scene linked to this pipeline
  54690. * @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)
  54691. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54692. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54693. */
  54694. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54695. private _buildPipeline;
  54696. private _createDownSampleX4PostProcess;
  54697. private _createBrightPassPostProcess;
  54698. private _createBlurPostProcesses;
  54699. private _createTextureAdderPostProcess;
  54700. private _createVolumetricLightPostProcess;
  54701. private _createLuminancePostProcesses;
  54702. private _createHdrPostProcess;
  54703. private _createLensFlarePostProcess;
  54704. private _createDepthOfFieldPostProcess;
  54705. private _createMotionBlurPostProcess;
  54706. private _getDepthTexture;
  54707. private _disposePostProcesses;
  54708. /**
  54709. * Dispose of the pipeline and stop all post processes
  54710. */
  54711. dispose(): void;
  54712. /**
  54713. * Serialize the rendering pipeline (Used when exporting)
  54714. * @returns the serialized object
  54715. */
  54716. serialize(): any;
  54717. /**
  54718. * Parse the serialized pipeline
  54719. * @param source Source pipeline.
  54720. * @param scene The scene to load the pipeline to.
  54721. * @param rootUrl The URL of the serialized pipeline.
  54722. * @returns An instantiated pipeline from the serialized object.
  54723. */
  54724. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54725. /**
  54726. * Luminance steps
  54727. */
  54728. static LuminanceSteps: number;
  54729. }
  54730. }
  54731. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54732. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54733. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54734. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54735. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54736. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54737. }
  54738. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54739. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54740. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54741. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54742. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54743. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54744. }
  54745. declare module "babylonjs/Shaders/tonemap.fragment" {
  54746. /** @hidden */
  54747. export var tonemapPixelShader: {
  54748. name: string;
  54749. shader: string;
  54750. };
  54751. }
  54752. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54753. import { Camera } from "babylonjs/Cameras/camera";
  54754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54755. import "babylonjs/Shaders/tonemap.fragment";
  54756. import { Engine } from "babylonjs/Engines/engine";
  54757. /** Defines operator used for tonemapping */
  54758. export enum TonemappingOperator {
  54759. /** Hable */
  54760. Hable = 0,
  54761. /** Reinhard */
  54762. Reinhard = 1,
  54763. /** HejiDawson */
  54764. HejiDawson = 2,
  54765. /** Photographic */
  54766. Photographic = 3
  54767. }
  54768. /**
  54769. * Defines a post process to apply tone mapping
  54770. */
  54771. export class TonemapPostProcess extends PostProcess {
  54772. private _operator;
  54773. /** Defines the required exposure adjustement */
  54774. exposureAdjustment: number;
  54775. /**
  54776. * Creates a new TonemapPostProcess
  54777. * @param name defines the name of the postprocess
  54778. * @param _operator defines the operator to use
  54779. * @param exposureAdjustment defines the required exposure adjustement
  54780. * @param camera defines the camera to use (can be null)
  54781. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54782. * @param engine defines the hosting engine (can be ignore if camera is set)
  54783. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54784. */
  54785. constructor(name: string, _operator: TonemappingOperator,
  54786. /** Defines the required exposure adjustement */
  54787. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54788. }
  54789. }
  54790. declare module "babylonjs/Shaders/depth.vertex" {
  54791. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54792. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54793. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54794. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54795. /** @hidden */
  54796. export var depthVertexShader: {
  54797. name: string;
  54798. shader: string;
  54799. };
  54800. }
  54801. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54802. /** @hidden */
  54803. export var volumetricLightScatteringPixelShader: {
  54804. name: string;
  54805. shader: string;
  54806. };
  54807. }
  54808. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54809. /** @hidden */
  54810. export var volumetricLightScatteringPassPixelShader: {
  54811. name: string;
  54812. shader: string;
  54813. };
  54814. }
  54815. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54816. import { Vector3 } from "babylonjs/Maths/math";
  54817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54818. import { Mesh } from "babylonjs/Meshes/mesh";
  54819. import { Camera } from "babylonjs/Cameras/camera";
  54820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54821. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54822. import { Scene } from "babylonjs/scene";
  54823. import "babylonjs/Meshes/Builders/planeBuilder";
  54824. import "babylonjs/Shaders/depth.vertex";
  54825. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54826. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54827. import { Engine } from "babylonjs/Engines/engine";
  54828. /**
  54829. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54830. */
  54831. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54832. private _volumetricLightScatteringPass;
  54833. private _volumetricLightScatteringRTT;
  54834. private _viewPort;
  54835. private _screenCoordinates;
  54836. private _cachedDefines;
  54837. /**
  54838. * If not undefined, the mesh position is computed from the attached node position
  54839. */
  54840. attachedNode: {
  54841. position: Vector3;
  54842. };
  54843. /**
  54844. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54845. */
  54846. customMeshPosition: Vector3;
  54847. /**
  54848. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54849. */
  54850. useCustomMeshPosition: boolean;
  54851. /**
  54852. * If the post-process should inverse the light scattering direction
  54853. */
  54854. invert: boolean;
  54855. /**
  54856. * The internal mesh used by the post-process
  54857. */
  54858. mesh: Mesh;
  54859. /**
  54860. * @hidden
  54861. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54862. */
  54863. useDiffuseColor: boolean;
  54864. /**
  54865. * Array containing the excluded meshes not rendered in the internal pass
  54866. */
  54867. excludedMeshes: AbstractMesh[];
  54868. /**
  54869. * Controls the overall intensity of the post-process
  54870. */
  54871. exposure: number;
  54872. /**
  54873. * Dissipates each sample's contribution in range [0, 1]
  54874. */
  54875. decay: number;
  54876. /**
  54877. * Controls the overall intensity of each sample
  54878. */
  54879. weight: number;
  54880. /**
  54881. * Controls the density of each sample
  54882. */
  54883. density: number;
  54884. /**
  54885. * @constructor
  54886. * @param name The post-process name
  54887. * @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)
  54888. * @param camera The camera that the post-process will be attached to
  54889. * @param mesh The mesh used to create the light scattering
  54890. * @param samples The post-process quality, default 100
  54891. * @param samplingModeThe post-process filtering mode
  54892. * @param engine The babylon engine
  54893. * @param reusable If the post-process is reusable
  54894. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54895. */
  54896. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54897. /**
  54898. * Returns the string "VolumetricLightScatteringPostProcess"
  54899. * @returns "VolumetricLightScatteringPostProcess"
  54900. */
  54901. getClassName(): string;
  54902. private _isReady;
  54903. /**
  54904. * Sets the new light position for light scattering effect
  54905. * @param position The new custom light position
  54906. */
  54907. setCustomMeshPosition(position: Vector3): void;
  54908. /**
  54909. * Returns the light position for light scattering effect
  54910. * @return Vector3 The custom light position
  54911. */
  54912. getCustomMeshPosition(): Vector3;
  54913. /**
  54914. * Disposes the internal assets and detaches the post-process from the camera
  54915. */
  54916. dispose(camera: Camera): void;
  54917. /**
  54918. * Returns the render target texture used by the post-process
  54919. * @return the render target texture used by the post-process
  54920. */
  54921. getPass(): RenderTargetTexture;
  54922. private _meshExcluded;
  54923. private _createPass;
  54924. private _updateMeshScreenCoordinates;
  54925. /**
  54926. * Creates a default mesh for the Volumeric Light Scattering post-process
  54927. * @param name The mesh name
  54928. * @param scene The scene where to create the mesh
  54929. * @return the default mesh
  54930. */
  54931. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54932. }
  54933. }
  54934. declare module "babylonjs/PostProcesses/index" {
  54935. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54936. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54937. export * from "babylonjs/PostProcesses/bloomEffect";
  54938. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54939. export * from "babylonjs/PostProcesses/blurPostProcess";
  54940. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54941. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54942. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54943. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54944. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54945. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54946. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54947. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54948. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54949. export * from "babylonjs/PostProcesses/filterPostProcess";
  54950. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54951. export * from "babylonjs/PostProcesses/grainPostProcess";
  54952. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54953. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54954. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54955. export * from "babylonjs/PostProcesses/passPostProcess";
  54956. export * from "babylonjs/PostProcesses/postProcess";
  54957. export * from "babylonjs/PostProcesses/postProcessManager";
  54958. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54959. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54960. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54961. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54962. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54963. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54964. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54965. }
  54966. declare module "babylonjs/Probes/index" {
  54967. export * from "babylonjs/Probes/reflectionProbe";
  54968. }
  54969. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54970. import { Scene } from "babylonjs/scene";
  54971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54972. import { Color3 } from "babylonjs/Maths/math";
  54973. import { SmartArray } from "babylonjs/Misc/smartArray";
  54974. import { ISceneComponent } from "babylonjs/sceneComponent";
  54975. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54976. import "babylonjs/Meshes/Builders/boxBuilder";
  54977. import "babylonjs/Shaders/color.fragment";
  54978. import "babylonjs/Shaders/color.vertex";
  54979. module "babylonjs/scene" {
  54980. interface Scene {
  54981. /** @hidden (Backing field) */
  54982. _boundingBoxRenderer: BoundingBoxRenderer;
  54983. /** @hidden (Backing field) */
  54984. _forceShowBoundingBoxes: boolean;
  54985. /**
  54986. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54987. */
  54988. forceShowBoundingBoxes: boolean;
  54989. /**
  54990. * Gets the bounding box renderer associated with the scene
  54991. * @returns a BoundingBoxRenderer
  54992. */
  54993. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54994. }
  54995. }
  54996. module "babylonjs/Meshes/abstractMesh" {
  54997. interface AbstractMesh {
  54998. /** @hidden (Backing field) */
  54999. _showBoundingBox: boolean;
  55000. /**
  55001. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55002. */
  55003. showBoundingBox: boolean;
  55004. }
  55005. }
  55006. /**
  55007. * Component responsible of rendering the bounding box of the meshes in a scene.
  55008. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55009. */
  55010. export class BoundingBoxRenderer implements ISceneComponent {
  55011. /**
  55012. * The component name helpfull to identify the component in the list of scene components.
  55013. */
  55014. readonly name: string;
  55015. /**
  55016. * The scene the component belongs to.
  55017. */
  55018. scene: Scene;
  55019. /**
  55020. * Color of the bounding box lines placed in front of an object
  55021. */
  55022. frontColor: Color3;
  55023. /**
  55024. * Color of the bounding box lines placed behind an object
  55025. */
  55026. backColor: Color3;
  55027. /**
  55028. * Defines if the renderer should show the back lines or not
  55029. */
  55030. showBackLines: boolean;
  55031. /**
  55032. * @hidden
  55033. */
  55034. renderList: SmartArray<BoundingBox>;
  55035. private _colorShader;
  55036. private _vertexBuffers;
  55037. private _indexBuffer;
  55038. /**
  55039. * Instantiates a new bounding box renderer in a scene.
  55040. * @param scene the scene the renderer renders in
  55041. */
  55042. constructor(scene: Scene);
  55043. /**
  55044. * Registers the component in a given scene
  55045. */
  55046. register(): void;
  55047. private _evaluateSubMesh;
  55048. private _activeMesh;
  55049. private _prepareRessources;
  55050. private _createIndexBuffer;
  55051. /**
  55052. * Rebuilds the elements related to this component in case of
  55053. * context lost for instance.
  55054. */
  55055. rebuild(): void;
  55056. /**
  55057. * @hidden
  55058. */
  55059. reset(): void;
  55060. /**
  55061. * Render the bounding boxes of a specific rendering group
  55062. * @param renderingGroupId defines the rendering group to render
  55063. */
  55064. render(renderingGroupId: number): void;
  55065. /**
  55066. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55067. * @param mesh Define the mesh to render the occlusion bounding box for
  55068. */
  55069. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55070. /**
  55071. * Dispose and release the resources attached to this renderer.
  55072. */
  55073. dispose(): void;
  55074. }
  55075. }
  55076. declare module "babylonjs/Shaders/depth.fragment" {
  55077. /** @hidden */
  55078. export var depthPixelShader: {
  55079. name: string;
  55080. shader: string;
  55081. };
  55082. }
  55083. declare module "babylonjs/Rendering/depthRenderer" {
  55084. import { Nullable } from "babylonjs/types";
  55085. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55086. import { Scene } from "babylonjs/scene";
  55087. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55088. import { Camera } from "babylonjs/Cameras/camera";
  55089. import "babylonjs/Shaders/depth.fragment";
  55090. import "babylonjs/Shaders/depth.vertex";
  55091. /**
  55092. * This represents a depth renderer in Babylon.
  55093. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55094. */
  55095. export class DepthRenderer {
  55096. private _scene;
  55097. private _depthMap;
  55098. private _effect;
  55099. private _cachedDefines;
  55100. private _camera;
  55101. /**
  55102. * Specifiess that the depth renderer will only be used within
  55103. * the camera it is created for.
  55104. * This can help forcing its rendering during the camera processing.
  55105. */
  55106. useOnlyInActiveCamera: boolean;
  55107. /** @hidden */
  55108. static _SceneComponentInitialization: (scene: Scene) => void;
  55109. /**
  55110. * Instantiates a depth renderer
  55111. * @param scene The scene the renderer belongs to
  55112. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55113. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55114. */
  55115. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55116. /**
  55117. * Creates the depth rendering effect and checks if the effect is ready.
  55118. * @param subMesh The submesh to be used to render the depth map of
  55119. * @param useInstances If multiple world instances should be used
  55120. * @returns if the depth renderer is ready to render the depth map
  55121. */
  55122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55123. /**
  55124. * Gets the texture which the depth map will be written to.
  55125. * @returns The depth map texture
  55126. */
  55127. getDepthMap(): RenderTargetTexture;
  55128. /**
  55129. * Disposes of the depth renderer.
  55130. */
  55131. dispose(): void;
  55132. }
  55133. }
  55134. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55135. import { Nullable } from "babylonjs/types";
  55136. import { Scene } from "babylonjs/scene";
  55137. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55138. import { Camera } from "babylonjs/Cameras/camera";
  55139. import { ISceneComponent } from "babylonjs/sceneComponent";
  55140. module "babylonjs/scene" {
  55141. interface Scene {
  55142. /** @hidden (Backing field) */
  55143. _depthRenderer: {
  55144. [id: string]: DepthRenderer;
  55145. };
  55146. /**
  55147. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55148. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55149. * @returns the created depth renderer
  55150. */
  55151. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55152. /**
  55153. * Disables a depth renderer for a given camera
  55154. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55155. */
  55156. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55157. }
  55158. }
  55159. /**
  55160. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55161. * in several rendering techniques.
  55162. */
  55163. export class DepthRendererSceneComponent implements ISceneComponent {
  55164. /**
  55165. * The component name helpfull to identify the component in the list of scene components.
  55166. */
  55167. readonly name: string;
  55168. /**
  55169. * The scene the component belongs to.
  55170. */
  55171. scene: Scene;
  55172. /**
  55173. * Creates a new instance of the component for the given scene
  55174. * @param scene Defines the scene to register the component in
  55175. */
  55176. constructor(scene: Scene);
  55177. /**
  55178. * Registers the component in a given scene
  55179. */
  55180. register(): void;
  55181. /**
  55182. * Rebuilds the elements related to this component in case of
  55183. * context lost for instance.
  55184. */
  55185. rebuild(): void;
  55186. /**
  55187. * Disposes the component and the associated ressources
  55188. */
  55189. dispose(): void;
  55190. private _gatherRenderTargets;
  55191. private _gatherActiveCameraRenderTargets;
  55192. }
  55193. }
  55194. declare module "babylonjs/Shaders/outline.fragment" {
  55195. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55196. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55197. /** @hidden */
  55198. export var outlinePixelShader: {
  55199. name: string;
  55200. shader: string;
  55201. };
  55202. }
  55203. declare module "babylonjs/Shaders/outline.vertex" {
  55204. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55205. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55206. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55207. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55208. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55209. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55210. /** @hidden */
  55211. export var outlineVertexShader: {
  55212. name: string;
  55213. shader: string;
  55214. };
  55215. }
  55216. declare module "babylonjs/Rendering/outlineRenderer" {
  55217. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55218. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55219. import { Scene } from "babylonjs/scene";
  55220. import { ISceneComponent } from "babylonjs/sceneComponent";
  55221. import "babylonjs/Shaders/outline.fragment";
  55222. import "babylonjs/Shaders/outline.vertex";
  55223. module "babylonjs/scene" {
  55224. interface Scene {
  55225. /** @hidden */
  55226. _outlineRenderer: OutlineRenderer;
  55227. /**
  55228. * Gets the outline renderer associated with the scene
  55229. * @returns a OutlineRenderer
  55230. */
  55231. getOutlineRenderer(): OutlineRenderer;
  55232. }
  55233. }
  55234. module "babylonjs/Meshes/abstractMesh" {
  55235. interface AbstractMesh {
  55236. /** @hidden (Backing field) */
  55237. _renderOutline: boolean;
  55238. /**
  55239. * Gets or sets a boolean indicating if the outline must be rendered as well
  55240. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55241. */
  55242. renderOutline: boolean;
  55243. /** @hidden (Backing field) */
  55244. _renderOverlay: boolean;
  55245. /**
  55246. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55247. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55248. */
  55249. renderOverlay: boolean;
  55250. }
  55251. }
  55252. /**
  55253. * This class is responsible to draw bothe outline/overlay of meshes.
  55254. * It should not be used directly but through the available method on mesh.
  55255. */
  55256. export class OutlineRenderer implements ISceneComponent {
  55257. /**
  55258. * The name of the component. Each component must have a unique name.
  55259. */
  55260. name: string;
  55261. /**
  55262. * The scene the component belongs to.
  55263. */
  55264. scene: Scene;
  55265. /**
  55266. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55267. */
  55268. zOffset: number;
  55269. private _engine;
  55270. private _effect;
  55271. private _cachedDefines;
  55272. private _savedDepthWrite;
  55273. /**
  55274. * Instantiates a new outline renderer. (There could be only one per scene).
  55275. * @param scene Defines the scene it belongs to
  55276. */
  55277. constructor(scene: Scene);
  55278. /**
  55279. * Register the component to one instance of a scene.
  55280. */
  55281. register(): void;
  55282. /**
  55283. * Rebuilds the elements related to this component in case of
  55284. * context lost for instance.
  55285. */
  55286. rebuild(): void;
  55287. /**
  55288. * Disposes the component and the associated ressources.
  55289. */
  55290. dispose(): void;
  55291. /**
  55292. * Renders the outline in the canvas.
  55293. * @param subMesh Defines the sumesh to render
  55294. * @param batch Defines the batch of meshes in case of instances
  55295. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55296. */
  55297. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55298. /**
  55299. * Returns whether or not the outline renderer is ready for a given submesh.
  55300. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55301. * @param subMesh Defines the submesh to check readyness for
  55302. * @param useInstances Defines wheter wee are trying to render instances or not
  55303. * @returns true if ready otherwise false
  55304. */
  55305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55306. private _beforeRenderingMesh;
  55307. private _afterRenderingMesh;
  55308. }
  55309. }
  55310. declare module "babylonjs/Rendering/index" {
  55311. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55312. export * from "babylonjs/Rendering/depthRenderer";
  55313. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55314. export * from "babylonjs/Rendering/edgesRenderer";
  55315. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55316. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55317. export * from "babylonjs/Rendering/outlineRenderer";
  55318. export * from "babylonjs/Rendering/renderingGroup";
  55319. export * from "babylonjs/Rendering/renderingManager";
  55320. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55321. }
  55322. declare module "babylonjs/Sprites/index" {
  55323. export * from "babylonjs/Sprites/sprite";
  55324. export * from "babylonjs/Sprites/spriteManager";
  55325. export * from "babylonjs/Sprites/spriteSceneComponent";
  55326. }
  55327. declare module "babylonjs/Misc/assetsManager" {
  55328. import { Scene } from "babylonjs/scene";
  55329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55330. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55331. import { Skeleton } from "babylonjs/Bones/skeleton";
  55332. import { Observable } from "babylonjs/Misc/observable";
  55333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55334. import { Texture } from "babylonjs/Materials/Textures/texture";
  55335. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55336. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55337. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55338. /**
  55339. * Defines the list of states available for a task inside a AssetsManager
  55340. */
  55341. export enum AssetTaskState {
  55342. /**
  55343. * Initialization
  55344. */
  55345. INIT = 0,
  55346. /**
  55347. * Running
  55348. */
  55349. RUNNING = 1,
  55350. /**
  55351. * Done
  55352. */
  55353. DONE = 2,
  55354. /**
  55355. * Error
  55356. */
  55357. ERROR = 3
  55358. }
  55359. /**
  55360. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55361. */
  55362. export abstract class AbstractAssetTask {
  55363. /**
  55364. * Task name
  55365. */ name: string;
  55366. /**
  55367. * Callback called when the task is successful
  55368. */
  55369. onSuccess: (task: any) => void;
  55370. /**
  55371. * Callback called when the task is not successful
  55372. */
  55373. onError: (task: any, message?: string, exception?: any) => void;
  55374. /**
  55375. * Creates a new AssetsManager
  55376. * @param name defines the name of the task
  55377. */
  55378. constructor(
  55379. /**
  55380. * Task name
  55381. */ name: string);
  55382. private _isCompleted;
  55383. private _taskState;
  55384. private _errorObject;
  55385. /**
  55386. * Get if the task is completed
  55387. */
  55388. readonly isCompleted: boolean;
  55389. /**
  55390. * Gets the current state of the task
  55391. */
  55392. readonly taskState: AssetTaskState;
  55393. /**
  55394. * Gets the current error object (if task is in error)
  55395. */
  55396. readonly errorObject: {
  55397. message?: string;
  55398. exception?: any;
  55399. };
  55400. /**
  55401. * Internal only
  55402. * @hidden
  55403. */
  55404. _setErrorObject(message?: string, exception?: any): void;
  55405. /**
  55406. * Execute the current task
  55407. * @param scene defines the scene where you want your assets to be loaded
  55408. * @param onSuccess is a callback called when the task is successfully executed
  55409. * @param onError is a callback called if an error occurs
  55410. */
  55411. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55412. /**
  55413. * Execute the current task
  55414. * @param scene defines the scene where you want your assets to be loaded
  55415. * @param onSuccess is a callback called when the task is successfully executed
  55416. * @param onError is a callback called if an error occurs
  55417. */
  55418. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55419. /**
  55420. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55421. * This can be used with failed tasks that have the reason for failure fixed.
  55422. */
  55423. reset(): void;
  55424. private onErrorCallback;
  55425. private onDoneCallback;
  55426. }
  55427. /**
  55428. * Define the interface used by progress events raised during assets loading
  55429. */
  55430. export interface IAssetsProgressEvent {
  55431. /**
  55432. * Defines the number of remaining tasks to process
  55433. */
  55434. remainingCount: number;
  55435. /**
  55436. * Defines the total number of tasks
  55437. */
  55438. totalCount: number;
  55439. /**
  55440. * Defines the task that was just processed
  55441. */
  55442. task: AbstractAssetTask;
  55443. }
  55444. /**
  55445. * Class used to share progress information about assets loading
  55446. */
  55447. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55448. /**
  55449. * Defines the number of remaining tasks to process
  55450. */
  55451. remainingCount: number;
  55452. /**
  55453. * Defines the total number of tasks
  55454. */
  55455. totalCount: number;
  55456. /**
  55457. * Defines the task that was just processed
  55458. */
  55459. task: AbstractAssetTask;
  55460. /**
  55461. * Creates a AssetsProgressEvent
  55462. * @param remainingCount defines the number of remaining tasks to process
  55463. * @param totalCount defines the total number of tasks
  55464. * @param task defines the task that was just processed
  55465. */
  55466. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55467. }
  55468. /**
  55469. * Define a task used by AssetsManager to load meshes
  55470. */
  55471. export class MeshAssetTask extends AbstractAssetTask {
  55472. /**
  55473. * Defines the name of the task
  55474. */
  55475. name: string;
  55476. /**
  55477. * Defines the list of mesh's names you want to load
  55478. */
  55479. meshesNames: any;
  55480. /**
  55481. * Defines the root url to use as a base to load your meshes and associated resources
  55482. */
  55483. rootUrl: string;
  55484. /**
  55485. * Defines the filename of the scene to load from
  55486. */
  55487. sceneFilename: string;
  55488. /**
  55489. * Gets the list of loaded meshes
  55490. */
  55491. loadedMeshes: Array<AbstractMesh>;
  55492. /**
  55493. * Gets the list of loaded particle systems
  55494. */
  55495. loadedParticleSystems: Array<IParticleSystem>;
  55496. /**
  55497. * Gets the list of loaded skeletons
  55498. */
  55499. loadedSkeletons: Array<Skeleton>;
  55500. /**
  55501. * Gets the list of loaded animation groups
  55502. */
  55503. loadedAnimationGroups: Array<AnimationGroup>;
  55504. /**
  55505. * Callback called when the task is successful
  55506. */
  55507. onSuccess: (task: MeshAssetTask) => void;
  55508. /**
  55509. * Callback called when the task is successful
  55510. */
  55511. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55512. /**
  55513. * Creates a new MeshAssetTask
  55514. * @param name defines the name of the task
  55515. * @param meshesNames defines the list of mesh's names you want to load
  55516. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55517. * @param sceneFilename defines the filename of the scene to load from
  55518. */
  55519. constructor(
  55520. /**
  55521. * Defines the name of the task
  55522. */
  55523. name: string,
  55524. /**
  55525. * Defines the list of mesh's names you want to load
  55526. */
  55527. meshesNames: any,
  55528. /**
  55529. * Defines the root url to use as a base to load your meshes and associated resources
  55530. */
  55531. rootUrl: string,
  55532. /**
  55533. * Defines the filename of the scene to load from
  55534. */
  55535. sceneFilename: string);
  55536. /**
  55537. * Execute the current task
  55538. * @param scene defines the scene where you want your assets to be loaded
  55539. * @param onSuccess is a callback called when the task is successfully executed
  55540. * @param onError is a callback called if an error occurs
  55541. */
  55542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55543. }
  55544. /**
  55545. * Define a task used by AssetsManager to load text content
  55546. */
  55547. export class TextFileAssetTask extends AbstractAssetTask {
  55548. /**
  55549. * Defines the name of the task
  55550. */
  55551. name: string;
  55552. /**
  55553. * Defines the location of the file to load
  55554. */
  55555. url: string;
  55556. /**
  55557. * Gets the loaded text string
  55558. */
  55559. text: string;
  55560. /**
  55561. * Callback called when the task is successful
  55562. */
  55563. onSuccess: (task: TextFileAssetTask) => void;
  55564. /**
  55565. * Callback called when the task is successful
  55566. */
  55567. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55568. /**
  55569. * Creates a new TextFileAssetTask object
  55570. * @param name defines the name of the task
  55571. * @param url defines the location of the file to load
  55572. */
  55573. constructor(
  55574. /**
  55575. * Defines the name of the task
  55576. */
  55577. name: string,
  55578. /**
  55579. * Defines the location of the file to load
  55580. */
  55581. url: string);
  55582. /**
  55583. * Execute the current task
  55584. * @param scene defines the scene where you want your assets to be loaded
  55585. * @param onSuccess is a callback called when the task is successfully executed
  55586. * @param onError is a callback called if an error occurs
  55587. */
  55588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55589. }
  55590. /**
  55591. * Define a task used by AssetsManager to load binary data
  55592. */
  55593. export class BinaryFileAssetTask extends AbstractAssetTask {
  55594. /**
  55595. * Defines the name of the task
  55596. */
  55597. name: string;
  55598. /**
  55599. * Defines the location of the file to load
  55600. */
  55601. url: string;
  55602. /**
  55603. * Gets the lodaded data (as an array buffer)
  55604. */
  55605. data: ArrayBuffer;
  55606. /**
  55607. * Callback called when the task is successful
  55608. */
  55609. onSuccess: (task: BinaryFileAssetTask) => void;
  55610. /**
  55611. * Callback called when the task is successful
  55612. */
  55613. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55614. /**
  55615. * Creates a new BinaryFileAssetTask object
  55616. * @param name defines the name of the new task
  55617. * @param url defines the location of the file to load
  55618. */
  55619. constructor(
  55620. /**
  55621. * Defines the name of the task
  55622. */
  55623. name: string,
  55624. /**
  55625. * Defines the location of the file to load
  55626. */
  55627. url: string);
  55628. /**
  55629. * Execute the current task
  55630. * @param scene defines the scene where you want your assets to be loaded
  55631. * @param onSuccess is a callback called when the task is successfully executed
  55632. * @param onError is a callback called if an error occurs
  55633. */
  55634. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55635. }
  55636. /**
  55637. * Define a task used by AssetsManager to load images
  55638. */
  55639. export class ImageAssetTask extends AbstractAssetTask {
  55640. /**
  55641. * Defines the name of the task
  55642. */
  55643. name: string;
  55644. /**
  55645. * Defines the location of the image to load
  55646. */
  55647. url: string;
  55648. /**
  55649. * Gets the loaded images
  55650. */
  55651. image: HTMLImageElement;
  55652. /**
  55653. * Callback called when the task is successful
  55654. */
  55655. onSuccess: (task: ImageAssetTask) => void;
  55656. /**
  55657. * Callback called when the task is successful
  55658. */
  55659. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55660. /**
  55661. * Creates a new ImageAssetTask
  55662. * @param name defines the name of the task
  55663. * @param url defines the location of the image to load
  55664. */
  55665. constructor(
  55666. /**
  55667. * Defines the name of the task
  55668. */
  55669. name: string,
  55670. /**
  55671. * Defines the location of the image to load
  55672. */
  55673. url: string);
  55674. /**
  55675. * Execute the current task
  55676. * @param scene defines the scene where you want your assets to be loaded
  55677. * @param onSuccess is a callback called when the task is successfully executed
  55678. * @param onError is a callback called if an error occurs
  55679. */
  55680. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55681. }
  55682. /**
  55683. * Defines the interface used by texture loading tasks
  55684. */
  55685. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55686. /**
  55687. * Gets the loaded texture
  55688. */
  55689. texture: TEX;
  55690. }
  55691. /**
  55692. * Define a task used by AssetsManager to load 2D textures
  55693. */
  55694. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55695. /**
  55696. * Defines the name of the task
  55697. */
  55698. name: string;
  55699. /**
  55700. * Defines the location of the file to load
  55701. */
  55702. url: string;
  55703. /**
  55704. * Defines if mipmap should not be generated (default is false)
  55705. */
  55706. noMipmap?: boolean | undefined;
  55707. /**
  55708. * Defines if texture must be inverted on Y axis (default is false)
  55709. */
  55710. invertY?: boolean | undefined;
  55711. /**
  55712. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55713. */
  55714. samplingMode: number;
  55715. /**
  55716. * Gets the loaded texture
  55717. */
  55718. texture: Texture;
  55719. /**
  55720. * Callback called when the task is successful
  55721. */
  55722. onSuccess: (task: TextureAssetTask) => void;
  55723. /**
  55724. * Callback called when the task is successful
  55725. */
  55726. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55727. /**
  55728. * Creates a new TextureAssetTask object
  55729. * @param name defines the name of the task
  55730. * @param url defines the location of the file to load
  55731. * @param noMipmap defines if mipmap should not be generated (default is false)
  55732. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55733. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55734. */
  55735. constructor(
  55736. /**
  55737. * Defines the name of the task
  55738. */
  55739. name: string,
  55740. /**
  55741. * Defines the location of the file to load
  55742. */
  55743. url: string,
  55744. /**
  55745. * Defines if mipmap should not be generated (default is false)
  55746. */
  55747. noMipmap?: boolean | undefined,
  55748. /**
  55749. * Defines if texture must be inverted on Y axis (default is false)
  55750. */
  55751. invertY?: boolean | undefined,
  55752. /**
  55753. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55754. */
  55755. samplingMode?: number);
  55756. /**
  55757. * Execute the current task
  55758. * @param scene defines the scene where you want your assets to be loaded
  55759. * @param onSuccess is a callback called when the task is successfully executed
  55760. * @param onError is a callback called if an error occurs
  55761. */
  55762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55763. }
  55764. /**
  55765. * Define a task used by AssetsManager to load cube textures
  55766. */
  55767. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55768. /**
  55769. * Defines the name of the task
  55770. */
  55771. name: string;
  55772. /**
  55773. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55774. */
  55775. url: string;
  55776. /**
  55777. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55778. */
  55779. extensions?: string[] | undefined;
  55780. /**
  55781. * Defines if mipmaps should not be generated (default is false)
  55782. */
  55783. noMipmap?: boolean | undefined;
  55784. /**
  55785. * Defines the explicit list of files (undefined by default)
  55786. */
  55787. files?: string[] | undefined;
  55788. /**
  55789. * Gets the loaded texture
  55790. */
  55791. texture: CubeTexture;
  55792. /**
  55793. * Callback called when the task is successful
  55794. */
  55795. onSuccess: (task: CubeTextureAssetTask) => void;
  55796. /**
  55797. * Callback called when the task is successful
  55798. */
  55799. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55800. /**
  55801. * Creates a new CubeTextureAssetTask
  55802. * @param name defines the name of the task
  55803. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55804. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55805. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55806. * @param files defines the explicit list of files (undefined by default)
  55807. */
  55808. constructor(
  55809. /**
  55810. * Defines the name of the task
  55811. */
  55812. name: string,
  55813. /**
  55814. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55815. */
  55816. url: string,
  55817. /**
  55818. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55819. */
  55820. extensions?: string[] | undefined,
  55821. /**
  55822. * Defines if mipmaps should not be generated (default is false)
  55823. */
  55824. noMipmap?: boolean | undefined,
  55825. /**
  55826. * Defines the explicit list of files (undefined by default)
  55827. */
  55828. files?: string[] | undefined);
  55829. /**
  55830. * Execute the current task
  55831. * @param scene defines the scene where you want your assets to be loaded
  55832. * @param onSuccess is a callback called when the task is successfully executed
  55833. * @param onError is a callback called if an error occurs
  55834. */
  55835. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55836. }
  55837. /**
  55838. * Define a task used by AssetsManager to load HDR cube textures
  55839. */
  55840. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55841. /**
  55842. * Defines the name of the task
  55843. */
  55844. name: string;
  55845. /**
  55846. * Defines the location of the file to load
  55847. */
  55848. url: string;
  55849. /**
  55850. * Defines the desired size (the more it increases the longer the generation will be)
  55851. */
  55852. size: number;
  55853. /**
  55854. * Defines if mipmaps should not be generated (default is false)
  55855. */
  55856. noMipmap: boolean;
  55857. /**
  55858. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55859. */
  55860. generateHarmonics: boolean;
  55861. /**
  55862. * 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)
  55863. */
  55864. gammaSpace: boolean;
  55865. /**
  55866. * Internal Use Only
  55867. */
  55868. reserved: boolean;
  55869. /**
  55870. * Gets the loaded texture
  55871. */
  55872. texture: HDRCubeTexture;
  55873. /**
  55874. * Callback called when the task is successful
  55875. */
  55876. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55877. /**
  55878. * Callback called when the task is successful
  55879. */
  55880. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55881. /**
  55882. * Creates a new HDRCubeTextureAssetTask object
  55883. * @param name defines the name of the task
  55884. * @param url defines the location of the file to load
  55885. * @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.
  55886. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55887. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55888. * @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)
  55889. * @param reserved Internal use only
  55890. */
  55891. constructor(
  55892. /**
  55893. * Defines the name of the task
  55894. */
  55895. name: string,
  55896. /**
  55897. * Defines the location of the file to load
  55898. */
  55899. url: string,
  55900. /**
  55901. * Defines the desired size (the more it increases the longer the generation will be)
  55902. */
  55903. size: number,
  55904. /**
  55905. * Defines if mipmaps should not be generated (default is false)
  55906. */
  55907. noMipmap?: boolean,
  55908. /**
  55909. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55910. */
  55911. generateHarmonics?: boolean,
  55912. /**
  55913. * 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)
  55914. */
  55915. gammaSpace?: boolean,
  55916. /**
  55917. * Internal Use Only
  55918. */
  55919. reserved?: boolean);
  55920. /**
  55921. * Execute the current task
  55922. * @param scene defines the scene where you want your assets to be loaded
  55923. * @param onSuccess is a callback called when the task is successfully executed
  55924. * @param onError is a callback called if an error occurs
  55925. */
  55926. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55927. }
  55928. /**
  55929. * This class can be used to easily import assets into a scene
  55930. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55931. */
  55932. export class AssetsManager {
  55933. private _scene;
  55934. private _isLoading;
  55935. protected _tasks: AbstractAssetTask[];
  55936. protected _waitingTasksCount: number;
  55937. protected _totalTasksCount: number;
  55938. /**
  55939. * Callback called when all tasks are processed
  55940. */
  55941. onFinish: (tasks: AbstractAssetTask[]) => void;
  55942. /**
  55943. * Callback called when a task is successful
  55944. */
  55945. onTaskSuccess: (task: AbstractAssetTask) => void;
  55946. /**
  55947. * Callback called when a task had an error
  55948. */
  55949. onTaskError: (task: AbstractAssetTask) => void;
  55950. /**
  55951. * Callback called when a task is done (whatever the result is)
  55952. */
  55953. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55954. /**
  55955. * Observable called when all tasks are processed
  55956. */
  55957. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55958. /**
  55959. * Observable called when a task had an error
  55960. */
  55961. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55962. /**
  55963. * Observable called when a task is successful
  55964. */
  55965. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55966. /**
  55967. * Observable called when a task is done (whatever the result is)
  55968. */
  55969. onProgressObservable: Observable<IAssetsProgressEvent>;
  55970. /**
  55971. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55972. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55973. */
  55974. useDefaultLoadingScreen: boolean;
  55975. /**
  55976. * Creates a new AssetsManager
  55977. * @param scene defines the scene to work on
  55978. */
  55979. constructor(scene: Scene);
  55980. /**
  55981. * Add a MeshAssetTask to the list of active tasks
  55982. * @param taskName defines the name of the new task
  55983. * @param meshesNames defines the name of meshes to load
  55984. * @param rootUrl defines the root url to use to locate files
  55985. * @param sceneFilename defines the filename of the scene file
  55986. * @returns a new MeshAssetTask object
  55987. */
  55988. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55989. /**
  55990. * Add a TextFileAssetTask to the list of active tasks
  55991. * @param taskName defines the name of the new task
  55992. * @param url defines the url of the file to load
  55993. * @returns a new TextFileAssetTask object
  55994. */
  55995. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55996. /**
  55997. * Add a BinaryFileAssetTask to the list of active tasks
  55998. * @param taskName defines the name of the new task
  55999. * @param url defines the url of the file to load
  56000. * @returns a new BinaryFileAssetTask object
  56001. */
  56002. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56003. /**
  56004. * Add a ImageAssetTask to the list of active tasks
  56005. * @param taskName defines the name of the new task
  56006. * @param url defines the url of the file to load
  56007. * @returns a new ImageAssetTask object
  56008. */
  56009. addImageTask(taskName: string, url: string): ImageAssetTask;
  56010. /**
  56011. * Add a TextureAssetTask to the list of active tasks
  56012. * @param taskName defines the name of the new task
  56013. * @param url defines the url of the file to load
  56014. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56015. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56016. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56017. * @returns a new TextureAssetTask object
  56018. */
  56019. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56020. /**
  56021. * Add a CubeTextureAssetTask to the list of active tasks
  56022. * @param taskName defines the name of the new task
  56023. * @param url defines the url of the file to load
  56024. * @param extensions defines the extension to use to load the cube map (can be null)
  56025. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56026. * @param files defines the list of files to load (can be null)
  56027. * @returns a new CubeTextureAssetTask object
  56028. */
  56029. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56030. /**
  56031. *
  56032. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56033. * @param taskName defines the name of the new task
  56034. * @param url defines the url of the file to load
  56035. * @param size defines the size you want for the cubemap (can be null)
  56036. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56037. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56038. * @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)
  56039. * @param reserved Internal use only
  56040. * @returns a new HDRCubeTextureAssetTask object
  56041. */
  56042. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56043. /**
  56044. * Remove a task from the assets manager.
  56045. * @param task the task to remove
  56046. */
  56047. removeTask(task: AbstractAssetTask): void;
  56048. private _decreaseWaitingTasksCount;
  56049. private _runTask;
  56050. /**
  56051. * Reset the AssetsManager and remove all tasks
  56052. * @return the current instance of the AssetsManager
  56053. */
  56054. reset(): AssetsManager;
  56055. /**
  56056. * Start the loading process
  56057. * @return the current instance of the AssetsManager
  56058. */
  56059. load(): AssetsManager;
  56060. }
  56061. }
  56062. declare module "babylonjs/Misc/deferred" {
  56063. /**
  56064. * Wrapper class for promise with external resolve and reject.
  56065. */
  56066. export class Deferred<T> {
  56067. /**
  56068. * The promise associated with this deferred object.
  56069. */
  56070. readonly promise: Promise<T>;
  56071. private _resolve;
  56072. private _reject;
  56073. /**
  56074. * The resolve method of the promise associated with this deferred object.
  56075. */
  56076. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56077. /**
  56078. * The reject method of the promise associated with this deferred object.
  56079. */
  56080. readonly reject: (reason?: any) => void;
  56081. /**
  56082. * Constructor for this deferred object.
  56083. */
  56084. constructor();
  56085. }
  56086. }
  56087. declare module "babylonjs/Misc/filesInput" {
  56088. import { Engine } from "babylonjs/Engines/engine";
  56089. import { Scene } from "babylonjs/scene";
  56090. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56091. /**
  56092. * Class used to help managing file picking and drag'n'drop
  56093. */
  56094. export class FilesInput {
  56095. /**
  56096. * List of files ready to be loaded
  56097. */
  56098. static readonly FilesToLoad: {
  56099. [key: string]: File;
  56100. };
  56101. /**
  56102. * Callback called when a file is processed
  56103. */
  56104. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56105. private _engine;
  56106. private _currentScene;
  56107. private _sceneLoadedCallback;
  56108. private _progressCallback;
  56109. private _additionalRenderLoopLogicCallback;
  56110. private _textureLoadingCallback;
  56111. private _startingProcessingFilesCallback;
  56112. private _onReloadCallback;
  56113. private _errorCallback;
  56114. private _elementToMonitor;
  56115. private _sceneFileToLoad;
  56116. private _filesToLoad;
  56117. /**
  56118. * Creates a new FilesInput
  56119. * @param engine defines the rendering engine
  56120. * @param scene defines the hosting scene
  56121. * @param sceneLoadedCallback callback called when scene is loaded
  56122. * @param progressCallback callback called to track progress
  56123. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56124. * @param textureLoadingCallback callback called when a texture is loading
  56125. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56126. * @param onReloadCallback callback called when a reload is requested
  56127. * @param errorCallback callback call if an error occurs
  56128. */
  56129. 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);
  56130. private _dragEnterHandler;
  56131. private _dragOverHandler;
  56132. private _dropHandler;
  56133. /**
  56134. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56135. * @param elementToMonitor defines the DOM element to track
  56136. */
  56137. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56138. /**
  56139. * Release all associated resources
  56140. */
  56141. dispose(): void;
  56142. private renderFunction;
  56143. private drag;
  56144. private drop;
  56145. private _traverseFolder;
  56146. private _processFiles;
  56147. /**
  56148. * Load files from a drop event
  56149. * @param event defines the drop event to use as source
  56150. */
  56151. loadFiles(event: any): void;
  56152. private _processReload;
  56153. /**
  56154. * Reload the current scene from the loaded files
  56155. */
  56156. reload(): void;
  56157. }
  56158. }
  56159. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56160. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56161. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56162. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56163. }
  56164. declare module "babylonjs/Misc/sceneOptimizer" {
  56165. import { Scene, IDisposable } from "babylonjs/scene";
  56166. import { Observable } from "babylonjs/Misc/observable";
  56167. /**
  56168. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56170. */
  56171. export class SceneOptimization {
  56172. /**
  56173. * Defines the priority of this optimization (0 by default which means first in the list)
  56174. */
  56175. priority: number;
  56176. /**
  56177. * Gets a string describing the action executed by the current optimization
  56178. * @returns description string
  56179. */
  56180. getDescription(): string;
  56181. /**
  56182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56183. * @param scene defines the current scene where to apply this optimization
  56184. * @param optimizer defines the current optimizer
  56185. * @returns true if everything that can be done was applied
  56186. */
  56187. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56188. /**
  56189. * Creates the SceneOptimization object
  56190. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56191. * @param desc defines the description associated with the optimization
  56192. */
  56193. constructor(
  56194. /**
  56195. * Defines the priority of this optimization (0 by default which means first in the list)
  56196. */
  56197. priority?: number);
  56198. }
  56199. /**
  56200. * Defines an optimization used to reduce the size of render target textures
  56201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56202. */
  56203. export class TextureOptimization extends SceneOptimization {
  56204. /**
  56205. * Defines the priority of this optimization (0 by default which means first in the list)
  56206. */
  56207. priority: number;
  56208. /**
  56209. * 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
  56210. */
  56211. maximumSize: number;
  56212. /**
  56213. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56214. */
  56215. step: number;
  56216. /**
  56217. * Gets a string describing the action executed by the current optimization
  56218. * @returns description string
  56219. */
  56220. getDescription(): string;
  56221. /**
  56222. * Creates the TextureOptimization object
  56223. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56224. * @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
  56225. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56226. */
  56227. constructor(
  56228. /**
  56229. * Defines the priority of this optimization (0 by default which means first in the list)
  56230. */
  56231. priority?: number,
  56232. /**
  56233. * 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
  56234. */
  56235. maximumSize?: number,
  56236. /**
  56237. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56238. */
  56239. step?: number);
  56240. /**
  56241. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56242. * @param scene defines the current scene where to apply this optimization
  56243. * @param optimizer defines the current optimizer
  56244. * @returns true if everything that can be done was applied
  56245. */
  56246. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56247. }
  56248. /**
  56249. * Defines an optimization used to increase or decrease the rendering resolution
  56250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56251. */
  56252. export class HardwareScalingOptimization extends SceneOptimization {
  56253. /**
  56254. * Defines the priority of this optimization (0 by default which means first in the list)
  56255. */
  56256. priority: number;
  56257. /**
  56258. * Defines the maximum scale to use (2 by default)
  56259. */
  56260. maximumScale: number;
  56261. /**
  56262. * Defines the step to use between two passes (0.5 by default)
  56263. */
  56264. step: number;
  56265. private _currentScale;
  56266. private _directionOffset;
  56267. /**
  56268. * Gets a string describing the action executed by the current optimization
  56269. * @return description string
  56270. */
  56271. getDescription(): string;
  56272. /**
  56273. * Creates the HardwareScalingOptimization object
  56274. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56275. * @param maximumScale defines the maximum scale to use (2 by default)
  56276. * @param step defines the step to use between two passes (0.5 by default)
  56277. */
  56278. constructor(
  56279. /**
  56280. * Defines the priority of this optimization (0 by default which means first in the list)
  56281. */
  56282. priority?: number,
  56283. /**
  56284. * Defines the maximum scale to use (2 by default)
  56285. */
  56286. maximumScale?: number,
  56287. /**
  56288. * Defines the step to use between two passes (0.5 by default)
  56289. */
  56290. step?: number);
  56291. /**
  56292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56293. * @param scene defines the current scene where to apply this optimization
  56294. * @param optimizer defines the current optimizer
  56295. * @returns true if everything that can be done was applied
  56296. */
  56297. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56298. }
  56299. /**
  56300. * Defines an optimization used to remove shadows
  56301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56302. */
  56303. export class ShadowsOptimization extends SceneOptimization {
  56304. /**
  56305. * Gets a string describing the action executed by the current optimization
  56306. * @return description string
  56307. */
  56308. getDescription(): string;
  56309. /**
  56310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56311. * @param scene defines the current scene where to apply this optimization
  56312. * @param optimizer defines the current optimizer
  56313. * @returns true if everything that can be done was applied
  56314. */
  56315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56316. }
  56317. /**
  56318. * Defines an optimization used to turn post-processes off
  56319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56320. */
  56321. export class PostProcessesOptimization extends SceneOptimization {
  56322. /**
  56323. * Gets a string describing the action executed by the current optimization
  56324. * @return description string
  56325. */
  56326. getDescription(): string;
  56327. /**
  56328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56329. * @param scene defines the current scene where to apply this optimization
  56330. * @param optimizer defines the current optimizer
  56331. * @returns true if everything that can be done was applied
  56332. */
  56333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56334. }
  56335. /**
  56336. * Defines an optimization used to turn lens flares off
  56337. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56338. */
  56339. export class LensFlaresOptimization extends SceneOptimization {
  56340. /**
  56341. * Gets a string describing the action executed by the current optimization
  56342. * @return description string
  56343. */
  56344. getDescription(): string;
  56345. /**
  56346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56347. * @param scene defines the current scene where to apply this optimization
  56348. * @param optimizer defines the current optimizer
  56349. * @returns true if everything that can be done was applied
  56350. */
  56351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56352. }
  56353. /**
  56354. * Defines an optimization based on user defined callback.
  56355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56356. */
  56357. export class CustomOptimization extends SceneOptimization {
  56358. /**
  56359. * Callback called to apply the custom optimization.
  56360. */
  56361. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56362. /**
  56363. * Callback called to get custom description
  56364. */
  56365. onGetDescription: () => string;
  56366. /**
  56367. * Gets a string describing the action executed by the current optimization
  56368. * @returns description string
  56369. */
  56370. getDescription(): string;
  56371. /**
  56372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56373. * @param scene defines the current scene where to apply this optimization
  56374. * @param optimizer defines the current optimizer
  56375. * @returns true if everything that can be done was applied
  56376. */
  56377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56378. }
  56379. /**
  56380. * Defines an optimization used to turn particles off
  56381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56382. */
  56383. export class ParticlesOptimization extends SceneOptimization {
  56384. /**
  56385. * Gets a string describing the action executed by the current optimization
  56386. * @return description string
  56387. */
  56388. getDescription(): string;
  56389. /**
  56390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56391. * @param scene defines the current scene where to apply this optimization
  56392. * @param optimizer defines the current optimizer
  56393. * @returns true if everything that can be done was applied
  56394. */
  56395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56396. }
  56397. /**
  56398. * Defines an optimization used to turn render targets off
  56399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56400. */
  56401. export class RenderTargetsOptimization extends SceneOptimization {
  56402. /**
  56403. * Gets a string describing the action executed by the current optimization
  56404. * @return description string
  56405. */
  56406. getDescription(): string;
  56407. /**
  56408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56409. * @param scene defines the current scene where to apply this optimization
  56410. * @param optimizer defines the current optimizer
  56411. * @returns true if everything that can be done was applied
  56412. */
  56413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56414. }
  56415. /**
  56416. * Defines an optimization used to merge meshes with compatible materials
  56417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56418. */
  56419. export class MergeMeshesOptimization extends SceneOptimization {
  56420. private static _UpdateSelectionTree;
  56421. /**
  56422. * Gets or sets a boolean which defines if optimization octree has to be updated
  56423. */
  56424. /**
  56425. * Gets or sets a boolean which defines if optimization octree has to be updated
  56426. */
  56427. static UpdateSelectionTree: boolean;
  56428. /**
  56429. * Gets a string describing the action executed by the current optimization
  56430. * @return description string
  56431. */
  56432. getDescription(): string;
  56433. private _canBeMerged;
  56434. /**
  56435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56436. * @param scene defines the current scene where to apply this optimization
  56437. * @param optimizer defines the current optimizer
  56438. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56439. * @returns true if everything that can be done was applied
  56440. */
  56441. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56442. }
  56443. /**
  56444. * Defines a list of options used by SceneOptimizer
  56445. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56446. */
  56447. export class SceneOptimizerOptions {
  56448. /**
  56449. * Defines the target frame rate to reach (60 by default)
  56450. */
  56451. targetFrameRate: number;
  56452. /**
  56453. * Defines the interval between two checkes (2000ms by default)
  56454. */
  56455. trackerDuration: number;
  56456. /**
  56457. * Gets the list of optimizations to apply
  56458. */
  56459. optimizations: SceneOptimization[];
  56460. /**
  56461. * Creates a new list of options used by SceneOptimizer
  56462. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56463. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56464. */
  56465. constructor(
  56466. /**
  56467. * Defines the target frame rate to reach (60 by default)
  56468. */
  56469. targetFrameRate?: number,
  56470. /**
  56471. * Defines the interval between two checkes (2000ms by default)
  56472. */
  56473. trackerDuration?: number);
  56474. /**
  56475. * Add a new optimization
  56476. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56477. * @returns the current SceneOptimizerOptions
  56478. */
  56479. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56480. /**
  56481. * Add a new custom optimization
  56482. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56483. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56484. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56485. * @returns the current SceneOptimizerOptions
  56486. */
  56487. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56488. /**
  56489. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56490. * @param targetFrameRate defines the target frame rate (60 by default)
  56491. * @returns a SceneOptimizerOptions object
  56492. */
  56493. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56494. /**
  56495. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56496. * @param targetFrameRate defines the target frame rate (60 by default)
  56497. * @returns a SceneOptimizerOptions object
  56498. */
  56499. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56500. /**
  56501. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56502. * @param targetFrameRate defines the target frame rate (60 by default)
  56503. * @returns a SceneOptimizerOptions object
  56504. */
  56505. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56506. }
  56507. /**
  56508. * Class used to run optimizations in order to reach a target frame rate
  56509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56510. */
  56511. export class SceneOptimizer implements IDisposable {
  56512. private _isRunning;
  56513. private _options;
  56514. private _scene;
  56515. private _currentPriorityLevel;
  56516. private _targetFrameRate;
  56517. private _trackerDuration;
  56518. private _currentFrameRate;
  56519. private _sceneDisposeObserver;
  56520. private _improvementMode;
  56521. /**
  56522. * Defines an observable called when the optimizer reaches the target frame rate
  56523. */
  56524. onSuccessObservable: Observable<SceneOptimizer>;
  56525. /**
  56526. * Defines an observable called when the optimizer enables an optimization
  56527. */
  56528. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56529. /**
  56530. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56531. */
  56532. onFailureObservable: Observable<SceneOptimizer>;
  56533. /**
  56534. * Gets a boolean indicating if the optimizer is in improvement mode
  56535. */
  56536. readonly isInImprovementMode: boolean;
  56537. /**
  56538. * Gets the current priority level (0 at start)
  56539. */
  56540. readonly currentPriorityLevel: number;
  56541. /**
  56542. * Gets the current frame rate checked by the SceneOptimizer
  56543. */
  56544. readonly currentFrameRate: number;
  56545. /**
  56546. * Gets or sets the current target frame rate (60 by default)
  56547. */
  56548. /**
  56549. * Gets or sets the current target frame rate (60 by default)
  56550. */
  56551. targetFrameRate: number;
  56552. /**
  56553. * Gets or sets the current interval between two checks (every 2000ms by default)
  56554. */
  56555. /**
  56556. * Gets or sets the current interval between two checks (every 2000ms by default)
  56557. */
  56558. trackerDuration: number;
  56559. /**
  56560. * Gets the list of active optimizations
  56561. */
  56562. readonly optimizations: SceneOptimization[];
  56563. /**
  56564. * Creates a new SceneOptimizer
  56565. * @param scene defines the scene to work on
  56566. * @param options defines the options to use with the SceneOptimizer
  56567. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56568. * @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)
  56569. */
  56570. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56571. /**
  56572. * Stops the current optimizer
  56573. */
  56574. stop(): void;
  56575. /**
  56576. * Reset the optimizer to initial step (current priority level = 0)
  56577. */
  56578. reset(): void;
  56579. /**
  56580. * Start the optimizer. By default it will try to reach a specific framerate
  56581. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56582. */
  56583. start(): void;
  56584. private _checkCurrentState;
  56585. /**
  56586. * Release all resources
  56587. */
  56588. dispose(): void;
  56589. /**
  56590. * Helper function to create a SceneOptimizer with one single line of code
  56591. * @param scene defines the scene to work on
  56592. * @param options defines the options to use with the SceneOptimizer
  56593. * @param onSuccess defines a callback to call on success
  56594. * @param onFailure defines a callback to call on failure
  56595. * @returns the new SceneOptimizer object
  56596. */
  56597. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56598. }
  56599. }
  56600. declare module "babylonjs/Misc/sceneSerializer" {
  56601. import { Scene } from "babylonjs/scene";
  56602. /**
  56603. * Class used to serialize a scene into a string
  56604. */
  56605. export class SceneSerializer {
  56606. /**
  56607. * Clear cache used by a previous serialization
  56608. */
  56609. static ClearCache(): void;
  56610. /**
  56611. * Serialize a scene into a JSON compatible object
  56612. * @param scene defines the scene to serialize
  56613. * @returns a JSON compatible object
  56614. */
  56615. static Serialize(scene: Scene): any;
  56616. /**
  56617. * Serialize a mesh into a JSON compatible object
  56618. * @param toSerialize defines the mesh to serialize
  56619. * @param withParents defines if parents must be serialized as well
  56620. * @param withChildren defines if children must be serialized as well
  56621. * @returns a JSON compatible object
  56622. */
  56623. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56624. }
  56625. }
  56626. declare module "babylonjs/Misc/videoRecorder" {
  56627. import { Nullable } from "babylonjs/types";
  56628. import { Engine } from "babylonjs/Engines/engine";
  56629. /**
  56630. * This represents the different options avilable for the video capture.
  56631. */
  56632. export interface VideoRecorderOptions {
  56633. /** Defines the mime type of the video */
  56634. mimeType: string;
  56635. /** Defines the video the video should be recorded at */
  56636. fps: number;
  56637. /** Defines the chunk size for the recording data */
  56638. recordChunckSize: number;
  56639. /** The audio tracks to attach to the record */
  56640. audioTracks?: MediaStreamTrack[];
  56641. }
  56642. /**
  56643. * This can helps recording videos from BabylonJS.
  56644. * This is based on the available WebRTC functionalities of the browser.
  56645. *
  56646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56647. */
  56648. export class VideoRecorder {
  56649. private static readonly _defaultOptions;
  56650. /**
  56651. * Returns wehther or not the VideoRecorder is available in your browser.
  56652. * @param engine Defines the Babylon Engine to check the support for
  56653. * @returns true if supported otherwise false
  56654. */
  56655. static IsSupported(engine: Engine): boolean;
  56656. private readonly _options;
  56657. private _canvas;
  56658. private _mediaRecorder;
  56659. private _recordedChunks;
  56660. private _fileName;
  56661. private _resolve;
  56662. private _reject;
  56663. /**
  56664. * True wether a recording is already in progress.
  56665. */
  56666. readonly isRecording: boolean;
  56667. /**
  56668. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56669. * a video file.
  56670. * @param engine Defines the BabylonJS Engine you wish to record
  56671. * @param options Defines options that can be used to customized the capture
  56672. */
  56673. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56674. /**
  56675. * Stops the current recording before the default capture timeout passed in the startRecording
  56676. * functions.
  56677. */
  56678. stopRecording(): void;
  56679. /**
  56680. * Starts recording the canvas for a max duration specified in parameters.
  56681. * @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.
  56682. * @param maxDuration Defines the maximum recording time in seconds.
  56683. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56684. * @return a promise callback at the end of the recording with the video data in Blob.
  56685. */
  56686. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56687. /**
  56688. * Releases internal resources used during the recording.
  56689. */
  56690. dispose(): void;
  56691. private _handleDataAvailable;
  56692. private _handleError;
  56693. private _handleStop;
  56694. }
  56695. }
  56696. declare module "babylonjs/Misc/workerPool" {
  56697. import { IDisposable } from "babylonjs/scene";
  56698. /**
  56699. * Helper class to push actions to a pool of workers.
  56700. */
  56701. export class WorkerPool implements IDisposable {
  56702. private _workerInfos;
  56703. private _pendingActions;
  56704. /**
  56705. * Constructor
  56706. * @param workers Array of workers to use for actions
  56707. */
  56708. constructor(workers: Array<Worker>);
  56709. /**
  56710. * Terminates all workers and clears any pending actions.
  56711. */
  56712. dispose(): void;
  56713. /**
  56714. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56715. * pended until a worker has completed its action.
  56716. * @param action The action to perform. Call onComplete when the action is complete.
  56717. */
  56718. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56719. private _execute;
  56720. }
  56721. }
  56722. declare module "babylonjs/Misc/screenshotTools" {
  56723. import { Camera } from "babylonjs/Cameras/camera";
  56724. import { Engine } from "babylonjs/Engines/engine";
  56725. /**
  56726. * Class containing a set of static utilities functions for screenshots
  56727. */
  56728. export class ScreenshotTools {
  56729. /**
  56730. * Captures a screenshot of the current rendering
  56731. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56732. * @param engine defines the rendering engine
  56733. * @param camera defines the source camera
  56734. * @param size This parameter can be set to a single number or to an object with the
  56735. * following (optional) properties: precision, width, height. If a single number is passed,
  56736. * it will be used for both width and height. If an object is passed, the screenshot size
  56737. * will be derived from the parameters. The precision property is a multiplier allowing
  56738. * rendering at a higher or lower resolution
  56739. * @param successCallback defines the callback receives a single parameter which contains the
  56740. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56741. * src parameter of an <img> to display it
  56742. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56743. * Check your browser for supported MIME types
  56744. */
  56745. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56746. /**
  56747. * Generates an image screenshot from the specified camera.
  56748. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56749. * @param engine The engine to use for rendering
  56750. * @param camera The camera to use for rendering
  56751. * @param size This parameter can be set to a single number or to an object with the
  56752. * following (optional) properties: precision, width, height. If a single number is passed,
  56753. * it will be used for both width and height. If an object is passed, the screenshot size
  56754. * will be derived from the parameters. The precision property is a multiplier allowing
  56755. * rendering at a higher or lower resolution
  56756. * @param successCallback The callback receives a single parameter which contains the
  56757. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56758. * src parameter of an <img> to display it
  56759. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56760. * Check your browser for supported MIME types
  56761. * @param samples Texture samples (default: 1)
  56762. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56763. * @param fileName A name for for the downloaded file.
  56764. */
  56765. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56766. }
  56767. }
  56768. declare module "babylonjs/Misc/index" {
  56769. export * from "babylonjs/Misc/andOrNotEvaluator";
  56770. export * from "babylonjs/Misc/assetsManager";
  56771. export * from "babylonjs/Misc/dds";
  56772. export * from "babylonjs/Misc/decorators";
  56773. export * from "babylonjs/Misc/deferred";
  56774. export * from "babylonjs/Misc/environmentTextureTools";
  56775. export * from "babylonjs/Misc/filesInput";
  56776. export * from "babylonjs/Misc/HighDynamicRange/index";
  56777. export * from "babylonjs/Misc/khronosTextureContainer";
  56778. export * from "babylonjs/Misc/observable";
  56779. export * from "babylonjs/Misc/performanceMonitor";
  56780. export * from "babylonjs/Misc/promise";
  56781. export * from "babylonjs/Misc/sceneOptimizer";
  56782. export * from "babylonjs/Misc/sceneSerializer";
  56783. export * from "babylonjs/Misc/smartArray";
  56784. export * from "babylonjs/Misc/stringDictionary";
  56785. export * from "babylonjs/Misc/tags";
  56786. export * from "babylonjs/Misc/textureTools";
  56787. export * from "babylonjs/Misc/tga";
  56788. export * from "babylonjs/Misc/tools";
  56789. export * from "babylonjs/Misc/videoRecorder";
  56790. export * from "babylonjs/Misc/virtualJoystick";
  56791. export * from "babylonjs/Misc/workerPool";
  56792. export * from "babylonjs/Misc/logger";
  56793. export * from "babylonjs/Misc/typeStore";
  56794. export * from "babylonjs/Misc/filesInputStore";
  56795. export * from "babylonjs/Misc/deepCopier";
  56796. export * from "babylonjs/Misc/pivotTools";
  56797. export * from "babylonjs/Misc/precisionDate";
  56798. export * from "babylonjs/Misc/screenshotTools";
  56799. export * from "babylonjs/Misc/typeStore";
  56800. }
  56801. declare module "babylonjs/index" {
  56802. export * from "babylonjs/abstractScene";
  56803. export * from "babylonjs/Actions/index";
  56804. export * from "babylonjs/Animations/index";
  56805. export * from "babylonjs/assetContainer";
  56806. export * from "babylonjs/Audio/index";
  56807. export * from "babylonjs/Behaviors/index";
  56808. export * from "babylonjs/Bones/index";
  56809. export * from "babylonjs/Cameras/index";
  56810. export * from "babylonjs/Collisions/index";
  56811. export * from "babylonjs/Culling/index";
  56812. export * from "babylonjs/Debug/index";
  56813. export * from "babylonjs/Engines/index";
  56814. export * from "babylonjs/Events/index";
  56815. export * from "babylonjs/Gamepads/index";
  56816. export * from "babylonjs/Gizmos/index";
  56817. export * from "babylonjs/Helpers/index";
  56818. export * from "babylonjs/Instrumentation/index";
  56819. export * from "babylonjs/Layers/index";
  56820. export * from "babylonjs/LensFlares/index";
  56821. export * from "babylonjs/Lights/index";
  56822. export * from "babylonjs/Loading/index";
  56823. export * from "babylonjs/Materials/index";
  56824. export * from "babylonjs/Maths/index";
  56825. export * from "babylonjs/Meshes/index";
  56826. export * from "babylonjs/Morph/index";
  56827. export * from "babylonjs/node";
  56828. export * from "babylonjs/Offline/index";
  56829. export * from "babylonjs/Particles/index";
  56830. export * from "babylonjs/Physics/index";
  56831. export * from "babylonjs/PostProcesses/index";
  56832. export * from "babylonjs/Probes/index";
  56833. export * from "babylonjs/Rendering/index";
  56834. export * from "babylonjs/scene";
  56835. export * from "babylonjs/sceneComponent";
  56836. export * from "babylonjs/Sprites/index";
  56837. export * from "babylonjs/States/index";
  56838. export * from "babylonjs/Misc/index";
  56839. export * from "babylonjs/types";
  56840. }
  56841. declare module "babylonjs/Animations/pathCursor" {
  56842. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56843. /**
  56844. * A cursor which tracks a point on a path
  56845. */
  56846. export class PathCursor {
  56847. private path;
  56848. /**
  56849. * Stores path cursor callbacks for when an onchange event is triggered
  56850. */
  56851. private _onchange;
  56852. /**
  56853. * The value of the path cursor
  56854. */
  56855. value: number;
  56856. /**
  56857. * The animation array of the path cursor
  56858. */
  56859. animations: Animation[];
  56860. /**
  56861. * Initializes the path cursor
  56862. * @param path The path to track
  56863. */
  56864. constructor(path: Path2);
  56865. /**
  56866. * Gets the cursor point on the path
  56867. * @returns A point on the path cursor at the cursor location
  56868. */
  56869. getPoint(): Vector3;
  56870. /**
  56871. * Moves the cursor ahead by the step amount
  56872. * @param step The amount to move the cursor forward
  56873. * @returns This path cursor
  56874. */
  56875. moveAhead(step?: number): PathCursor;
  56876. /**
  56877. * Moves the cursor behind by the step amount
  56878. * @param step The amount to move the cursor back
  56879. * @returns This path cursor
  56880. */
  56881. moveBack(step?: number): PathCursor;
  56882. /**
  56883. * Moves the cursor by the step amount
  56884. * If the step amount is greater than one, an exception is thrown
  56885. * @param step The amount to move the cursor
  56886. * @returns This path cursor
  56887. */
  56888. move(step: number): PathCursor;
  56889. /**
  56890. * Ensures that the value is limited between zero and one
  56891. * @returns This path cursor
  56892. */
  56893. private ensureLimits;
  56894. /**
  56895. * Runs onchange callbacks on change (used by the animation engine)
  56896. * @returns This path cursor
  56897. */
  56898. private raiseOnChange;
  56899. /**
  56900. * Executes a function on change
  56901. * @param f A path cursor onchange callback
  56902. * @returns This path cursor
  56903. */
  56904. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56905. }
  56906. }
  56907. declare module "babylonjs/Legacy/legacy" {
  56908. import * as Babylon from "babylonjs/index";
  56909. export * from "babylonjs/index";
  56910. }
  56911. declare module "babylonjs/Shaders/blur.fragment" {
  56912. /** @hidden */
  56913. export var blurPixelShader: {
  56914. name: string;
  56915. shader: string;
  56916. };
  56917. }
  56918. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56919. /** @hidden */
  56920. export var bones300Declaration: {
  56921. name: string;
  56922. shader: string;
  56923. };
  56924. }
  56925. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56926. /** @hidden */
  56927. export var instances300Declaration: {
  56928. name: string;
  56929. shader: string;
  56930. };
  56931. }
  56932. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56933. /** @hidden */
  56934. export var pointCloudVertexDeclaration: {
  56935. name: string;
  56936. shader: string;
  56937. };
  56938. }
  56939. // Mixins
  56940. interface Window {
  56941. mozIndexedDB: IDBFactory;
  56942. webkitIndexedDB: IDBFactory;
  56943. msIndexedDB: IDBFactory;
  56944. webkitURL: typeof URL;
  56945. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56946. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56947. WebGLRenderingContext: WebGLRenderingContext;
  56948. MSGesture: MSGesture;
  56949. CANNON: any;
  56950. AudioContext: AudioContext;
  56951. webkitAudioContext: AudioContext;
  56952. PointerEvent: any;
  56953. Math: Math;
  56954. Uint8Array: Uint8ArrayConstructor;
  56955. Float32Array: Float32ArrayConstructor;
  56956. mozURL: typeof URL;
  56957. msURL: typeof URL;
  56958. VRFrameData: any; // WebVR, from specs 1.1
  56959. DracoDecoderModule: any;
  56960. setImmediate(handler: (...args: any[]) => void): number;
  56961. }
  56962. interface HTMLCanvasElement {
  56963. requestPointerLock(): void;
  56964. msRequestPointerLock?(): void;
  56965. mozRequestPointerLock?(): void;
  56966. webkitRequestPointerLock?(): void;
  56967. /** Track wether a record is in progress */
  56968. isRecording: boolean;
  56969. /** Capture Stream method defined by some browsers */
  56970. captureStream(fps?: number): MediaStream;
  56971. }
  56972. interface CanvasRenderingContext2D {
  56973. msImageSmoothingEnabled: boolean;
  56974. }
  56975. interface MouseEvent {
  56976. mozMovementX: number;
  56977. mozMovementY: number;
  56978. webkitMovementX: number;
  56979. webkitMovementY: number;
  56980. msMovementX: number;
  56981. msMovementY: number;
  56982. }
  56983. interface Navigator {
  56984. mozGetVRDevices: (any: any) => any;
  56985. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56986. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56987. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56988. webkitGetGamepads(): Gamepad[];
  56989. msGetGamepads(): Gamepad[];
  56990. webkitGamepads(): Gamepad[];
  56991. }
  56992. interface HTMLVideoElement {
  56993. mozSrcObject: any;
  56994. }
  56995. interface Math {
  56996. fround(x: number): number;
  56997. imul(a: number, b: number): number;
  56998. }
  56999. interface WebGLProgram {
  57000. context?: WebGLRenderingContext;
  57001. vertexShader?: WebGLShader;
  57002. fragmentShader?: WebGLShader;
  57003. isParallelCompiled: boolean;
  57004. onCompiled?: () => void;
  57005. }
  57006. interface WebGLRenderingContext {
  57007. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57008. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57009. vertexAttribDivisor(index: number, divisor: number): void;
  57010. createVertexArray(): any;
  57011. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57012. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57013. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57014. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57015. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57016. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57017. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57018. // Queries
  57019. createQuery(): WebGLQuery;
  57020. deleteQuery(query: WebGLQuery): void;
  57021. beginQuery(target: number, query: WebGLQuery): void;
  57022. endQuery(target: number): void;
  57023. getQueryParameter(query: WebGLQuery, pname: number): any;
  57024. getQuery(target: number, pname: number): any;
  57025. MAX_SAMPLES: number;
  57026. RGBA8: number;
  57027. READ_FRAMEBUFFER: number;
  57028. DRAW_FRAMEBUFFER: number;
  57029. UNIFORM_BUFFER: number;
  57030. HALF_FLOAT_OES: number;
  57031. RGBA16F: number;
  57032. RGBA32F: number;
  57033. R32F: number;
  57034. RG32F: number;
  57035. RGB32F: number;
  57036. R16F: number;
  57037. RG16F: number;
  57038. RGB16F: number;
  57039. RED: number;
  57040. RG: number;
  57041. R8: number;
  57042. RG8: number;
  57043. UNSIGNED_INT_24_8: number;
  57044. DEPTH24_STENCIL8: number;
  57045. /* Multiple Render Targets */
  57046. drawBuffers(buffers: number[]): void;
  57047. readBuffer(src: number): void;
  57048. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57049. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57050. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57051. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57052. // Occlusion Query
  57053. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57054. ANY_SAMPLES_PASSED: number;
  57055. QUERY_RESULT_AVAILABLE: number;
  57056. QUERY_RESULT: number;
  57057. }
  57058. interface WebGLBuffer {
  57059. references: number;
  57060. capacity: number;
  57061. is32Bits: boolean;
  57062. }
  57063. interface WebGLProgram {
  57064. transformFeedback?: WebGLTransformFeedback | null;
  57065. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57066. }
  57067. interface EXT_disjoint_timer_query {
  57068. QUERY_COUNTER_BITS_EXT: number;
  57069. TIME_ELAPSED_EXT: number;
  57070. TIMESTAMP_EXT: number;
  57071. GPU_DISJOINT_EXT: number;
  57072. QUERY_RESULT_EXT: number;
  57073. QUERY_RESULT_AVAILABLE_EXT: number;
  57074. queryCounterEXT(query: WebGLQuery, target: number): void;
  57075. createQueryEXT(): WebGLQuery;
  57076. beginQueryEXT(target: number, query: WebGLQuery): void;
  57077. endQueryEXT(target: number): void;
  57078. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57079. deleteQueryEXT(query: WebGLQuery): void;
  57080. }
  57081. interface WebGLUniformLocation {
  57082. _currentState: any;
  57083. }
  57084. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57085. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57086. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57087. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57088. interface WebGLRenderingContext {
  57089. readonly RASTERIZER_DISCARD: number;
  57090. readonly DEPTH_COMPONENT24: number;
  57091. readonly TEXTURE_3D: number;
  57092. readonly TEXTURE_2D_ARRAY: number;
  57093. readonly TEXTURE_COMPARE_FUNC: number;
  57094. readonly TEXTURE_COMPARE_MODE: number;
  57095. readonly COMPARE_REF_TO_TEXTURE: number;
  57096. readonly TEXTURE_WRAP_R: number;
  57097. readonly HALF_FLOAT: number;
  57098. readonly RGB8: number;
  57099. readonly RED_INTEGER: number;
  57100. readonly RG_INTEGER: number;
  57101. readonly RGB_INTEGER: number;
  57102. readonly RGBA_INTEGER: number;
  57103. readonly R8_SNORM: number;
  57104. readonly RG8_SNORM: number;
  57105. readonly RGB8_SNORM: number;
  57106. readonly RGBA8_SNORM: number;
  57107. readonly R8I: number;
  57108. readonly RG8I: number;
  57109. readonly RGB8I: number;
  57110. readonly RGBA8I: number;
  57111. readonly R8UI: number;
  57112. readonly RG8UI: number;
  57113. readonly RGB8UI: number;
  57114. readonly RGBA8UI: number;
  57115. readonly R16I: number;
  57116. readonly RG16I: number;
  57117. readonly RGB16I: number;
  57118. readonly RGBA16I: number;
  57119. readonly R16UI: number;
  57120. readonly RG16UI: number;
  57121. readonly RGB16UI: number;
  57122. readonly RGBA16UI: number;
  57123. readonly R32I: number;
  57124. readonly RG32I: number;
  57125. readonly RGB32I: number;
  57126. readonly RGBA32I: number;
  57127. readonly R32UI: number;
  57128. readonly RG32UI: number;
  57129. readonly RGB32UI: number;
  57130. readonly RGBA32UI: number;
  57131. readonly RGB10_A2UI: number;
  57132. readonly R11F_G11F_B10F: number;
  57133. readonly RGB9_E5: number;
  57134. readonly RGB10_A2: number;
  57135. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57136. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57137. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57138. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57139. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57140. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57141. 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;
  57142. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57143. readonly TRANSFORM_FEEDBACK: number;
  57144. readonly INTERLEAVED_ATTRIBS: number;
  57145. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57146. createTransformFeedback(): WebGLTransformFeedback;
  57147. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57148. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57149. beginTransformFeedback(primitiveMode: number): void;
  57150. endTransformFeedback(): void;
  57151. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57152. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57153. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57154. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57155. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57156. }
  57157. interface ImageBitmap {
  57158. readonly width: number;
  57159. readonly height: number;
  57160. close(): void;
  57161. }
  57162. interface WebGLQuery extends WebGLObject {
  57163. }
  57164. declare var WebGLQuery: {
  57165. prototype: WebGLQuery;
  57166. new(): WebGLQuery;
  57167. };
  57168. interface WebGLSampler extends WebGLObject {
  57169. }
  57170. declare var WebGLSampler: {
  57171. prototype: WebGLSampler;
  57172. new(): WebGLSampler;
  57173. };
  57174. interface WebGLSync extends WebGLObject {
  57175. }
  57176. declare var WebGLSync: {
  57177. prototype: WebGLSync;
  57178. new(): WebGLSync;
  57179. };
  57180. interface WebGLTransformFeedback extends WebGLObject {
  57181. }
  57182. declare var WebGLTransformFeedback: {
  57183. prototype: WebGLTransformFeedback;
  57184. new(): WebGLTransformFeedback;
  57185. };
  57186. interface WebGLVertexArrayObject extends WebGLObject {
  57187. }
  57188. declare var WebGLVertexArrayObject: {
  57189. prototype: WebGLVertexArrayObject;
  57190. new(): WebGLVertexArrayObject;
  57191. };
  57192. // Type definitions for WebVR API
  57193. // Project: https://w3c.github.io/webvr/
  57194. // Definitions by: six a <https://github.com/lostfictions>
  57195. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57196. interface VRDisplay extends EventTarget {
  57197. /**
  57198. * Dictionary of capabilities describing the VRDisplay.
  57199. */
  57200. readonly capabilities: VRDisplayCapabilities;
  57201. /**
  57202. * z-depth defining the far plane of the eye view frustum
  57203. * enables mapping of values in the render target depth
  57204. * attachment to scene coordinates. Initially set to 10000.0.
  57205. */
  57206. depthFar: number;
  57207. /**
  57208. * z-depth defining the near plane of the eye view frustum
  57209. * enables mapping of values in the render target depth
  57210. * attachment to scene coordinates. Initially set to 0.01.
  57211. */
  57212. depthNear: number;
  57213. /**
  57214. * An identifier for this distinct VRDisplay. Used as an
  57215. * association point in the Gamepad API.
  57216. */
  57217. readonly displayId: number;
  57218. /**
  57219. * A display name, a user-readable name identifying it.
  57220. */
  57221. readonly displayName: string;
  57222. readonly isConnected: boolean;
  57223. readonly isPresenting: boolean;
  57224. /**
  57225. * If this VRDisplay supports room-scale experiences, the optional
  57226. * stage attribute contains details on the room-scale parameters.
  57227. */
  57228. readonly stageParameters: VRStageParameters | null;
  57229. /**
  57230. * Passing the value returned by `requestAnimationFrame` to
  57231. * `cancelAnimationFrame` will unregister the callback.
  57232. * @param handle Define the hanle of the request to cancel
  57233. */
  57234. cancelAnimationFrame(handle: number): void;
  57235. /**
  57236. * Stops presenting to the VRDisplay.
  57237. * @returns a promise to know when it stopped
  57238. */
  57239. exitPresent(): Promise<void>;
  57240. /**
  57241. * Return the current VREyeParameters for the given eye.
  57242. * @param whichEye Define the eye we want the parameter for
  57243. * @returns the eye parameters
  57244. */
  57245. getEyeParameters(whichEye: string): VREyeParameters;
  57246. /**
  57247. * Populates the passed VRFrameData with the information required to render
  57248. * the current frame.
  57249. * @param frameData Define the data structure to populate
  57250. * @returns true if ok otherwise false
  57251. */
  57252. getFrameData(frameData: VRFrameData): boolean;
  57253. /**
  57254. * Get the layers currently being presented.
  57255. * @returns the list of VR layers
  57256. */
  57257. getLayers(): VRLayer[];
  57258. /**
  57259. * Return a VRPose containing the future predicted pose of the VRDisplay
  57260. * when the current frame will be presented. The value returned will not
  57261. * change until JavaScript has returned control to the browser.
  57262. *
  57263. * The VRPose will contain the position, orientation, velocity,
  57264. * and acceleration of each of these properties.
  57265. * @returns the pose object
  57266. */
  57267. getPose(): VRPose;
  57268. /**
  57269. * Return the current instantaneous pose of the VRDisplay, with no
  57270. * prediction applied.
  57271. * @returns the current instantaneous pose
  57272. */
  57273. getImmediatePose(): VRPose;
  57274. /**
  57275. * The callback passed to `requestAnimationFrame` will be called
  57276. * any time a new frame should be rendered. When the VRDisplay is
  57277. * presenting the callback will be called at the native refresh
  57278. * rate of the HMD. When not presenting this function acts
  57279. * identically to how window.requestAnimationFrame acts. Content should
  57280. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57281. * asynchronously from other displays and at differing refresh rates.
  57282. * @param callback Define the eaction to run next frame
  57283. * @returns the request handle it
  57284. */
  57285. requestAnimationFrame(callback: FrameRequestCallback): number;
  57286. /**
  57287. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57288. * Repeat calls while already presenting will update the VRLayers being displayed.
  57289. * @param layers Define the list of layer to present
  57290. * @returns a promise to know when the request has been fulfilled
  57291. */
  57292. requestPresent(layers: VRLayer[]): Promise<void>;
  57293. /**
  57294. * Reset the pose for this display, treating its current position and
  57295. * orientation as the "origin/zero" values. VRPose.position,
  57296. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57297. * updated when calling resetPose(). This should be called in only
  57298. * sitting-space experiences.
  57299. */
  57300. resetPose(): void;
  57301. /**
  57302. * The VRLayer provided to the VRDisplay will be captured and presented
  57303. * in the HMD. Calling this function has the same effect on the source
  57304. * canvas as any other operation that uses its source image, and canvases
  57305. * created without preserveDrawingBuffer set to true will be cleared.
  57306. * @param pose Define the pose to submit
  57307. */
  57308. submitFrame(pose?: VRPose): void;
  57309. }
  57310. declare var VRDisplay: {
  57311. prototype: VRDisplay;
  57312. new(): VRDisplay;
  57313. };
  57314. interface VRLayer {
  57315. leftBounds?: number[] | Float32Array | null;
  57316. rightBounds?: number[] | Float32Array | null;
  57317. source?: HTMLCanvasElement | null;
  57318. }
  57319. interface VRDisplayCapabilities {
  57320. readonly canPresent: boolean;
  57321. readonly hasExternalDisplay: boolean;
  57322. readonly hasOrientation: boolean;
  57323. readonly hasPosition: boolean;
  57324. readonly maxLayers: number;
  57325. }
  57326. interface VREyeParameters {
  57327. /** @deprecated */
  57328. readonly fieldOfView: VRFieldOfView;
  57329. readonly offset: Float32Array;
  57330. readonly renderHeight: number;
  57331. readonly renderWidth: number;
  57332. }
  57333. interface VRFieldOfView {
  57334. readonly downDegrees: number;
  57335. readonly leftDegrees: number;
  57336. readonly rightDegrees: number;
  57337. readonly upDegrees: number;
  57338. }
  57339. interface VRFrameData {
  57340. readonly leftProjectionMatrix: Float32Array;
  57341. readonly leftViewMatrix: Float32Array;
  57342. readonly pose: VRPose;
  57343. readonly rightProjectionMatrix: Float32Array;
  57344. readonly rightViewMatrix: Float32Array;
  57345. readonly timestamp: number;
  57346. }
  57347. interface VRPose {
  57348. readonly angularAcceleration: Float32Array | null;
  57349. readonly angularVelocity: Float32Array | null;
  57350. readonly linearAcceleration: Float32Array | null;
  57351. readonly linearVelocity: Float32Array | null;
  57352. readonly orientation: Float32Array | null;
  57353. readonly position: Float32Array | null;
  57354. readonly timestamp: number;
  57355. }
  57356. interface VRStageParameters {
  57357. sittingToStandingTransform?: Float32Array;
  57358. sizeX?: number;
  57359. sizeY?: number;
  57360. }
  57361. interface Navigator {
  57362. getVRDisplays(): Promise<VRDisplay[]>;
  57363. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57364. }
  57365. interface Window {
  57366. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57367. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57368. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57369. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57370. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57371. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57372. }
  57373. interface Gamepad {
  57374. readonly displayId: number;
  57375. }
  57376. interface XRDevice {
  57377. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57378. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57379. }
  57380. interface XRSession {
  57381. getInputSources(): Array<any>;
  57382. baseLayer: XRWebGLLayer;
  57383. requestFrameOfReference(type: string): Promise<void>;
  57384. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57385. end(): Promise<void>;
  57386. requestAnimationFrame: Function;
  57387. addEventListener: Function;
  57388. }
  57389. interface XRSessionCreationOptions {
  57390. outputContext?: WebGLRenderingContext | null;
  57391. immersive?: boolean;
  57392. environmentIntegration?: boolean;
  57393. }
  57394. interface XRLayer {
  57395. getViewport: Function;
  57396. framebufferWidth: number;
  57397. framebufferHeight: number;
  57398. }
  57399. interface XRView {
  57400. projectionMatrix: Float32Array;
  57401. }
  57402. interface XRFrame {
  57403. getDevicePose: Function;
  57404. getInputPose: Function;
  57405. views: Array<XRView>;
  57406. baseLayer: XRLayer;
  57407. }
  57408. interface XRFrameOfReference {
  57409. }
  57410. interface XRWebGLLayer extends XRLayer {
  57411. framebuffer: WebGLFramebuffer;
  57412. }
  57413. declare var XRWebGLLayer: {
  57414. prototype: XRWebGLLayer;
  57415. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57416. };
  57417. declare module "babylonjs" {
  57418. export * from "babylonjs/Legacy/legacy";
  57419. }
  57420. declare module BABYLON {
  57421. /** Alias type for value that can be null */
  57422. export type Nullable<T> = T | null;
  57423. /**
  57424. * Alias type for number that are floats
  57425. * @ignorenaming
  57426. */
  57427. export type float = number;
  57428. /**
  57429. * Alias type for number that are doubles.
  57430. * @ignorenaming
  57431. */
  57432. export type double = number;
  57433. /**
  57434. * Alias type for number that are integer
  57435. * @ignorenaming
  57436. */
  57437. export type int = number;
  57438. /** Alias type for number array or Float32Array */
  57439. export type FloatArray = number[] | Float32Array;
  57440. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57441. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57442. /**
  57443. * Alias for types that can be used by a Buffer or VertexBuffer.
  57444. */
  57445. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57446. /**
  57447. * Alias type for primitive types
  57448. * @ignorenaming
  57449. */
  57450. type Primitive = undefined | null | boolean | string | number | Function;
  57451. /**
  57452. * Type modifier to make all the properties of an object Readonly
  57453. */
  57454. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57455. /**
  57456. * Type modifier to make all the properties of an object Readonly recursively
  57457. */
  57458. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57459. /** @hidden */
  57460. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57461. }
  57462. /** @hidden */
  57463. /** @hidden */
  57464. type DeepImmutableObject<T> = {
  57465. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57466. };
  57467. }
  57468. declare module BABYLON {
  57469. /**
  57470. * Class containing a set of static utilities functions for arrays.
  57471. */
  57472. export class ArrayTools {
  57473. /**
  57474. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57475. * @param size the number of element to construct and put in the array
  57476. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57477. * @returns a new array filled with new objects
  57478. */
  57479. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57480. }
  57481. }
  57482. declare module BABYLON {
  57483. /**
  57484. * Scalar computation library
  57485. */
  57486. export class Scalar {
  57487. /**
  57488. * Two pi constants convenient for computation.
  57489. */
  57490. static TwoPi: number;
  57491. /**
  57492. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57493. * @param a number
  57494. * @param b number
  57495. * @param epsilon (default = 1.401298E-45)
  57496. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57497. */
  57498. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57499. /**
  57500. * Returns a string : the upper case translation of the number i to hexadecimal.
  57501. * @param i number
  57502. * @returns the upper case translation of the number i to hexadecimal.
  57503. */
  57504. static ToHex(i: number): string;
  57505. /**
  57506. * Returns -1 if value is negative and +1 is value is positive.
  57507. * @param value the value
  57508. * @returns the value itself if it's equal to zero.
  57509. */
  57510. static Sign(value: number): number;
  57511. /**
  57512. * Returns the value itself if it's between min and max.
  57513. * Returns min if the value is lower than min.
  57514. * Returns max if the value is greater than max.
  57515. * @param value the value to clmap
  57516. * @param min the min value to clamp to (default: 0)
  57517. * @param max the max value to clamp to (default: 1)
  57518. * @returns the clamped value
  57519. */
  57520. static Clamp(value: number, min?: number, max?: number): number;
  57521. /**
  57522. * the log2 of value.
  57523. * @param value the value to compute log2 of
  57524. * @returns the log2 of value.
  57525. */
  57526. static Log2(value: number): number;
  57527. /**
  57528. * Loops the value, so that it is never larger than length and never smaller than 0.
  57529. *
  57530. * This is similar to the modulo operator but it works with floating point numbers.
  57531. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57532. * With t = 5 and length = 2.5, the result would be 0.0.
  57533. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57534. * @param value the value
  57535. * @param length the length
  57536. * @returns the looped value
  57537. */
  57538. static Repeat(value: number, length: number): number;
  57539. /**
  57540. * Normalize the value between 0.0 and 1.0 using min and max values
  57541. * @param value value to normalize
  57542. * @param min max to normalize between
  57543. * @param max min to normalize between
  57544. * @returns the normalized value
  57545. */
  57546. static Normalize(value: number, min: number, max: number): number;
  57547. /**
  57548. * Denormalize the value from 0.0 and 1.0 using min and max values
  57549. * @param normalized value to denormalize
  57550. * @param min max to denormalize between
  57551. * @param max min to denormalize between
  57552. * @returns the denormalized value
  57553. */
  57554. static Denormalize(normalized: number, min: number, max: number): number;
  57555. /**
  57556. * Calculates the shortest difference between two given angles given in degrees.
  57557. * @param current current angle in degrees
  57558. * @param target target angle in degrees
  57559. * @returns the delta
  57560. */
  57561. static DeltaAngle(current: number, target: number): number;
  57562. /**
  57563. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57564. * @param tx value
  57565. * @param length length
  57566. * @returns The returned value will move back and forth between 0 and length
  57567. */
  57568. static PingPong(tx: number, length: number): number;
  57569. /**
  57570. * Interpolates between min and max with smoothing at the limits.
  57571. *
  57572. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57573. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57574. * @param from from
  57575. * @param to to
  57576. * @param tx value
  57577. * @returns the smooth stepped value
  57578. */
  57579. static SmoothStep(from: number, to: number, tx: number): number;
  57580. /**
  57581. * Moves a value current towards target.
  57582. *
  57583. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57584. * Negative values of maxDelta pushes the value away from target.
  57585. * @param current current value
  57586. * @param target target value
  57587. * @param maxDelta max distance to move
  57588. * @returns resulting value
  57589. */
  57590. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57591. /**
  57592. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57593. *
  57594. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57595. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57596. * @param current current value
  57597. * @param target target value
  57598. * @param maxDelta max distance to move
  57599. * @returns resulting angle
  57600. */
  57601. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57602. /**
  57603. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57604. * @param start start value
  57605. * @param end target value
  57606. * @param amount amount to lerp between
  57607. * @returns the lerped value
  57608. */
  57609. static Lerp(start: number, end: number, amount: number): number;
  57610. /**
  57611. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57612. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57613. * @param start start value
  57614. * @param end target value
  57615. * @param amount amount to lerp between
  57616. * @returns the lerped value
  57617. */
  57618. static LerpAngle(start: number, end: number, amount: number): number;
  57619. /**
  57620. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57621. * @param a start value
  57622. * @param b target value
  57623. * @param value value between a and b
  57624. * @returns the inverseLerp value
  57625. */
  57626. static InverseLerp(a: number, b: number, value: number): number;
  57627. /**
  57628. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57629. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57630. * @param value1 spline value
  57631. * @param tangent1 spline value
  57632. * @param value2 spline value
  57633. * @param tangent2 spline value
  57634. * @param amount input value
  57635. * @returns hermite result
  57636. */
  57637. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57638. /**
  57639. * Returns a random float number between and min and max values
  57640. * @param min min value of random
  57641. * @param max max value of random
  57642. * @returns random value
  57643. */
  57644. static RandomRange(min: number, max: number): number;
  57645. /**
  57646. * This function returns percentage of a number in a given range.
  57647. *
  57648. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57649. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57650. * @param number to convert to percentage
  57651. * @param min min range
  57652. * @param max max range
  57653. * @returns the percentage
  57654. */
  57655. static RangeToPercent(number: number, min: number, max: number): number;
  57656. /**
  57657. * This function returns number that corresponds to the percentage in a given range.
  57658. *
  57659. * PercentToRange(0.34,0,100) will return 34.
  57660. * @param percent to convert to number
  57661. * @param min min range
  57662. * @param max max range
  57663. * @returns the number
  57664. */
  57665. static PercentToRange(percent: number, min: number, max: number): number;
  57666. /**
  57667. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57668. * @param angle The angle to normalize in radian.
  57669. * @return The converted angle.
  57670. */
  57671. static NormalizeRadians(angle: number): number;
  57672. }
  57673. }
  57674. declare module BABYLON {
  57675. /**
  57676. * Constant used to convert a value to gamma space
  57677. * @ignorenaming
  57678. */
  57679. export const ToGammaSpace: number;
  57680. /**
  57681. * Constant used to convert a value to linear space
  57682. * @ignorenaming
  57683. */
  57684. export const ToLinearSpace = 2.2;
  57685. /**
  57686. * Constant used to define the minimal number value in Babylon.js
  57687. * @ignorenaming
  57688. */
  57689. export const Epsilon = 0.001;
  57690. /**
  57691. * Class used to hold a RBG color
  57692. */
  57693. export class Color3 {
  57694. /**
  57695. * Defines the red component (between 0 and 1, default is 0)
  57696. */
  57697. r: number;
  57698. /**
  57699. * Defines the green component (between 0 and 1, default is 0)
  57700. */
  57701. g: number;
  57702. /**
  57703. * Defines the blue component (between 0 and 1, default is 0)
  57704. */
  57705. b: number;
  57706. /**
  57707. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57708. * @param r defines the red component (between 0 and 1, default is 0)
  57709. * @param g defines the green component (between 0 and 1, default is 0)
  57710. * @param b defines the blue component (between 0 and 1, default is 0)
  57711. */
  57712. constructor(
  57713. /**
  57714. * Defines the red component (between 0 and 1, default is 0)
  57715. */
  57716. r?: number,
  57717. /**
  57718. * Defines the green component (between 0 and 1, default is 0)
  57719. */
  57720. g?: number,
  57721. /**
  57722. * Defines the blue component (between 0 and 1, default is 0)
  57723. */
  57724. b?: number);
  57725. /**
  57726. * Creates a string with the Color3 current values
  57727. * @returns the string representation of the Color3 object
  57728. */
  57729. toString(): string;
  57730. /**
  57731. * Returns the string "Color3"
  57732. * @returns "Color3"
  57733. */
  57734. getClassName(): string;
  57735. /**
  57736. * Compute the Color3 hash code
  57737. * @returns an unique number that can be used to hash Color3 objects
  57738. */
  57739. getHashCode(): number;
  57740. /**
  57741. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57742. * @param array defines the array where to store the r,g,b components
  57743. * @param index defines an optional index in the target array to define where to start storing values
  57744. * @returns the current Color3 object
  57745. */
  57746. toArray(array: FloatArray, index?: number): Color3;
  57747. /**
  57748. * Returns a new Color4 object from the current Color3 and the given alpha
  57749. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57750. * @returns a new Color4 object
  57751. */
  57752. toColor4(alpha?: number): Color4;
  57753. /**
  57754. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57755. * @returns the new array
  57756. */
  57757. asArray(): number[];
  57758. /**
  57759. * Returns the luminance value
  57760. * @returns a float value
  57761. */
  57762. toLuminance(): number;
  57763. /**
  57764. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57765. * @param otherColor defines the second operand
  57766. * @returns the new Color3 object
  57767. */
  57768. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57769. /**
  57770. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57771. * @param otherColor defines the second operand
  57772. * @param result defines the Color3 object where to store the result
  57773. * @returns the current Color3
  57774. */
  57775. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57776. /**
  57777. * Determines equality between Color3 objects
  57778. * @param otherColor defines the second operand
  57779. * @returns true if the rgb values are equal to the given ones
  57780. */
  57781. equals(otherColor: DeepImmutable<Color3>): boolean;
  57782. /**
  57783. * Determines equality between the current Color3 object and a set of r,b,g values
  57784. * @param r defines the red component to check
  57785. * @param g defines the green component to check
  57786. * @param b defines the blue component to check
  57787. * @returns true if the rgb values are equal to the given ones
  57788. */
  57789. equalsFloats(r: number, g: number, b: number): boolean;
  57790. /**
  57791. * Multiplies in place each rgb value by scale
  57792. * @param scale defines the scaling factor
  57793. * @returns the updated Color3
  57794. */
  57795. scale(scale: number): Color3;
  57796. /**
  57797. * Multiplies the rgb values by scale and stores the result into "result"
  57798. * @param scale defines the scaling factor
  57799. * @param result defines the Color3 object where to store the result
  57800. * @returns the unmodified current Color3
  57801. */
  57802. scaleToRef(scale: number, result: Color3): Color3;
  57803. /**
  57804. * Scale the current Color3 values by a factor and add the result to a given Color3
  57805. * @param scale defines the scale factor
  57806. * @param result defines color to store the result into
  57807. * @returns the unmodified current Color3
  57808. */
  57809. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57810. /**
  57811. * Clamps the rgb values by the min and max values and stores the result into "result"
  57812. * @param min defines minimum clamping value (default is 0)
  57813. * @param max defines maximum clamping value (default is 1)
  57814. * @param result defines color to store the result into
  57815. * @returns the original Color3
  57816. */
  57817. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57818. /**
  57819. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57820. * @param otherColor defines the second operand
  57821. * @returns the new Color3
  57822. */
  57823. add(otherColor: DeepImmutable<Color3>): Color3;
  57824. /**
  57825. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57826. * @param otherColor defines the second operand
  57827. * @param result defines Color3 object to store the result into
  57828. * @returns the unmodified current Color3
  57829. */
  57830. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57831. /**
  57832. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57833. * @param otherColor defines the second operand
  57834. * @returns the new Color3
  57835. */
  57836. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57837. /**
  57838. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57839. * @param otherColor defines the second operand
  57840. * @param result defines Color3 object to store the result into
  57841. * @returns the unmodified current Color3
  57842. */
  57843. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57844. /**
  57845. * Copy the current object
  57846. * @returns a new Color3 copied the current one
  57847. */
  57848. clone(): Color3;
  57849. /**
  57850. * Copies the rgb values from the source in the current Color3
  57851. * @param source defines the source Color3 object
  57852. * @returns the updated Color3 object
  57853. */
  57854. copyFrom(source: DeepImmutable<Color3>): Color3;
  57855. /**
  57856. * Updates the Color3 rgb values from the given floats
  57857. * @param r defines the red component to read from
  57858. * @param g defines the green component to read from
  57859. * @param b defines the blue component to read from
  57860. * @returns the current Color3 object
  57861. */
  57862. copyFromFloats(r: number, g: number, b: number): Color3;
  57863. /**
  57864. * Updates the Color3 rgb values from the given floats
  57865. * @param r defines the red component to read from
  57866. * @param g defines the green component to read from
  57867. * @param b defines the blue component to read from
  57868. * @returns the current Color3 object
  57869. */
  57870. set(r: number, g: number, b: number): Color3;
  57871. /**
  57872. * Compute the Color3 hexadecimal code as a string
  57873. * @returns a string containing the hexadecimal representation of the Color3 object
  57874. */
  57875. toHexString(): string;
  57876. /**
  57877. * Computes a new Color3 converted from the current one to linear space
  57878. * @returns a new Color3 object
  57879. */
  57880. toLinearSpace(): Color3;
  57881. /**
  57882. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57883. * @param convertedColor defines the Color3 object where to store the linear space version
  57884. * @returns the unmodified Color3
  57885. */
  57886. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57887. /**
  57888. * Computes a new Color3 converted from the current one to gamma space
  57889. * @returns a new Color3 object
  57890. */
  57891. toGammaSpace(): Color3;
  57892. /**
  57893. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57894. * @param convertedColor defines the Color3 object where to store the gamma space version
  57895. * @returns the unmodified Color3
  57896. */
  57897. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57898. private static _BlackReadOnly;
  57899. /**
  57900. * Creates a new Color3 from the string containing valid hexadecimal values
  57901. * @param hex defines a string containing valid hexadecimal values
  57902. * @returns a new Color3 object
  57903. */
  57904. static FromHexString(hex: string): Color3;
  57905. /**
  57906. * Creates a new Vector3 from the starting index of the given array
  57907. * @param array defines the source array
  57908. * @param offset defines an offset in the source array
  57909. * @returns a new Color3 object
  57910. */
  57911. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57912. /**
  57913. * Creates a new Color3 from integer values (< 256)
  57914. * @param r defines the red component to read from (value between 0 and 255)
  57915. * @param g defines the green component to read from (value between 0 and 255)
  57916. * @param b defines the blue component to read from (value between 0 and 255)
  57917. * @returns a new Color3 object
  57918. */
  57919. static FromInts(r: number, g: number, b: number): Color3;
  57920. /**
  57921. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57922. * @param start defines the start Color3 value
  57923. * @param end defines the end Color3 value
  57924. * @param amount defines the gradient value between start and end
  57925. * @returns a new Color3 object
  57926. */
  57927. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57928. /**
  57929. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57930. * @param left defines the start value
  57931. * @param right defines the end value
  57932. * @param amount defines the gradient factor
  57933. * @param result defines the Color3 object where to store the result
  57934. */
  57935. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57936. /**
  57937. * Returns a Color3 value containing a red color
  57938. * @returns a new Color3 object
  57939. */
  57940. static Red(): Color3;
  57941. /**
  57942. * Returns a Color3 value containing a green color
  57943. * @returns a new Color3 object
  57944. */
  57945. static Green(): Color3;
  57946. /**
  57947. * Returns a Color3 value containing a blue color
  57948. * @returns a new Color3 object
  57949. */
  57950. static Blue(): Color3;
  57951. /**
  57952. * Returns a Color3 value containing a black color
  57953. * @returns a new Color3 object
  57954. */
  57955. static Black(): Color3;
  57956. /**
  57957. * Gets a Color3 value containing a black color that must not be updated
  57958. */
  57959. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57960. /**
  57961. * Returns a Color3 value containing a white color
  57962. * @returns a new Color3 object
  57963. */
  57964. static White(): Color3;
  57965. /**
  57966. * Returns a Color3 value containing a purple color
  57967. * @returns a new Color3 object
  57968. */
  57969. static Purple(): Color3;
  57970. /**
  57971. * Returns a Color3 value containing a magenta color
  57972. * @returns a new Color3 object
  57973. */
  57974. static Magenta(): Color3;
  57975. /**
  57976. * Returns a Color3 value containing a yellow color
  57977. * @returns a new Color3 object
  57978. */
  57979. static Yellow(): Color3;
  57980. /**
  57981. * Returns a Color3 value containing a gray color
  57982. * @returns a new Color3 object
  57983. */
  57984. static Gray(): Color3;
  57985. /**
  57986. * Returns a Color3 value containing a teal color
  57987. * @returns a new Color3 object
  57988. */
  57989. static Teal(): Color3;
  57990. /**
  57991. * Returns a Color3 value containing a random color
  57992. * @returns a new Color3 object
  57993. */
  57994. static Random(): Color3;
  57995. }
  57996. /**
  57997. * Class used to hold a RBGA color
  57998. */
  57999. export class Color4 {
  58000. /**
  58001. * Defines the red component (between 0 and 1, default is 0)
  58002. */
  58003. r: number;
  58004. /**
  58005. * Defines the green component (between 0 and 1, default is 0)
  58006. */
  58007. g: number;
  58008. /**
  58009. * Defines the blue component (between 0 and 1, default is 0)
  58010. */
  58011. b: number;
  58012. /**
  58013. * Defines the alpha component (between 0 and 1, default is 1)
  58014. */
  58015. a: number;
  58016. /**
  58017. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58018. * @param r defines the red component (between 0 and 1, default is 0)
  58019. * @param g defines the green component (between 0 and 1, default is 0)
  58020. * @param b defines the blue component (between 0 and 1, default is 0)
  58021. * @param a defines the alpha component (between 0 and 1, default is 1)
  58022. */
  58023. constructor(
  58024. /**
  58025. * Defines the red component (between 0 and 1, default is 0)
  58026. */
  58027. r?: number,
  58028. /**
  58029. * Defines the green component (between 0 and 1, default is 0)
  58030. */
  58031. g?: number,
  58032. /**
  58033. * Defines the blue component (between 0 and 1, default is 0)
  58034. */
  58035. b?: number,
  58036. /**
  58037. * Defines the alpha component (between 0 and 1, default is 1)
  58038. */
  58039. a?: number);
  58040. /**
  58041. * Adds in place the given Color4 values to the current Color4 object
  58042. * @param right defines the second operand
  58043. * @returns the current updated Color4 object
  58044. */
  58045. addInPlace(right: DeepImmutable<Color4>): Color4;
  58046. /**
  58047. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58048. * @returns the new array
  58049. */
  58050. asArray(): number[];
  58051. /**
  58052. * Stores from the starting index in the given array the Color4 successive values
  58053. * @param array defines the array where to store the r,g,b components
  58054. * @param index defines an optional index in the target array to define where to start storing values
  58055. * @returns the current Color4 object
  58056. */
  58057. toArray(array: number[], index?: number): Color4;
  58058. /**
  58059. * Determines equality between Color4 objects
  58060. * @param otherColor defines the second operand
  58061. * @returns true if the rgba values are equal to the given ones
  58062. */
  58063. equals(otherColor: DeepImmutable<Color4>): boolean;
  58064. /**
  58065. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58066. * @param right defines the second operand
  58067. * @returns a new Color4 object
  58068. */
  58069. add(right: DeepImmutable<Color4>): Color4;
  58070. /**
  58071. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58072. * @param right defines the second operand
  58073. * @returns a new Color4 object
  58074. */
  58075. subtract(right: DeepImmutable<Color4>): Color4;
  58076. /**
  58077. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58078. * @param right defines the second operand
  58079. * @param result defines the Color4 object where to store the result
  58080. * @returns the current Color4 object
  58081. */
  58082. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58083. /**
  58084. * Creates a new Color4 with the current Color4 values multiplied by scale
  58085. * @param scale defines the scaling factor to apply
  58086. * @returns a new Color4 object
  58087. */
  58088. scale(scale: number): Color4;
  58089. /**
  58090. * Multiplies the current Color4 values by scale and stores the result in "result"
  58091. * @param scale defines the scaling factor to apply
  58092. * @param result defines the Color4 object where to store the result
  58093. * @returns the current unmodified Color4
  58094. */
  58095. scaleToRef(scale: number, result: Color4): Color4;
  58096. /**
  58097. * Scale the current Color4 values by a factor and add the result to a given Color4
  58098. * @param scale defines the scale factor
  58099. * @param result defines the Color4 object where to store the result
  58100. * @returns the unmodified current Color4
  58101. */
  58102. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58103. /**
  58104. * Clamps the rgb values by the min and max values and stores the result into "result"
  58105. * @param min defines minimum clamping value (default is 0)
  58106. * @param max defines maximum clamping value (default is 1)
  58107. * @param result defines color to store the result into.
  58108. * @returns the cuurent Color4
  58109. */
  58110. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58111. /**
  58112. * Multipy an Color4 value by another and return a new Color4 object
  58113. * @param color defines the Color4 value to multiply by
  58114. * @returns a new Color4 object
  58115. */
  58116. multiply(color: Color4): Color4;
  58117. /**
  58118. * Multipy a Color4 value by another and push the result in a reference value
  58119. * @param color defines the Color4 value to multiply by
  58120. * @param result defines the Color4 to fill the result in
  58121. * @returns the result Color4
  58122. */
  58123. multiplyToRef(color: Color4, result: Color4): Color4;
  58124. /**
  58125. * Creates a string with the Color4 current values
  58126. * @returns the string representation of the Color4 object
  58127. */
  58128. toString(): string;
  58129. /**
  58130. * Returns the string "Color4"
  58131. * @returns "Color4"
  58132. */
  58133. getClassName(): string;
  58134. /**
  58135. * Compute the Color4 hash code
  58136. * @returns an unique number that can be used to hash Color4 objects
  58137. */
  58138. getHashCode(): number;
  58139. /**
  58140. * Creates a new Color4 copied from the current one
  58141. * @returns a new Color4 object
  58142. */
  58143. clone(): Color4;
  58144. /**
  58145. * Copies the given Color4 values into the current one
  58146. * @param source defines the source Color4 object
  58147. * @returns the current updated Color4 object
  58148. */
  58149. copyFrom(source: Color4): Color4;
  58150. /**
  58151. * Copies the given float values into the current one
  58152. * @param r defines the red component to read from
  58153. * @param g defines the green component to read from
  58154. * @param b defines the blue component to read from
  58155. * @param a defines the alpha component to read from
  58156. * @returns the current updated Color4 object
  58157. */
  58158. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58159. /**
  58160. * Copies the given float values into the current one
  58161. * @param r defines the red component to read from
  58162. * @param g defines the green component to read from
  58163. * @param b defines the blue component to read from
  58164. * @param a defines the alpha component to read from
  58165. * @returns the current updated Color4 object
  58166. */
  58167. set(r: number, g: number, b: number, a: number): Color4;
  58168. /**
  58169. * Compute the Color4 hexadecimal code as a string
  58170. * @returns a string containing the hexadecimal representation of the Color4 object
  58171. */
  58172. toHexString(): string;
  58173. /**
  58174. * Computes a new Color4 converted from the current one to linear space
  58175. * @returns a new Color4 object
  58176. */
  58177. toLinearSpace(): Color4;
  58178. /**
  58179. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58180. * @param convertedColor defines the Color4 object where to store the linear space version
  58181. * @returns the unmodified Color4
  58182. */
  58183. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58184. /**
  58185. * Computes a new Color4 converted from the current one to gamma space
  58186. * @returns a new Color4 object
  58187. */
  58188. toGammaSpace(): Color4;
  58189. /**
  58190. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58191. * @param convertedColor defines the Color4 object where to store the gamma space version
  58192. * @returns the unmodified Color4
  58193. */
  58194. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58195. /**
  58196. * Creates a new Color4 from the string containing valid hexadecimal values
  58197. * @param hex defines a string containing valid hexadecimal values
  58198. * @returns a new Color4 object
  58199. */
  58200. static FromHexString(hex: string): Color4;
  58201. /**
  58202. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58203. * @param left defines the start value
  58204. * @param right defines the end value
  58205. * @param amount defines the gradient factor
  58206. * @returns a new Color4 object
  58207. */
  58208. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58209. /**
  58210. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58211. * @param left defines the start value
  58212. * @param right defines the end value
  58213. * @param amount defines the gradient factor
  58214. * @param result defines the Color4 object where to store data
  58215. */
  58216. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58217. /**
  58218. * Creates a new Color4 from a Color3 and an alpha value
  58219. * @param color3 defines the source Color3 to read from
  58220. * @param alpha defines the alpha component (1.0 by default)
  58221. * @returns a new Color4 object
  58222. */
  58223. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58224. /**
  58225. * Creates a new Color4 from the starting index element of the given array
  58226. * @param array defines the source array to read from
  58227. * @param offset defines the offset in the source array
  58228. * @returns a new Color4 object
  58229. */
  58230. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58231. /**
  58232. * Creates a new Color3 from integer values (< 256)
  58233. * @param r defines the red component to read from (value between 0 and 255)
  58234. * @param g defines the green component to read from (value between 0 and 255)
  58235. * @param b defines the blue component to read from (value between 0 and 255)
  58236. * @param a defines the alpha component to read from (value between 0 and 255)
  58237. * @returns a new Color3 object
  58238. */
  58239. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58240. /**
  58241. * Check the content of a given array and convert it to an array containing RGBA data
  58242. * If the original array was already containing count * 4 values then it is returned directly
  58243. * @param colors defines the array to check
  58244. * @param count defines the number of RGBA data to expect
  58245. * @returns an array containing count * 4 values (RGBA)
  58246. */
  58247. static CheckColors4(colors: number[], count: number): number[];
  58248. }
  58249. /**
  58250. * Class representing a vector containing 2 coordinates
  58251. */
  58252. export class Vector2 {
  58253. /** defines the first coordinate */
  58254. x: number;
  58255. /** defines the second coordinate */
  58256. y: number;
  58257. /**
  58258. * Creates a new Vector2 from the given x and y coordinates
  58259. * @param x defines the first coordinate
  58260. * @param y defines the second coordinate
  58261. */
  58262. constructor(
  58263. /** defines the first coordinate */
  58264. x?: number,
  58265. /** defines the second coordinate */
  58266. y?: number);
  58267. /**
  58268. * Gets a string with the Vector2 coordinates
  58269. * @returns a string with the Vector2 coordinates
  58270. */
  58271. toString(): string;
  58272. /**
  58273. * Gets class name
  58274. * @returns the string "Vector2"
  58275. */
  58276. getClassName(): string;
  58277. /**
  58278. * Gets current vector hash code
  58279. * @returns the Vector2 hash code as a number
  58280. */
  58281. getHashCode(): number;
  58282. /**
  58283. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58284. * @param array defines the source array
  58285. * @param index defines the offset in source array
  58286. * @returns the current Vector2
  58287. */
  58288. toArray(array: FloatArray, index?: number): Vector2;
  58289. /**
  58290. * Copy the current vector to an array
  58291. * @returns a new array with 2 elements: the Vector2 coordinates.
  58292. */
  58293. asArray(): number[];
  58294. /**
  58295. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58296. * @param source defines the source Vector2
  58297. * @returns the current updated Vector2
  58298. */
  58299. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58300. /**
  58301. * Sets the Vector2 coordinates with the given floats
  58302. * @param x defines the first coordinate
  58303. * @param y defines the second coordinate
  58304. * @returns the current updated Vector2
  58305. */
  58306. copyFromFloats(x: number, y: number): Vector2;
  58307. /**
  58308. * Sets the Vector2 coordinates with the given floats
  58309. * @param x defines the first coordinate
  58310. * @param y defines the second coordinate
  58311. * @returns the current updated Vector2
  58312. */
  58313. set(x: number, y: number): Vector2;
  58314. /**
  58315. * Add another vector with the current one
  58316. * @param otherVector defines the other vector
  58317. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58318. */
  58319. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58320. /**
  58321. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58322. * @param otherVector defines the other vector
  58323. * @param result defines the target vector
  58324. * @returns the unmodified current Vector2
  58325. */
  58326. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58327. /**
  58328. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58329. * @param otherVector defines the other vector
  58330. * @returns the current updated Vector2
  58331. */
  58332. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58333. /**
  58334. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58335. * @param otherVector defines the other vector
  58336. * @returns a new Vector2
  58337. */
  58338. addVector3(otherVector: Vector3): Vector2;
  58339. /**
  58340. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58341. * @param otherVector defines the other vector
  58342. * @returns a new Vector2
  58343. */
  58344. subtract(otherVector: Vector2): Vector2;
  58345. /**
  58346. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58347. * @param otherVector defines the other vector
  58348. * @param result defines the target vector
  58349. * @returns the unmodified current Vector2
  58350. */
  58351. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58352. /**
  58353. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58354. * @param otherVector defines the other vector
  58355. * @returns the current updated Vector2
  58356. */
  58357. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58358. /**
  58359. * Multiplies in place the current Vector2 coordinates by the given ones
  58360. * @param otherVector defines the other vector
  58361. * @returns the current updated Vector2
  58362. */
  58363. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58364. /**
  58365. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58366. * @param otherVector defines the other vector
  58367. * @returns a new Vector2
  58368. */
  58369. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58370. /**
  58371. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58372. * @param otherVector defines the other vector
  58373. * @param result defines the target vector
  58374. * @returns the unmodified current Vector2
  58375. */
  58376. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58377. /**
  58378. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58379. * @param x defines the first coordinate
  58380. * @param y defines the second coordinate
  58381. * @returns a new Vector2
  58382. */
  58383. multiplyByFloats(x: number, y: number): Vector2;
  58384. /**
  58385. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58386. * @param otherVector defines the other vector
  58387. * @returns a new Vector2
  58388. */
  58389. divide(otherVector: Vector2): Vector2;
  58390. /**
  58391. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58392. * @param otherVector defines the other vector
  58393. * @param result defines the target vector
  58394. * @returns the unmodified current Vector2
  58395. */
  58396. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58397. /**
  58398. * Divides the current Vector2 coordinates by the given ones
  58399. * @param otherVector defines the other vector
  58400. * @returns the current updated Vector2
  58401. */
  58402. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58403. /**
  58404. * Gets a new Vector2 with current Vector2 negated coordinates
  58405. * @returns a new Vector2
  58406. */
  58407. negate(): Vector2;
  58408. /**
  58409. * Multiply the Vector2 coordinates by scale
  58410. * @param scale defines the scaling factor
  58411. * @returns the current updated Vector2
  58412. */
  58413. scaleInPlace(scale: number): Vector2;
  58414. /**
  58415. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58416. * @param scale defines the scaling factor
  58417. * @returns a new Vector2
  58418. */
  58419. scale(scale: number): Vector2;
  58420. /**
  58421. * Scale the current Vector2 values by a factor to a given Vector2
  58422. * @param scale defines the scale factor
  58423. * @param result defines the Vector2 object where to store the result
  58424. * @returns the unmodified current Vector2
  58425. */
  58426. scaleToRef(scale: number, result: Vector2): Vector2;
  58427. /**
  58428. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58429. * @param scale defines the scale factor
  58430. * @param result defines the Vector2 object where to store the result
  58431. * @returns the unmodified current Vector2
  58432. */
  58433. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58434. /**
  58435. * Gets a boolean if two vectors are equals
  58436. * @param otherVector defines the other vector
  58437. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58438. */
  58439. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58440. /**
  58441. * Gets a boolean if two vectors are equals (using an epsilon value)
  58442. * @param otherVector defines the other vector
  58443. * @param epsilon defines the minimal distance to consider equality
  58444. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58445. */
  58446. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58447. /**
  58448. * Gets a new Vector2 from current Vector2 floored values
  58449. * @returns a new Vector2
  58450. */
  58451. floor(): Vector2;
  58452. /**
  58453. * Gets a new Vector2 from current Vector2 floored values
  58454. * @returns a new Vector2
  58455. */
  58456. fract(): Vector2;
  58457. /**
  58458. * Gets the length of the vector
  58459. * @returns the vector length (float)
  58460. */
  58461. length(): number;
  58462. /**
  58463. * Gets the vector squared length
  58464. * @returns the vector squared length (float)
  58465. */
  58466. lengthSquared(): number;
  58467. /**
  58468. * Normalize the vector
  58469. * @returns the current updated Vector2
  58470. */
  58471. normalize(): Vector2;
  58472. /**
  58473. * Gets a new Vector2 copied from the Vector2
  58474. * @returns a new Vector2
  58475. */
  58476. clone(): Vector2;
  58477. /**
  58478. * Gets a new Vector2(0, 0)
  58479. * @returns a new Vector2
  58480. */
  58481. static Zero(): Vector2;
  58482. /**
  58483. * Gets a new Vector2(1, 1)
  58484. * @returns a new Vector2
  58485. */
  58486. static One(): Vector2;
  58487. /**
  58488. * Gets a new Vector2 set from the given index element of the given array
  58489. * @param array defines the data source
  58490. * @param offset defines the offset in the data source
  58491. * @returns a new Vector2
  58492. */
  58493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58494. /**
  58495. * Sets "result" from the given index element of the given array
  58496. * @param array defines the data source
  58497. * @param offset defines the offset in the data source
  58498. * @param result defines the target vector
  58499. */
  58500. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58501. /**
  58502. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58503. * @param value1 defines 1st point of control
  58504. * @param value2 defines 2nd point of control
  58505. * @param value3 defines 3rd point of control
  58506. * @param value4 defines 4th point of control
  58507. * @param amount defines the interpolation factor
  58508. * @returns a new Vector2
  58509. */
  58510. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58511. /**
  58512. * 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".
  58513. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58514. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58515. * @param value defines the value to clamp
  58516. * @param min defines the lower limit
  58517. * @param max defines the upper limit
  58518. * @returns a new Vector2
  58519. */
  58520. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58521. /**
  58522. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58523. * @param value1 defines the 1st control point
  58524. * @param tangent1 defines the outgoing tangent
  58525. * @param value2 defines the 2nd control point
  58526. * @param tangent2 defines the incoming tangent
  58527. * @param amount defines the interpolation factor
  58528. * @returns a new Vector2
  58529. */
  58530. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58531. /**
  58532. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58533. * @param start defines the start vector
  58534. * @param end defines the end vector
  58535. * @param amount defines the interpolation factor
  58536. * @returns a new Vector2
  58537. */
  58538. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58539. /**
  58540. * Gets the dot product of the vector "left" and the vector "right"
  58541. * @param left defines first vector
  58542. * @param right defines second vector
  58543. * @returns the dot product (float)
  58544. */
  58545. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58546. /**
  58547. * Returns a new Vector2 equal to the normalized given vector
  58548. * @param vector defines the vector to normalize
  58549. * @returns a new Vector2
  58550. */
  58551. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58552. /**
  58553. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58554. * @param left defines 1st vector
  58555. * @param right defines 2nd vector
  58556. * @returns a new Vector2
  58557. */
  58558. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58559. /**
  58560. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58561. * @param left defines 1st vector
  58562. * @param right defines 2nd vector
  58563. * @returns a new Vector2
  58564. */
  58565. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58566. /**
  58567. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58568. * @param vector defines the vector to transform
  58569. * @param transformation defines the matrix to apply
  58570. * @returns a new Vector2
  58571. */
  58572. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58573. /**
  58574. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58575. * @param vector defines the vector to transform
  58576. * @param transformation defines the matrix to apply
  58577. * @param result defines the target vector
  58578. */
  58579. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58580. /**
  58581. * Determines if a given vector is included in a triangle
  58582. * @param p defines the vector to test
  58583. * @param p0 defines 1st triangle point
  58584. * @param p1 defines 2nd triangle point
  58585. * @param p2 defines 3rd triangle point
  58586. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58587. */
  58588. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58589. /**
  58590. * Gets the distance between the vectors "value1" and "value2"
  58591. * @param value1 defines first vector
  58592. * @param value2 defines second vector
  58593. * @returns the distance between vectors
  58594. */
  58595. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58596. /**
  58597. * Returns the squared distance between the vectors "value1" and "value2"
  58598. * @param value1 defines first vector
  58599. * @param value2 defines second vector
  58600. * @returns the squared distance between vectors
  58601. */
  58602. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58603. /**
  58604. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58605. * @param value1 defines first vector
  58606. * @param value2 defines second vector
  58607. * @returns a new Vector2
  58608. */
  58609. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58610. /**
  58611. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58612. * @param p defines the middle point
  58613. * @param segA defines one point of the segment
  58614. * @param segB defines the other point of the segment
  58615. * @returns the shortest distance
  58616. */
  58617. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58618. }
  58619. /**
  58620. * Classed used to store (x,y,z) vector representation
  58621. * A Vector3 is the main object used in 3D geometry
  58622. * It can represent etiher the coordinates of a point the space, either a direction
  58623. * Reminder: js uses a left handed forward facing system
  58624. */
  58625. export class Vector3 {
  58626. /**
  58627. * Defines the first coordinates (on X axis)
  58628. */
  58629. x: number;
  58630. /**
  58631. * Defines the second coordinates (on Y axis)
  58632. */
  58633. y: number;
  58634. /**
  58635. * Defines the third coordinates (on Z axis)
  58636. */
  58637. z: number;
  58638. private static _UpReadOnly;
  58639. /**
  58640. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58641. * @param x defines the first coordinates (on X axis)
  58642. * @param y defines the second coordinates (on Y axis)
  58643. * @param z defines the third coordinates (on Z axis)
  58644. */
  58645. constructor(
  58646. /**
  58647. * Defines the first coordinates (on X axis)
  58648. */
  58649. x?: number,
  58650. /**
  58651. * Defines the second coordinates (on Y axis)
  58652. */
  58653. y?: number,
  58654. /**
  58655. * Defines the third coordinates (on Z axis)
  58656. */
  58657. z?: number);
  58658. /**
  58659. * Creates a string representation of the Vector3
  58660. * @returns a string with the Vector3 coordinates.
  58661. */
  58662. toString(): string;
  58663. /**
  58664. * Gets the class name
  58665. * @returns the string "Vector3"
  58666. */
  58667. getClassName(): string;
  58668. /**
  58669. * Creates the Vector3 hash code
  58670. * @returns a number which tends to be unique between Vector3 instances
  58671. */
  58672. getHashCode(): number;
  58673. /**
  58674. * Creates an array containing three elements : the coordinates of the Vector3
  58675. * @returns a new array of numbers
  58676. */
  58677. asArray(): number[];
  58678. /**
  58679. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58680. * @param array defines the destination array
  58681. * @param index defines the offset in the destination array
  58682. * @returns the current Vector3
  58683. */
  58684. toArray(array: FloatArray, index?: number): Vector3;
  58685. /**
  58686. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58687. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58688. */
  58689. toQuaternion(): Quaternion;
  58690. /**
  58691. * Adds the given vector to the current Vector3
  58692. * @param otherVector defines the second operand
  58693. * @returns the current updated Vector3
  58694. */
  58695. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58696. /**
  58697. * Adds the given coordinates to the current Vector3
  58698. * @param x defines the x coordinate of the operand
  58699. * @param y defines the y coordinate of the operand
  58700. * @param z defines the z coordinate of the operand
  58701. * @returns the current updated Vector3
  58702. */
  58703. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58704. /**
  58705. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58706. * @param otherVector defines the second operand
  58707. * @returns the resulting Vector3
  58708. */
  58709. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58710. /**
  58711. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58712. * @param otherVector defines the second operand
  58713. * @param result defines the Vector3 object where to store the result
  58714. * @returns the current Vector3
  58715. */
  58716. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58717. /**
  58718. * Subtract the given vector from the current Vector3
  58719. * @param otherVector defines the second operand
  58720. * @returns the current updated Vector3
  58721. */
  58722. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58723. /**
  58724. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58725. * @param otherVector defines the second operand
  58726. * @returns the resulting Vector3
  58727. */
  58728. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58729. /**
  58730. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58731. * @param otherVector defines the second operand
  58732. * @param result defines the Vector3 object where to store the result
  58733. * @returns the current Vector3
  58734. */
  58735. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58736. /**
  58737. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58738. * @param x defines the x coordinate of the operand
  58739. * @param y defines the y coordinate of the operand
  58740. * @param z defines the z coordinate of the operand
  58741. * @returns the resulting Vector3
  58742. */
  58743. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58744. /**
  58745. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58746. * @param x defines the x coordinate of the operand
  58747. * @param y defines the y coordinate of the operand
  58748. * @param z defines the z coordinate of the operand
  58749. * @param result defines the Vector3 object where to store the result
  58750. * @returns the current Vector3
  58751. */
  58752. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58753. /**
  58754. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58755. * @returns a new Vector3
  58756. */
  58757. negate(): Vector3;
  58758. /**
  58759. * Multiplies the Vector3 coordinates by the float "scale"
  58760. * @param scale defines the multiplier factor
  58761. * @returns the current updated Vector3
  58762. */
  58763. scaleInPlace(scale: number): Vector3;
  58764. /**
  58765. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58766. * @param scale defines the multiplier factor
  58767. * @returns a new Vector3
  58768. */
  58769. scale(scale: number): Vector3;
  58770. /**
  58771. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58772. * @param scale defines the multiplier factor
  58773. * @param result defines the Vector3 object where to store the result
  58774. * @returns the current Vector3
  58775. */
  58776. scaleToRef(scale: number, result: Vector3): Vector3;
  58777. /**
  58778. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58779. * @param scale defines the scale factor
  58780. * @param result defines the Vector3 object where to store the result
  58781. * @returns the unmodified current Vector3
  58782. */
  58783. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58784. /**
  58785. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58786. * @param otherVector defines the second operand
  58787. * @returns true if both vectors are equals
  58788. */
  58789. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58790. /**
  58791. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58792. * @param otherVector defines the second operand
  58793. * @param epsilon defines the minimal distance to define values as equals
  58794. * @returns true if both vectors are distant less than epsilon
  58795. */
  58796. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58797. /**
  58798. * Returns true if the current Vector3 coordinates equals the given floats
  58799. * @param x defines the x coordinate of the operand
  58800. * @param y defines the y coordinate of the operand
  58801. * @param z defines the z coordinate of the operand
  58802. * @returns true if both vectors are equals
  58803. */
  58804. equalsToFloats(x: number, y: number, z: number): boolean;
  58805. /**
  58806. * Multiplies the current Vector3 coordinates by the given ones
  58807. * @param otherVector defines the second operand
  58808. * @returns the current updated Vector3
  58809. */
  58810. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58811. /**
  58812. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58813. * @param otherVector defines the second operand
  58814. * @returns the new Vector3
  58815. */
  58816. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58817. /**
  58818. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58819. * @param otherVector defines the second operand
  58820. * @param result defines the Vector3 object where to store the result
  58821. * @returns the current Vector3
  58822. */
  58823. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58824. /**
  58825. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58826. * @param x defines the x coordinate of the operand
  58827. * @param y defines the y coordinate of the operand
  58828. * @param z defines the z coordinate of the operand
  58829. * @returns the new Vector3
  58830. */
  58831. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58832. /**
  58833. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58834. * @param otherVector defines the second operand
  58835. * @returns the new Vector3
  58836. */
  58837. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58838. /**
  58839. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58840. * @param otherVector defines the second operand
  58841. * @param result defines the Vector3 object where to store the result
  58842. * @returns the current Vector3
  58843. */
  58844. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58845. /**
  58846. * Divides the current Vector3 coordinates by the given ones.
  58847. * @param otherVector defines the second operand
  58848. * @returns the current updated Vector3
  58849. */
  58850. divideInPlace(otherVector: Vector3): Vector3;
  58851. /**
  58852. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58853. * @param other defines the second operand
  58854. * @returns the current updated Vector3
  58855. */
  58856. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58857. /**
  58858. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58859. * @param other defines the second operand
  58860. * @returns the current updated Vector3
  58861. */
  58862. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58863. /**
  58864. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58865. * @param x defines the x coordinate of the operand
  58866. * @param y defines the y coordinate of the operand
  58867. * @param z defines the z coordinate of the operand
  58868. * @returns the current updated Vector3
  58869. */
  58870. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58871. /**
  58872. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58873. * @param x defines the x coordinate of the operand
  58874. * @param y defines the y coordinate of the operand
  58875. * @param z defines the z coordinate of the operand
  58876. * @returns the current updated Vector3
  58877. */
  58878. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58879. /**
  58880. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58881. * Check if is non uniform within a certain amount of decimal places to account for this
  58882. * @param epsilon the amount the values can differ
  58883. * @returns if the the vector is non uniform to a certain number of decimal places
  58884. */
  58885. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58886. /**
  58887. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58888. */
  58889. readonly isNonUniform: boolean;
  58890. /**
  58891. * Gets a new Vector3 from current Vector3 floored values
  58892. * @returns a new Vector3
  58893. */
  58894. floor(): Vector3;
  58895. /**
  58896. * Gets a new Vector3 from current Vector3 floored values
  58897. * @returns a new Vector3
  58898. */
  58899. fract(): Vector3;
  58900. /**
  58901. * Gets the length of the Vector3
  58902. * @returns the length of the Vecto3
  58903. */
  58904. length(): number;
  58905. /**
  58906. * Gets the squared length of the Vector3
  58907. * @returns squared length of the Vector3
  58908. */
  58909. lengthSquared(): number;
  58910. /**
  58911. * Normalize the current Vector3.
  58912. * Please note that this is an in place operation.
  58913. * @returns the current updated Vector3
  58914. */
  58915. normalize(): Vector3;
  58916. /**
  58917. * Reorders the x y z properties of the vector in place
  58918. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58919. * @returns the current updated vector
  58920. */
  58921. reorderInPlace(order: string): this;
  58922. /**
  58923. * Rotates the vector around 0,0,0 by a quaternion
  58924. * @param quaternion the rotation quaternion
  58925. * @param result vector to store the result
  58926. * @returns the resulting vector
  58927. */
  58928. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58929. /**
  58930. * Rotates a vector around a given point
  58931. * @param quaternion the rotation quaternion
  58932. * @param point the point to rotate around
  58933. * @param result vector to store the result
  58934. * @returns the resulting vector
  58935. */
  58936. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58937. /**
  58938. * Normalize the current Vector3 with the given input length.
  58939. * Please note that this is an in place operation.
  58940. * @param len the length of the vector
  58941. * @returns the current updated Vector3
  58942. */
  58943. normalizeFromLength(len: number): Vector3;
  58944. /**
  58945. * Normalize the current Vector3 to a new vector
  58946. * @returns the new Vector3
  58947. */
  58948. normalizeToNew(): Vector3;
  58949. /**
  58950. * Normalize the current Vector3 to the reference
  58951. * @param reference define the Vector3 to update
  58952. * @returns the updated Vector3
  58953. */
  58954. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58955. /**
  58956. * Creates a new Vector3 copied from the current Vector3
  58957. * @returns the new Vector3
  58958. */
  58959. clone(): Vector3;
  58960. /**
  58961. * Copies the given vector coordinates to the current Vector3 ones
  58962. * @param source defines the source Vector3
  58963. * @returns the current updated Vector3
  58964. */
  58965. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58966. /**
  58967. * Copies the given floats to the current Vector3 coordinates
  58968. * @param x defines the x coordinate of the operand
  58969. * @param y defines the y coordinate of the operand
  58970. * @param z defines the z coordinate of the operand
  58971. * @returns the current updated Vector3
  58972. */
  58973. copyFromFloats(x: number, y: number, z: number): Vector3;
  58974. /**
  58975. * Copies the given floats to the current Vector3 coordinates
  58976. * @param x defines the x coordinate of the operand
  58977. * @param y defines the y coordinate of the operand
  58978. * @param z defines the z coordinate of the operand
  58979. * @returns the current updated Vector3
  58980. */
  58981. set(x: number, y: number, z: number): Vector3;
  58982. /**
  58983. * Copies the given float to the current Vector3 coordinates
  58984. * @param v defines the x, y and z coordinates of the operand
  58985. * @returns the current updated Vector3
  58986. */
  58987. setAll(v: number): Vector3;
  58988. /**
  58989. * Get the clip factor between two vectors
  58990. * @param vector0 defines the first operand
  58991. * @param vector1 defines the second operand
  58992. * @param axis defines the axis to use
  58993. * @param size defines the size along the axis
  58994. * @returns the clip factor
  58995. */
  58996. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58997. /**
  58998. * Get angle between two vectors
  58999. * @param vector0 angle between vector0 and vector1
  59000. * @param vector1 angle between vector0 and vector1
  59001. * @param normal direction of the normal
  59002. * @return the angle between vector0 and vector1
  59003. */
  59004. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59005. /**
  59006. * Returns a new Vector3 set from the index "offset" of the given array
  59007. * @param array defines the source array
  59008. * @param offset defines the offset in the source array
  59009. * @returns the new Vector3
  59010. */
  59011. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59012. /**
  59013. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59014. * This function is deprecated. Use FromArray instead
  59015. * @param array defines the source array
  59016. * @param offset defines the offset in the source array
  59017. * @returns the new Vector3
  59018. */
  59019. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59020. /**
  59021. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59022. * @param array defines the source array
  59023. * @param offset defines the offset in the source array
  59024. * @param result defines the Vector3 where to store the result
  59025. */
  59026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59027. /**
  59028. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59029. * This function is deprecated. Use FromArrayToRef instead.
  59030. * @param array defines the source array
  59031. * @param offset defines the offset in the source array
  59032. * @param result defines the Vector3 where to store the result
  59033. */
  59034. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59035. /**
  59036. * Sets the given vector "result" with the given floats.
  59037. * @param x defines the x coordinate of the source
  59038. * @param y defines the y coordinate of the source
  59039. * @param z defines the z coordinate of the source
  59040. * @param result defines the Vector3 where to store the result
  59041. */
  59042. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59043. /**
  59044. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59045. * @returns a new empty Vector3
  59046. */
  59047. static Zero(): Vector3;
  59048. /**
  59049. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59050. * @returns a new unit Vector3
  59051. */
  59052. static One(): Vector3;
  59053. /**
  59054. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59055. * @returns a new up Vector3
  59056. */
  59057. static Up(): Vector3;
  59058. /**
  59059. * Gets a up Vector3 that must not be updated
  59060. */
  59061. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59062. /**
  59063. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59064. * @returns a new down Vector3
  59065. */
  59066. static Down(): Vector3;
  59067. /**
  59068. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59069. * @returns a new forward Vector3
  59070. */
  59071. static Forward(): Vector3;
  59072. /**
  59073. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59074. * @returns a new forward Vector3
  59075. */
  59076. static Backward(): Vector3;
  59077. /**
  59078. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59079. * @returns a new right Vector3
  59080. */
  59081. static Right(): Vector3;
  59082. /**
  59083. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59084. * @returns a new left Vector3
  59085. */
  59086. static Left(): Vector3;
  59087. /**
  59088. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59089. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59090. * @param vector defines the Vector3 to transform
  59091. * @param transformation defines the transformation matrix
  59092. * @returns the transformed Vector3
  59093. */
  59094. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59095. /**
  59096. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59097. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59098. * @param vector defines the Vector3 to transform
  59099. * @param transformation defines the transformation matrix
  59100. * @param result defines the Vector3 where to store the result
  59101. */
  59102. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59103. /**
  59104. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59105. * This method computes tranformed coordinates only, not transformed direction vectors
  59106. * @param x define the x coordinate of the source vector
  59107. * @param y define the y coordinate of the source vector
  59108. * @param z define the z coordinate of the source vector
  59109. * @param transformation defines the transformation matrix
  59110. * @param result defines the Vector3 where to store the result
  59111. */
  59112. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59113. /**
  59114. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59115. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59116. * @param vector defines the Vector3 to transform
  59117. * @param transformation defines the transformation matrix
  59118. * @returns the new Vector3
  59119. */
  59120. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59121. /**
  59122. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59123. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59124. * @param vector defines the Vector3 to transform
  59125. * @param transformation defines the transformation matrix
  59126. * @param result defines the Vector3 where to store the result
  59127. */
  59128. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59129. /**
  59130. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59131. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59132. * @param x define the x coordinate of the source vector
  59133. * @param y define the y coordinate of the source vector
  59134. * @param z define the z coordinate of the source vector
  59135. * @param transformation defines the transformation matrix
  59136. * @param result defines the Vector3 where to store the result
  59137. */
  59138. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59139. /**
  59140. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59141. * @param value1 defines the first control point
  59142. * @param value2 defines the second control point
  59143. * @param value3 defines the third control point
  59144. * @param value4 defines the fourth control point
  59145. * @param amount defines the amount on the spline to use
  59146. * @returns the new Vector3
  59147. */
  59148. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59149. /**
  59150. * 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"
  59151. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59152. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59153. * @param value defines the current value
  59154. * @param min defines the lower range value
  59155. * @param max defines the upper range value
  59156. * @returns the new Vector3
  59157. */
  59158. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59159. /**
  59160. * 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"
  59161. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59162. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59163. * @param value defines the current value
  59164. * @param min defines the lower range value
  59165. * @param max defines the upper range value
  59166. * @param result defines the Vector3 where to store the result
  59167. */
  59168. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59169. /**
  59170. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59171. * @param value1 defines the first control point
  59172. * @param tangent1 defines the first tangent vector
  59173. * @param value2 defines the second control point
  59174. * @param tangent2 defines the second tangent vector
  59175. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59176. * @returns the new Vector3
  59177. */
  59178. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59179. /**
  59180. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59181. * @param start defines the start value
  59182. * @param end defines the end value
  59183. * @param amount max defines amount between both (between 0 and 1)
  59184. * @returns the new Vector3
  59185. */
  59186. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59187. /**
  59188. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59189. * @param start defines the start value
  59190. * @param end defines the end value
  59191. * @param amount max defines amount between both (between 0 and 1)
  59192. * @param result defines the Vector3 where to store the result
  59193. */
  59194. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59195. /**
  59196. * Returns the dot product (float) between the vectors "left" and "right"
  59197. * @param left defines the left operand
  59198. * @param right defines the right operand
  59199. * @returns the dot product
  59200. */
  59201. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59202. /**
  59203. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59204. * The cross product is then orthogonal to both "left" and "right"
  59205. * @param left defines the left operand
  59206. * @param right defines the right operand
  59207. * @returns the cross product
  59208. */
  59209. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59210. /**
  59211. * Sets the given vector "result" with the cross product of "left" and "right"
  59212. * The cross product is then orthogonal to both "left" and "right"
  59213. * @param left defines the left operand
  59214. * @param right defines the right operand
  59215. * @param result defines the Vector3 where to store the result
  59216. */
  59217. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59218. /**
  59219. * Returns a new Vector3 as the normalization of the given vector
  59220. * @param vector defines the Vector3 to normalize
  59221. * @returns the new Vector3
  59222. */
  59223. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59224. /**
  59225. * Sets the given vector "result" with the normalization of the given first vector
  59226. * @param vector defines the Vector3 to normalize
  59227. * @param result defines the Vector3 where to store the result
  59228. */
  59229. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59230. /**
  59231. * Project a Vector3 onto screen space
  59232. * @param vector defines the Vector3 to project
  59233. * @param world defines the world matrix to use
  59234. * @param transform defines the transform (view x projection) matrix to use
  59235. * @param viewport defines the screen viewport to use
  59236. * @returns the new Vector3
  59237. */
  59238. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59239. /** @hidden */
  59240. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59241. /**
  59242. * Unproject from screen space to object space
  59243. * @param source defines the screen space Vector3 to use
  59244. * @param viewportWidth defines the current width of the viewport
  59245. * @param viewportHeight defines the current height of the viewport
  59246. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59247. * @param transform defines the transform (view x projection) matrix to use
  59248. * @returns the new Vector3
  59249. */
  59250. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59251. /**
  59252. * Unproject from screen space to object space
  59253. * @param source defines the screen space Vector3 to use
  59254. * @param viewportWidth defines the current width of the viewport
  59255. * @param viewportHeight defines the current height of the viewport
  59256. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59257. * @param view defines the view matrix to use
  59258. * @param projection defines the projection matrix to use
  59259. * @returns the new Vector3
  59260. */
  59261. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59262. /**
  59263. * Unproject from screen space to object space
  59264. * @param source defines the screen space Vector3 to use
  59265. * @param viewportWidth defines the current width of the viewport
  59266. * @param viewportHeight defines the current height of the viewport
  59267. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59268. * @param view defines the view matrix to use
  59269. * @param projection defines the projection matrix to use
  59270. * @param result defines the Vector3 where to store the result
  59271. */
  59272. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59273. /**
  59274. * Unproject from screen space to object space
  59275. * @param sourceX defines the screen space x coordinate to use
  59276. * @param sourceY defines the screen space y coordinate to use
  59277. * @param sourceZ defines the screen space z coordinate to use
  59278. * @param viewportWidth defines the current width of the viewport
  59279. * @param viewportHeight defines the current height of the viewport
  59280. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59281. * @param view defines the view matrix to use
  59282. * @param projection defines the projection matrix to use
  59283. * @param result defines the Vector3 where to store the result
  59284. */
  59285. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59286. /**
  59287. * Gets the minimal coordinate values between two Vector3
  59288. * @param left defines the first operand
  59289. * @param right defines the second operand
  59290. * @returns the new Vector3
  59291. */
  59292. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59293. /**
  59294. * Gets the maximal coordinate values between two Vector3
  59295. * @param left defines the first operand
  59296. * @param right defines the second operand
  59297. * @returns the new Vector3
  59298. */
  59299. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59300. /**
  59301. * Returns the distance between the vectors "value1" and "value2"
  59302. * @param value1 defines the first operand
  59303. * @param value2 defines the second operand
  59304. * @returns the distance
  59305. */
  59306. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59307. /**
  59308. * Returns the squared distance between the vectors "value1" and "value2"
  59309. * @param value1 defines the first operand
  59310. * @param value2 defines the second operand
  59311. * @returns the squared distance
  59312. */
  59313. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59314. /**
  59315. * Returns a new Vector3 located at the center between "value1" and "value2"
  59316. * @param value1 defines the first operand
  59317. * @param value2 defines the second operand
  59318. * @returns the new Vector3
  59319. */
  59320. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59321. /**
  59322. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59323. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59324. * to something in order to rotate it from its local system to the given target system
  59325. * Note: axis1, axis2 and axis3 are normalized during this operation
  59326. * @param axis1 defines the first axis
  59327. * @param axis2 defines the second axis
  59328. * @param axis3 defines the third axis
  59329. * @returns a new Vector3
  59330. */
  59331. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59332. /**
  59333. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59334. * @param axis1 defines the first axis
  59335. * @param axis2 defines the second axis
  59336. * @param axis3 defines the third axis
  59337. * @param ref defines the Vector3 where to store the result
  59338. */
  59339. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59340. }
  59341. /**
  59342. * Vector4 class created for EulerAngle class conversion to Quaternion
  59343. */
  59344. export class Vector4 {
  59345. /** x value of the vector */
  59346. x: number;
  59347. /** y value of the vector */
  59348. y: number;
  59349. /** z value of the vector */
  59350. z: number;
  59351. /** w value of the vector */
  59352. w: number;
  59353. /**
  59354. * Creates a Vector4 object from the given floats.
  59355. * @param x x value of the vector
  59356. * @param y y value of the vector
  59357. * @param z z value of the vector
  59358. * @param w w value of the vector
  59359. */
  59360. constructor(
  59361. /** x value of the vector */
  59362. x: number,
  59363. /** y value of the vector */
  59364. y: number,
  59365. /** z value of the vector */
  59366. z: number,
  59367. /** w value of the vector */
  59368. w: number);
  59369. /**
  59370. * Returns the string with the Vector4 coordinates.
  59371. * @returns a string containing all the vector values
  59372. */
  59373. toString(): string;
  59374. /**
  59375. * Returns the string "Vector4".
  59376. * @returns "Vector4"
  59377. */
  59378. getClassName(): string;
  59379. /**
  59380. * Returns the Vector4 hash code.
  59381. * @returns a unique hash code
  59382. */
  59383. getHashCode(): number;
  59384. /**
  59385. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59386. * @returns the resulting array
  59387. */
  59388. asArray(): number[];
  59389. /**
  59390. * Populates the given array from the given index with the Vector4 coordinates.
  59391. * @param array array to populate
  59392. * @param index index of the array to start at (default: 0)
  59393. * @returns the Vector4.
  59394. */
  59395. toArray(array: FloatArray, index?: number): Vector4;
  59396. /**
  59397. * Adds the given vector to the current Vector4.
  59398. * @param otherVector the vector to add
  59399. * @returns the updated Vector4.
  59400. */
  59401. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59402. /**
  59403. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59404. * @param otherVector the vector to add
  59405. * @returns the resulting vector
  59406. */
  59407. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59408. /**
  59409. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59410. * @param otherVector the vector to add
  59411. * @param result the vector to store the result
  59412. * @returns the current Vector4.
  59413. */
  59414. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59415. /**
  59416. * Subtract in place the given vector from the current Vector4.
  59417. * @param otherVector the vector to subtract
  59418. * @returns the updated Vector4.
  59419. */
  59420. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59421. /**
  59422. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59423. * @param otherVector the vector to add
  59424. * @returns the new vector with the result
  59425. */
  59426. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59427. /**
  59428. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59429. * @param otherVector the vector to subtract
  59430. * @param result the vector to store the result
  59431. * @returns the current Vector4.
  59432. */
  59433. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59434. /**
  59435. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59436. */
  59437. /**
  59438. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59439. * @param x value to subtract
  59440. * @param y value to subtract
  59441. * @param z value to subtract
  59442. * @param w value to subtract
  59443. * @returns new vector containing the result
  59444. */
  59445. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59446. /**
  59447. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59448. * @param x value to subtract
  59449. * @param y value to subtract
  59450. * @param z value to subtract
  59451. * @param w value to subtract
  59452. * @param result the vector to store the result in
  59453. * @returns the current Vector4.
  59454. */
  59455. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59456. /**
  59457. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59458. * @returns a new vector with the negated values
  59459. */
  59460. negate(): Vector4;
  59461. /**
  59462. * Multiplies the current Vector4 coordinates by scale (float).
  59463. * @param scale the number to scale with
  59464. * @returns the updated Vector4.
  59465. */
  59466. scaleInPlace(scale: number): Vector4;
  59467. /**
  59468. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59469. * @param scale the number to scale with
  59470. * @returns a new vector with the result
  59471. */
  59472. scale(scale: number): Vector4;
  59473. /**
  59474. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59475. * @param scale the number to scale with
  59476. * @param result a vector to store the result in
  59477. * @returns the current Vector4.
  59478. */
  59479. scaleToRef(scale: number, result: Vector4): Vector4;
  59480. /**
  59481. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59482. * @param scale defines the scale factor
  59483. * @param result defines the Vector4 object where to store the result
  59484. * @returns the unmodified current Vector4
  59485. */
  59486. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59487. /**
  59488. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59489. * @param otherVector the vector to compare against
  59490. * @returns true if they are equal
  59491. */
  59492. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59493. /**
  59494. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59495. * @param otherVector vector to compare against
  59496. * @param epsilon (Default: very small number)
  59497. * @returns true if they are equal
  59498. */
  59499. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59500. /**
  59501. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59502. * @param x x value to compare against
  59503. * @param y y value to compare against
  59504. * @param z z value to compare against
  59505. * @param w w value to compare against
  59506. * @returns true if equal
  59507. */
  59508. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59509. /**
  59510. * Multiplies in place the current Vector4 by the given one.
  59511. * @param otherVector vector to multiple with
  59512. * @returns the updated Vector4.
  59513. */
  59514. multiplyInPlace(otherVector: Vector4): Vector4;
  59515. /**
  59516. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59517. * @param otherVector vector to multiple with
  59518. * @returns resulting new vector
  59519. */
  59520. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59521. /**
  59522. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59523. * @param otherVector vector to multiple with
  59524. * @param result vector to store the result
  59525. * @returns the current Vector4.
  59526. */
  59527. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59528. /**
  59529. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59530. * @param x x value multiply with
  59531. * @param y y value multiply with
  59532. * @param z z value multiply with
  59533. * @param w w value multiply with
  59534. * @returns resulting new vector
  59535. */
  59536. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59537. /**
  59538. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59539. * @param otherVector vector to devide with
  59540. * @returns resulting new vector
  59541. */
  59542. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59543. /**
  59544. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59545. * @param otherVector vector to devide with
  59546. * @param result vector to store the result
  59547. * @returns the current Vector4.
  59548. */
  59549. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59550. /**
  59551. * Divides the current Vector3 coordinates by the given ones.
  59552. * @param otherVector vector to devide with
  59553. * @returns the updated Vector3.
  59554. */
  59555. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59556. /**
  59557. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59558. * @param other defines the second operand
  59559. * @returns the current updated Vector4
  59560. */
  59561. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59562. /**
  59563. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59564. * @param other defines the second operand
  59565. * @returns the current updated Vector4
  59566. */
  59567. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59568. /**
  59569. * Gets a new Vector4 from current Vector4 floored values
  59570. * @returns a new Vector4
  59571. */
  59572. floor(): Vector4;
  59573. /**
  59574. * Gets a new Vector4 from current Vector3 floored values
  59575. * @returns a new Vector4
  59576. */
  59577. fract(): Vector4;
  59578. /**
  59579. * Returns the Vector4 length (float).
  59580. * @returns the length
  59581. */
  59582. length(): number;
  59583. /**
  59584. * Returns the Vector4 squared length (float).
  59585. * @returns the length squared
  59586. */
  59587. lengthSquared(): number;
  59588. /**
  59589. * Normalizes in place the Vector4.
  59590. * @returns the updated Vector4.
  59591. */
  59592. normalize(): Vector4;
  59593. /**
  59594. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59595. * @returns this converted to a new vector3
  59596. */
  59597. toVector3(): Vector3;
  59598. /**
  59599. * Returns a new Vector4 copied from the current one.
  59600. * @returns the new cloned vector
  59601. */
  59602. clone(): Vector4;
  59603. /**
  59604. * Updates the current Vector4 with the given one coordinates.
  59605. * @param source the source vector to copy from
  59606. * @returns the updated Vector4.
  59607. */
  59608. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59609. /**
  59610. * Updates the current Vector4 coordinates with the given floats.
  59611. * @param x float to copy from
  59612. * @param y float to copy from
  59613. * @param z float to copy from
  59614. * @param w float to copy from
  59615. * @returns the updated Vector4.
  59616. */
  59617. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59618. /**
  59619. * Updates the current Vector4 coordinates with the given floats.
  59620. * @param x float to set from
  59621. * @param y float to set from
  59622. * @param z float to set from
  59623. * @param w float to set from
  59624. * @returns the updated Vector4.
  59625. */
  59626. set(x: number, y: number, z: number, w: number): Vector4;
  59627. /**
  59628. * Copies the given float to the current Vector3 coordinates
  59629. * @param v defines the x, y, z and w coordinates of the operand
  59630. * @returns the current updated Vector3
  59631. */
  59632. setAll(v: number): Vector4;
  59633. /**
  59634. * Returns a new Vector4 set from the starting index of the given array.
  59635. * @param array the array to pull values from
  59636. * @param offset the offset into the array to start at
  59637. * @returns the new vector
  59638. */
  59639. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59640. /**
  59641. * Updates the given vector "result" from the starting index of the given array.
  59642. * @param array the array to pull values from
  59643. * @param offset the offset into the array to start at
  59644. * @param result the vector to store the result in
  59645. */
  59646. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59647. /**
  59648. * Updates the given vector "result" from the starting index of the given Float32Array.
  59649. * @param array the array to pull values from
  59650. * @param offset the offset into the array to start at
  59651. * @param result the vector to store the result in
  59652. */
  59653. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59654. /**
  59655. * Updates the given vector "result" coordinates from the given floats.
  59656. * @param x float to set from
  59657. * @param y float to set from
  59658. * @param z float to set from
  59659. * @param w float to set from
  59660. * @param result the vector to the floats in
  59661. */
  59662. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59663. /**
  59664. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59665. * @returns the new vector
  59666. */
  59667. static Zero(): Vector4;
  59668. /**
  59669. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59670. * @returns the new vector
  59671. */
  59672. static One(): Vector4;
  59673. /**
  59674. * Returns a new normalized Vector4 from the given one.
  59675. * @param vector the vector to normalize
  59676. * @returns the vector
  59677. */
  59678. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59679. /**
  59680. * Updates the given vector "result" from the normalization of the given one.
  59681. * @param vector the vector to normalize
  59682. * @param result the vector to store the result in
  59683. */
  59684. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59685. /**
  59686. * Returns a vector with the minimum values from the left and right vectors
  59687. * @param left left vector to minimize
  59688. * @param right right vector to minimize
  59689. * @returns a new vector with the minimum of the left and right vector values
  59690. */
  59691. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59692. /**
  59693. * Returns a vector with the maximum values from the left and right vectors
  59694. * @param left left vector to maximize
  59695. * @param right right vector to maximize
  59696. * @returns a new vector with the maximum of the left and right vector values
  59697. */
  59698. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59699. /**
  59700. * Returns the distance (float) between the vectors "value1" and "value2".
  59701. * @param value1 value to calulate the distance between
  59702. * @param value2 value to calulate the distance between
  59703. * @return the distance between the two vectors
  59704. */
  59705. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59706. /**
  59707. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59708. * @param value1 value to calulate the distance between
  59709. * @param value2 value to calulate the distance between
  59710. * @return the distance between the two vectors squared
  59711. */
  59712. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59713. /**
  59714. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59715. * @param value1 value to calulate the center between
  59716. * @param value2 value to calulate the center between
  59717. * @return the center between the two vectors
  59718. */
  59719. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59720. /**
  59721. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59722. * This methods computes transformed normalized direction vectors only.
  59723. * @param vector the vector to transform
  59724. * @param transformation the transformation matrix to apply
  59725. * @returns the new vector
  59726. */
  59727. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59728. /**
  59729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59730. * This methods computes transformed normalized direction vectors only.
  59731. * @param vector the vector to transform
  59732. * @param transformation the transformation matrix to apply
  59733. * @param result the vector to store the result in
  59734. */
  59735. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59736. /**
  59737. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59738. * This methods computes transformed normalized direction vectors only.
  59739. * @param x value to transform
  59740. * @param y value to transform
  59741. * @param z value to transform
  59742. * @param w value to transform
  59743. * @param transformation the transformation matrix to apply
  59744. * @param result the vector to store the results in
  59745. */
  59746. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59747. /**
  59748. * Creates a new Vector4 from a Vector3
  59749. * @param source defines the source data
  59750. * @param w defines the 4th component (default is 0)
  59751. * @returns a new Vector4
  59752. */
  59753. static FromVector3(source: Vector3, w?: number): Vector4;
  59754. }
  59755. /**
  59756. * Interface for the size containing width and height
  59757. */
  59758. export interface ISize {
  59759. /**
  59760. * Width
  59761. */
  59762. width: number;
  59763. /**
  59764. * Heighht
  59765. */
  59766. height: number;
  59767. }
  59768. /**
  59769. * Size containing widht and height
  59770. */
  59771. export class Size implements ISize {
  59772. /**
  59773. * Width
  59774. */
  59775. width: number;
  59776. /**
  59777. * Height
  59778. */
  59779. height: number;
  59780. /**
  59781. * Creates a Size object from the given width and height (floats).
  59782. * @param width width of the new size
  59783. * @param height height of the new size
  59784. */
  59785. constructor(width: number, height: number);
  59786. /**
  59787. * Returns a string with the Size width and height
  59788. * @returns a string with the Size width and height
  59789. */
  59790. toString(): string;
  59791. /**
  59792. * "Size"
  59793. * @returns the string "Size"
  59794. */
  59795. getClassName(): string;
  59796. /**
  59797. * Returns the Size hash code.
  59798. * @returns a hash code for a unique width and height
  59799. */
  59800. getHashCode(): number;
  59801. /**
  59802. * Updates the current size from the given one.
  59803. * @param src the given size
  59804. */
  59805. copyFrom(src: Size): void;
  59806. /**
  59807. * Updates in place the current Size from the given floats.
  59808. * @param width width of the new size
  59809. * @param height height of the new size
  59810. * @returns the updated Size.
  59811. */
  59812. copyFromFloats(width: number, height: number): Size;
  59813. /**
  59814. * Updates in place the current Size from the given floats.
  59815. * @param width width to set
  59816. * @param height height to set
  59817. * @returns the updated Size.
  59818. */
  59819. set(width: number, height: number): Size;
  59820. /**
  59821. * Multiplies the width and height by numbers
  59822. * @param w factor to multiple the width by
  59823. * @param h factor to multiple the height by
  59824. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59825. */
  59826. multiplyByFloats(w: number, h: number): Size;
  59827. /**
  59828. * Clones the size
  59829. * @returns a new Size copied from the given one.
  59830. */
  59831. clone(): Size;
  59832. /**
  59833. * True if the current Size and the given one width and height are strictly equal.
  59834. * @param other the other size to compare against
  59835. * @returns True if the current Size and the given one width and height are strictly equal.
  59836. */
  59837. equals(other: Size): boolean;
  59838. /**
  59839. * The surface of the Size : width * height (float).
  59840. */
  59841. readonly surface: number;
  59842. /**
  59843. * Create a new size of zero
  59844. * @returns a new Size set to (0.0, 0.0)
  59845. */
  59846. static Zero(): Size;
  59847. /**
  59848. * Sums the width and height of two sizes
  59849. * @param otherSize size to add to this size
  59850. * @returns a new Size set as the addition result of the current Size and the given one.
  59851. */
  59852. add(otherSize: Size): Size;
  59853. /**
  59854. * Subtracts the width and height of two
  59855. * @param otherSize size to subtract to this size
  59856. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59857. */
  59858. subtract(otherSize: Size): Size;
  59859. /**
  59860. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59861. * @param start starting size to lerp between
  59862. * @param end end size to lerp between
  59863. * @param amount amount to lerp between the start and end values
  59864. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59865. */
  59866. static Lerp(start: Size, end: Size, amount: number): Size;
  59867. }
  59868. /**
  59869. * Class used to store quaternion data
  59870. * @see https://en.wikipedia.org/wiki/Quaternion
  59871. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59872. */
  59873. export class Quaternion {
  59874. /** defines the first component (0 by default) */
  59875. x: number;
  59876. /** defines the second component (0 by default) */
  59877. y: number;
  59878. /** defines the third component (0 by default) */
  59879. z: number;
  59880. /** defines the fourth component (1.0 by default) */
  59881. w: number;
  59882. /**
  59883. * Creates a new Quaternion from the given floats
  59884. * @param x defines the first component (0 by default)
  59885. * @param y defines the second component (0 by default)
  59886. * @param z defines the third component (0 by default)
  59887. * @param w defines the fourth component (1.0 by default)
  59888. */
  59889. constructor(
  59890. /** defines the first component (0 by default) */
  59891. x?: number,
  59892. /** defines the second component (0 by default) */
  59893. y?: number,
  59894. /** defines the third component (0 by default) */
  59895. z?: number,
  59896. /** defines the fourth component (1.0 by default) */
  59897. w?: number);
  59898. /**
  59899. * Gets a string representation for the current quaternion
  59900. * @returns a string with the Quaternion coordinates
  59901. */
  59902. toString(): string;
  59903. /**
  59904. * Gets the class name of the quaternion
  59905. * @returns the string "Quaternion"
  59906. */
  59907. getClassName(): string;
  59908. /**
  59909. * Gets a hash code for this quaternion
  59910. * @returns the quaternion hash code
  59911. */
  59912. getHashCode(): number;
  59913. /**
  59914. * Copy the quaternion to an array
  59915. * @returns a new array populated with 4 elements from the quaternion coordinates
  59916. */
  59917. asArray(): number[];
  59918. /**
  59919. * Check if two quaternions are equals
  59920. * @param otherQuaternion defines the second operand
  59921. * @return true if the current quaternion and the given one coordinates are strictly equals
  59922. */
  59923. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59924. /**
  59925. * Clone the current quaternion
  59926. * @returns a new quaternion copied from the current one
  59927. */
  59928. clone(): Quaternion;
  59929. /**
  59930. * Copy a quaternion to the current one
  59931. * @param other defines the other quaternion
  59932. * @returns the updated current quaternion
  59933. */
  59934. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59935. /**
  59936. * Updates the current quaternion with the given float coordinates
  59937. * @param x defines the x coordinate
  59938. * @param y defines the y coordinate
  59939. * @param z defines the z coordinate
  59940. * @param w defines the w coordinate
  59941. * @returns the updated current quaternion
  59942. */
  59943. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59944. /**
  59945. * Updates the current quaternion from the given float coordinates
  59946. * @param x defines the x coordinate
  59947. * @param y defines the y coordinate
  59948. * @param z defines the z coordinate
  59949. * @param w defines the w coordinate
  59950. * @returns the updated current quaternion
  59951. */
  59952. set(x: number, y: number, z: number, w: number): Quaternion;
  59953. /**
  59954. * Adds two quaternions
  59955. * @param other defines the second operand
  59956. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59957. */
  59958. add(other: DeepImmutable<Quaternion>): Quaternion;
  59959. /**
  59960. * Add a quaternion to the current one
  59961. * @param other defines the quaternion to add
  59962. * @returns the current quaternion
  59963. */
  59964. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59965. /**
  59966. * Subtract two quaternions
  59967. * @param other defines the second operand
  59968. * @returns a new quaternion as the subtraction result of the given one from the current one
  59969. */
  59970. subtract(other: Quaternion): Quaternion;
  59971. /**
  59972. * Multiplies the current quaternion by a scale factor
  59973. * @param value defines the scale factor
  59974. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59975. */
  59976. scale(value: number): Quaternion;
  59977. /**
  59978. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59979. * @param scale defines the scale factor
  59980. * @param result defines the Quaternion object where to store the result
  59981. * @returns the unmodified current quaternion
  59982. */
  59983. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59984. /**
  59985. * Multiplies in place the current quaternion by a scale factor
  59986. * @param value defines the scale factor
  59987. * @returns the current modified quaternion
  59988. */
  59989. scaleInPlace(value: number): Quaternion;
  59990. /**
  59991. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59992. * @param scale defines the scale factor
  59993. * @param result defines the Quaternion object where to store the result
  59994. * @returns the unmodified current quaternion
  59995. */
  59996. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59997. /**
  59998. * Multiplies two quaternions
  59999. * @param q1 defines the second operand
  60000. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60001. */
  60002. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60003. /**
  60004. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60005. * @param q1 defines the second operand
  60006. * @param result defines the target quaternion
  60007. * @returns the current quaternion
  60008. */
  60009. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60010. /**
  60011. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60012. * @param q1 defines the second operand
  60013. * @returns the currentupdated quaternion
  60014. */
  60015. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60016. /**
  60017. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60018. * @param ref defines the target quaternion
  60019. * @returns the current quaternion
  60020. */
  60021. conjugateToRef(ref: Quaternion): Quaternion;
  60022. /**
  60023. * Conjugates in place (1-q) the current quaternion
  60024. * @returns the current updated quaternion
  60025. */
  60026. conjugateInPlace(): Quaternion;
  60027. /**
  60028. * Conjugates in place (1-q) the current quaternion
  60029. * @returns a new quaternion
  60030. */
  60031. conjugate(): Quaternion;
  60032. /**
  60033. * Gets length of current quaternion
  60034. * @returns the quaternion length (float)
  60035. */
  60036. length(): number;
  60037. /**
  60038. * Normalize in place the current quaternion
  60039. * @returns the current updated quaternion
  60040. */
  60041. normalize(): Quaternion;
  60042. /**
  60043. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60044. * @param order is a reserved parameter and is ignore for now
  60045. * @returns a new Vector3 containing the Euler angles
  60046. */
  60047. toEulerAngles(order?: string): Vector3;
  60048. /**
  60049. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60050. * @param result defines the vector which will be filled with the Euler angles
  60051. * @param order is a reserved parameter and is ignore for now
  60052. * @returns the current unchanged quaternion
  60053. */
  60054. toEulerAnglesToRef(result: Vector3): Quaternion;
  60055. /**
  60056. * Updates the given rotation matrix with the current quaternion values
  60057. * @param result defines the target matrix
  60058. * @returns the current unchanged quaternion
  60059. */
  60060. toRotationMatrix(result: Matrix): Quaternion;
  60061. /**
  60062. * Updates the current quaternion from the given rotation matrix values
  60063. * @param matrix defines the source matrix
  60064. * @returns the current updated quaternion
  60065. */
  60066. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60067. /**
  60068. * Creates a new quaternion from a rotation matrix
  60069. * @param matrix defines the source matrix
  60070. * @returns a new quaternion created from the given rotation matrix values
  60071. */
  60072. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60073. /**
  60074. * Updates the given quaternion with the given rotation matrix values
  60075. * @param matrix defines the source matrix
  60076. * @param result defines the target quaternion
  60077. */
  60078. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60079. /**
  60080. * Returns the dot product (float) between the quaternions "left" and "right"
  60081. * @param left defines the left operand
  60082. * @param right defines the right operand
  60083. * @returns the dot product
  60084. */
  60085. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60086. /**
  60087. * Checks if the two quaternions are close to each other
  60088. * @param quat0 defines the first quaternion to check
  60089. * @param quat1 defines the second quaternion to check
  60090. * @returns true if the two quaternions are close to each other
  60091. */
  60092. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60093. /**
  60094. * Creates an empty quaternion
  60095. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60096. */
  60097. static Zero(): Quaternion;
  60098. /**
  60099. * Inverse a given quaternion
  60100. * @param q defines the source quaternion
  60101. * @returns a new quaternion as the inverted current quaternion
  60102. */
  60103. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60104. /**
  60105. * Inverse a given quaternion
  60106. * @param q defines the source quaternion
  60107. * @param result the quaternion the result will be stored in
  60108. * @returns the result quaternion
  60109. */
  60110. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60111. /**
  60112. * Creates an identity quaternion
  60113. * @returns the identity quaternion
  60114. */
  60115. static Identity(): Quaternion;
  60116. /**
  60117. * Gets a boolean indicating if the given quaternion is identity
  60118. * @param quaternion defines the quaternion to check
  60119. * @returns true if the quaternion is identity
  60120. */
  60121. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60122. /**
  60123. * Creates a quaternion from a rotation around an axis
  60124. * @param axis defines the axis to use
  60125. * @param angle defines the angle to use
  60126. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60127. */
  60128. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60129. /**
  60130. * Creates a rotation around an axis and stores it into the given quaternion
  60131. * @param axis defines the axis to use
  60132. * @param angle defines the angle to use
  60133. * @param result defines the target quaternion
  60134. * @returns the target quaternion
  60135. */
  60136. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60137. /**
  60138. * Creates a new quaternion from data stored into an array
  60139. * @param array defines the data source
  60140. * @param offset defines the offset in the source array where the data starts
  60141. * @returns a new quaternion
  60142. */
  60143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60144. /**
  60145. * Create a quaternion from Euler rotation angles
  60146. * @param x Pitch
  60147. * @param y Yaw
  60148. * @param z Roll
  60149. * @returns the new Quaternion
  60150. */
  60151. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60152. /**
  60153. * Updates a quaternion from Euler rotation angles
  60154. * @param x Pitch
  60155. * @param y Yaw
  60156. * @param z Roll
  60157. * @param result the quaternion to store the result
  60158. * @returns the updated quaternion
  60159. */
  60160. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60161. /**
  60162. * Create a quaternion from Euler rotation vector
  60163. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60164. * @returns the new Quaternion
  60165. */
  60166. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60167. /**
  60168. * Updates a quaternion from Euler rotation vector
  60169. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60170. * @param result the quaternion to store the result
  60171. * @returns the updated quaternion
  60172. */
  60173. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60174. /**
  60175. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60176. * @param yaw defines the rotation around Y axis
  60177. * @param pitch defines the rotation around X axis
  60178. * @param roll defines the rotation around Z axis
  60179. * @returns the new quaternion
  60180. */
  60181. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60182. /**
  60183. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60184. * @param yaw defines the rotation around Y axis
  60185. * @param pitch defines the rotation around X axis
  60186. * @param roll defines the rotation around Z axis
  60187. * @param result defines the target quaternion
  60188. */
  60189. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60190. /**
  60191. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60192. * @param alpha defines the rotation around first axis
  60193. * @param beta defines the rotation around second axis
  60194. * @param gamma defines the rotation around third axis
  60195. * @returns the new quaternion
  60196. */
  60197. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60198. /**
  60199. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60200. * @param alpha defines the rotation around first axis
  60201. * @param beta defines the rotation around second axis
  60202. * @param gamma defines the rotation around third axis
  60203. * @param result defines the target quaternion
  60204. */
  60205. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60206. /**
  60207. * 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)
  60208. * @param axis1 defines the first axis
  60209. * @param axis2 defines the second axis
  60210. * @param axis3 defines the third axis
  60211. * @returns the new quaternion
  60212. */
  60213. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60214. /**
  60215. * 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
  60216. * @param axis1 defines the first axis
  60217. * @param axis2 defines the second axis
  60218. * @param axis3 defines the third axis
  60219. * @param ref defines the target quaternion
  60220. */
  60221. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60222. /**
  60223. * Interpolates between two quaternions
  60224. * @param left defines first quaternion
  60225. * @param right defines second quaternion
  60226. * @param amount defines the gradient to use
  60227. * @returns the new interpolated quaternion
  60228. */
  60229. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60230. /**
  60231. * Interpolates between two quaternions and stores it into a target quaternion
  60232. * @param left defines first quaternion
  60233. * @param right defines second quaternion
  60234. * @param amount defines the gradient to use
  60235. * @param result defines the target quaternion
  60236. */
  60237. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60238. /**
  60239. * Interpolate between two quaternions using Hermite interpolation
  60240. * @param value1 defines first quaternion
  60241. * @param tangent1 defines the incoming tangent
  60242. * @param value2 defines second quaternion
  60243. * @param tangent2 defines the outgoing tangent
  60244. * @param amount defines the target quaternion
  60245. * @returns the new interpolated quaternion
  60246. */
  60247. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60248. }
  60249. /**
  60250. * Class used to store matrix data (4x4)
  60251. */
  60252. export class Matrix {
  60253. private static _updateFlagSeed;
  60254. private static _identityReadOnly;
  60255. private _isIdentity;
  60256. private _isIdentityDirty;
  60257. private _isIdentity3x2;
  60258. private _isIdentity3x2Dirty;
  60259. /**
  60260. * Gets the update flag of the matrix which is an unique number for the matrix.
  60261. * It will be incremented every time the matrix data change.
  60262. * You can use it to speed the comparison between two versions of the same matrix.
  60263. */
  60264. updateFlag: number;
  60265. private readonly _m;
  60266. /**
  60267. * Gets the internal data of the matrix
  60268. */
  60269. readonly m: DeepImmutable<Float32Array>;
  60270. /** @hidden */
  60271. _markAsUpdated(): void;
  60272. /** @hidden */
  60273. private _updateIdentityStatus;
  60274. /**
  60275. * Creates an empty matrix (filled with zeros)
  60276. */
  60277. constructor();
  60278. /**
  60279. * Check if the current matrix is identity
  60280. * @returns true is the matrix is the identity matrix
  60281. */
  60282. isIdentity(): boolean;
  60283. /**
  60284. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60285. * @returns true is the matrix is the identity matrix
  60286. */
  60287. isIdentityAs3x2(): boolean;
  60288. /**
  60289. * Gets the determinant of the matrix
  60290. * @returns the matrix determinant
  60291. */
  60292. determinant(): number;
  60293. /**
  60294. * Returns the matrix as a Float32Array
  60295. * @returns the matrix underlying array
  60296. */
  60297. toArray(): DeepImmutable<Float32Array>;
  60298. /**
  60299. * Returns the matrix as a Float32Array
  60300. * @returns the matrix underlying array.
  60301. */
  60302. asArray(): DeepImmutable<Float32Array>;
  60303. /**
  60304. * Inverts the current matrix in place
  60305. * @returns the current inverted matrix
  60306. */
  60307. invert(): Matrix;
  60308. /**
  60309. * Sets all the matrix elements to zero
  60310. * @returns the current matrix
  60311. */
  60312. reset(): Matrix;
  60313. /**
  60314. * Adds the current matrix with a second one
  60315. * @param other defines the matrix to add
  60316. * @returns a new matrix as the addition of the current matrix and the given one
  60317. */
  60318. add(other: DeepImmutable<Matrix>): Matrix;
  60319. /**
  60320. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60321. * @param other defines the matrix to add
  60322. * @param result defines the target matrix
  60323. * @returns the current matrix
  60324. */
  60325. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60326. /**
  60327. * Adds in place the given matrix to the current matrix
  60328. * @param other defines the second operand
  60329. * @returns the current updated matrix
  60330. */
  60331. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60332. /**
  60333. * Sets the given matrix to the current inverted Matrix
  60334. * @param other defines the target matrix
  60335. * @returns the unmodified current matrix
  60336. */
  60337. invertToRef(other: Matrix): Matrix;
  60338. /**
  60339. * add a value at the specified position in the current Matrix
  60340. * @param index the index of the value within the matrix. between 0 and 15.
  60341. * @param value the value to be added
  60342. * @returns the current updated matrix
  60343. */
  60344. addAtIndex(index: number, value: number): Matrix;
  60345. /**
  60346. * mutiply the specified position in the current Matrix by a value
  60347. * @param index the index of the value within the matrix. between 0 and 15.
  60348. * @param value the value to be added
  60349. * @returns the current updated matrix
  60350. */
  60351. multiplyAtIndex(index: number, value: number): Matrix;
  60352. /**
  60353. * Inserts the translation vector (using 3 floats) in the current matrix
  60354. * @param x defines the 1st component of the translation
  60355. * @param y defines the 2nd component of the translation
  60356. * @param z defines the 3rd component of the translation
  60357. * @returns the current updated matrix
  60358. */
  60359. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60360. /**
  60361. * Inserts the translation vector in the current matrix
  60362. * @param vector3 defines the translation to insert
  60363. * @returns the current updated matrix
  60364. */
  60365. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60366. /**
  60367. * Gets the translation value of the current matrix
  60368. * @returns a new Vector3 as the extracted translation from the matrix
  60369. */
  60370. getTranslation(): Vector3;
  60371. /**
  60372. * Fill a Vector3 with the extracted translation from the matrix
  60373. * @param result defines the Vector3 where to store the translation
  60374. * @returns the current matrix
  60375. */
  60376. getTranslationToRef(result: Vector3): Matrix;
  60377. /**
  60378. * Remove rotation and scaling part from the matrix
  60379. * @returns the updated matrix
  60380. */
  60381. removeRotationAndScaling(): Matrix;
  60382. /**
  60383. * Multiply two matrices
  60384. * @param other defines the second operand
  60385. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60386. */
  60387. multiply(other: DeepImmutable<Matrix>): Matrix;
  60388. /**
  60389. * Copy the current matrix from the given one
  60390. * @param other defines the source matrix
  60391. * @returns the current updated matrix
  60392. */
  60393. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60394. /**
  60395. * Populates the given array from the starting index with the current matrix values
  60396. * @param array defines the target array
  60397. * @param offset defines the offset in the target array where to start storing values
  60398. * @returns the current matrix
  60399. */
  60400. copyToArray(array: Float32Array, offset?: number): Matrix;
  60401. /**
  60402. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60403. * @param other defines the second operand
  60404. * @param result defines the matrix where to store the multiplication
  60405. * @returns the current matrix
  60406. */
  60407. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60408. /**
  60409. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60410. * @param other defines the second operand
  60411. * @param result defines the array where to store the multiplication
  60412. * @param offset defines the offset in the target array where to start storing values
  60413. * @returns the current matrix
  60414. */
  60415. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60416. /**
  60417. * Check equality between this matrix and a second one
  60418. * @param value defines the second matrix to compare
  60419. * @returns true is the current matrix and the given one values are strictly equal
  60420. */
  60421. equals(value: DeepImmutable<Matrix>): boolean;
  60422. /**
  60423. * Clone the current matrix
  60424. * @returns a new matrix from the current matrix
  60425. */
  60426. clone(): Matrix;
  60427. /**
  60428. * Returns the name of the current matrix class
  60429. * @returns the string "Matrix"
  60430. */
  60431. getClassName(): string;
  60432. /**
  60433. * Gets the hash code of the current matrix
  60434. * @returns the hash code
  60435. */
  60436. getHashCode(): number;
  60437. /**
  60438. * Decomposes the current Matrix into a translation, rotation and scaling components
  60439. * @param scale defines the scale vector3 given as a reference to update
  60440. * @param rotation defines the rotation quaternion given as a reference to update
  60441. * @param translation defines the translation vector3 given as a reference to update
  60442. * @returns true if operation was successful
  60443. */
  60444. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60445. /**
  60446. * Gets specific row of the matrix
  60447. * @param index defines the number of the row to get
  60448. * @returns the index-th row of the current matrix as a new Vector4
  60449. */
  60450. getRow(index: number): Nullable<Vector4>;
  60451. /**
  60452. * Sets the index-th row of the current matrix to the vector4 values
  60453. * @param index defines the number of the row to set
  60454. * @param row defines the target vector4
  60455. * @returns the updated current matrix
  60456. */
  60457. setRow(index: number, row: Vector4): Matrix;
  60458. /**
  60459. * Compute the transpose of the matrix
  60460. * @returns the new transposed matrix
  60461. */
  60462. transpose(): Matrix;
  60463. /**
  60464. * Compute the transpose of the matrix and store it in a given matrix
  60465. * @param result defines the target matrix
  60466. * @returns the current matrix
  60467. */
  60468. transposeToRef(result: Matrix): Matrix;
  60469. /**
  60470. * Sets the index-th row of the current matrix with the given 4 x float values
  60471. * @param index defines the row index
  60472. * @param x defines the x component to set
  60473. * @param y defines the y component to set
  60474. * @param z defines the z component to set
  60475. * @param w defines the w component to set
  60476. * @returns the updated current matrix
  60477. */
  60478. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60479. /**
  60480. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60481. * @param scale defines the scale factor
  60482. * @returns a new matrix
  60483. */
  60484. scale(scale: number): Matrix;
  60485. /**
  60486. * Scale the current matrix values by a factor to a given result matrix
  60487. * @param scale defines the scale factor
  60488. * @param result defines the matrix to store the result
  60489. * @returns the current matrix
  60490. */
  60491. scaleToRef(scale: number, result: Matrix): Matrix;
  60492. /**
  60493. * Scale the current matrix values by a factor and add the result to a given matrix
  60494. * @param scale defines the scale factor
  60495. * @param result defines the Matrix to store the result
  60496. * @returns the current matrix
  60497. */
  60498. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60499. /**
  60500. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60501. * @param ref matrix to store the result
  60502. */
  60503. toNormalMatrix(ref: Matrix): void;
  60504. /**
  60505. * Gets only rotation part of the current matrix
  60506. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60507. */
  60508. getRotationMatrix(): Matrix;
  60509. /**
  60510. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60511. * @param result defines the target matrix to store data to
  60512. * @returns the current matrix
  60513. */
  60514. getRotationMatrixToRef(result: Matrix): Matrix;
  60515. /**
  60516. * Toggles model matrix from being right handed to left handed in place and vice versa
  60517. */
  60518. toggleModelMatrixHandInPlace(): void;
  60519. /**
  60520. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60521. */
  60522. toggleProjectionMatrixHandInPlace(): void;
  60523. /**
  60524. * Creates a matrix from an array
  60525. * @param array defines the source array
  60526. * @param offset defines an offset in the source array
  60527. * @returns a new Matrix set from the starting index of the given array
  60528. */
  60529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60530. /**
  60531. * Copy the content of an array into a given matrix
  60532. * @param array defines the source array
  60533. * @param offset defines an offset in the source array
  60534. * @param result defines the target matrix
  60535. */
  60536. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60537. /**
  60538. * Stores an array into a matrix after having multiplied each component by a given factor
  60539. * @param array defines the source array
  60540. * @param offset defines the offset in the source array
  60541. * @param scale defines the scaling factor
  60542. * @param result defines the target matrix
  60543. */
  60544. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60545. /**
  60546. * Gets an identity matrix that must not be updated
  60547. */
  60548. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60549. /**
  60550. * Stores a list of values (16) inside a given matrix
  60551. * @param initialM11 defines 1st value of 1st row
  60552. * @param initialM12 defines 2nd value of 1st row
  60553. * @param initialM13 defines 3rd value of 1st row
  60554. * @param initialM14 defines 4th value of 1st row
  60555. * @param initialM21 defines 1st value of 2nd row
  60556. * @param initialM22 defines 2nd value of 2nd row
  60557. * @param initialM23 defines 3rd value of 2nd row
  60558. * @param initialM24 defines 4th value of 2nd row
  60559. * @param initialM31 defines 1st value of 3rd row
  60560. * @param initialM32 defines 2nd value of 3rd row
  60561. * @param initialM33 defines 3rd value of 3rd row
  60562. * @param initialM34 defines 4th value of 3rd row
  60563. * @param initialM41 defines 1st value of 4th row
  60564. * @param initialM42 defines 2nd value of 4th row
  60565. * @param initialM43 defines 3rd value of 4th row
  60566. * @param initialM44 defines 4th value of 4th row
  60567. * @param result defines the target matrix
  60568. */
  60569. 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;
  60570. /**
  60571. * Creates new matrix from a list of values (16)
  60572. * @param initialM11 defines 1st value of 1st row
  60573. * @param initialM12 defines 2nd value of 1st row
  60574. * @param initialM13 defines 3rd value of 1st row
  60575. * @param initialM14 defines 4th value of 1st row
  60576. * @param initialM21 defines 1st value of 2nd row
  60577. * @param initialM22 defines 2nd value of 2nd row
  60578. * @param initialM23 defines 3rd value of 2nd row
  60579. * @param initialM24 defines 4th value of 2nd row
  60580. * @param initialM31 defines 1st value of 3rd row
  60581. * @param initialM32 defines 2nd value of 3rd row
  60582. * @param initialM33 defines 3rd value of 3rd row
  60583. * @param initialM34 defines 4th value of 3rd row
  60584. * @param initialM41 defines 1st value of 4th row
  60585. * @param initialM42 defines 2nd value of 4th row
  60586. * @param initialM43 defines 3rd value of 4th row
  60587. * @param initialM44 defines 4th value of 4th row
  60588. * @returns the new matrix
  60589. */
  60590. 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;
  60591. /**
  60592. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60593. * @param scale defines the scale vector3
  60594. * @param rotation defines the rotation quaternion
  60595. * @param translation defines the translation vector3
  60596. * @returns a new matrix
  60597. */
  60598. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60599. /**
  60600. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60601. * @param scale defines the scale vector3
  60602. * @param rotation defines the rotation quaternion
  60603. * @param translation defines the translation vector3
  60604. * @param result defines the target matrix
  60605. */
  60606. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60607. /**
  60608. * Creates a new identity matrix
  60609. * @returns a new identity matrix
  60610. */
  60611. static Identity(): Matrix;
  60612. /**
  60613. * Creates a new identity matrix and stores the result in a given matrix
  60614. * @param result defines the target matrix
  60615. */
  60616. static IdentityToRef(result: Matrix): void;
  60617. /**
  60618. * Creates a new zero matrix
  60619. * @returns a new zero matrix
  60620. */
  60621. static Zero(): Matrix;
  60622. /**
  60623. * Creates a new rotation matrix for "angle" radians around the X axis
  60624. * @param angle defines the angle (in radians) to use
  60625. * @return the new matrix
  60626. */
  60627. static RotationX(angle: number): Matrix;
  60628. /**
  60629. * Creates a new matrix as the invert of a given matrix
  60630. * @param source defines the source matrix
  60631. * @returns the new matrix
  60632. */
  60633. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60634. /**
  60635. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60636. * @param angle defines the angle (in radians) to use
  60637. * @param result defines the target matrix
  60638. */
  60639. static RotationXToRef(angle: number, result: Matrix): void;
  60640. /**
  60641. * Creates a new rotation matrix for "angle" radians around the Y axis
  60642. * @param angle defines the angle (in radians) to use
  60643. * @return the new matrix
  60644. */
  60645. static RotationY(angle: number): Matrix;
  60646. /**
  60647. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60648. * @param angle defines the angle (in radians) to use
  60649. * @param result defines the target matrix
  60650. */
  60651. static RotationYToRef(angle: number, result: Matrix): void;
  60652. /**
  60653. * Creates a new rotation matrix for "angle" radians around the Z axis
  60654. * @param angle defines the angle (in radians) to use
  60655. * @return the new matrix
  60656. */
  60657. static RotationZ(angle: number): Matrix;
  60658. /**
  60659. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60660. * @param angle defines the angle (in radians) to use
  60661. * @param result defines the target matrix
  60662. */
  60663. static RotationZToRef(angle: number, result: Matrix): void;
  60664. /**
  60665. * Creates a new rotation matrix for "angle" radians around the given axis
  60666. * @param axis defines the axis to use
  60667. * @param angle defines the angle (in radians) to use
  60668. * @return the new matrix
  60669. */
  60670. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60671. /**
  60672. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60673. * @param axis defines the axis to use
  60674. * @param angle defines the angle (in radians) to use
  60675. * @param result defines the target matrix
  60676. */
  60677. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60678. /**
  60679. * Creates a rotation matrix
  60680. * @param yaw defines the yaw angle in radians (Y axis)
  60681. * @param pitch defines the pitch angle in radians (X axis)
  60682. * @param roll defines the roll angle in radians (X axis)
  60683. * @returns the new rotation matrix
  60684. */
  60685. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60686. /**
  60687. * Creates a rotation matrix and stores it in a given matrix
  60688. * @param yaw defines the yaw angle in radians (Y axis)
  60689. * @param pitch defines the pitch angle in radians (X axis)
  60690. * @param roll defines the roll angle in radians (X axis)
  60691. * @param result defines the target matrix
  60692. */
  60693. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60694. /**
  60695. * Creates a scaling matrix
  60696. * @param x defines the scale factor on X axis
  60697. * @param y defines the scale factor on Y axis
  60698. * @param z defines the scale factor on Z axis
  60699. * @returns the new matrix
  60700. */
  60701. static Scaling(x: number, y: number, z: number): Matrix;
  60702. /**
  60703. * Creates a scaling matrix and stores it in a given matrix
  60704. * @param x defines the scale factor on X axis
  60705. * @param y defines the scale factor on Y axis
  60706. * @param z defines the scale factor on Z axis
  60707. * @param result defines the target matrix
  60708. */
  60709. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60710. /**
  60711. * Creates a translation matrix
  60712. * @param x defines the translation on X axis
  60713. * @param y defines the translation on Y axis
  60714. * @param z defines the translationon Z axis
  60715. * @returns the new matrix
  60716. */
  60717. static Translation(x: number, y: number, z: number): Matrix;
  60718. /**
  60719. * Creates a translation matrix and stores it in a given matrix
  60720. * @param x defines the translation on X axis
  60721. * @param y defines the translation on Y axis
  60722. * @param z defines the translationon Z axis
  60723. * @param result defines the target matrix
  60724. */
  60725. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60726. /**
  60727. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60728. * @param startValue defines the start value
  60729. * @param endValue defines the end value
  60730. * @param gradient defines the gradient factor
  60731. * @returns the new matrix
  60732. */
  60733. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60734. /**
  60735. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60736. * @param startValue defines the start value
  60737. * @param endValue defines the end value
  60738. * @param gradient defines the gradient factor
  60739. * @param result defines the Matrix object where to store data
  60740. */
  60741. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60742. /**
  60743. * Builds a new matrix whose values are computed by:
  60744. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60745. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60746. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60747. * @param startValue defines the first matrix
  60748. * @param endValue defines the second matrix
  60749. * @param gradient defines the gradient between the two matrices
  60750. * @returns the new matrix
  60751. */
  60752. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60753. /**
  60754. * Update a matrix to values which are computed by:
  60755. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60756. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60757. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60758. * @param startValue defines the first matrix
  60759. * @param endValue defines the second matrix
  60760. * @param gradient defines the gradient between the two matrices
  60761. * @param result defines the target matrix
  60762. */
  60763. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60764. /**
  60765. * 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"
  60766. * This function works in left handed mode
  60767. * @param eye defines the final position of the entity
  60768. * @param target defines where the entity should look at
  60769. * @param up defines the up vector for the entity
  60770. * @returns the new matrix
  60771. */
  60772. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60773. /**
  60774. * 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".
  60775. * This function works in left handed mode
  60776. * @param eye defines the final position of the entity
  60777. * @param target defines where the entity should look at
  60778. * @param up defines the up vector for the entity
  60779. * @param result defines the target matrix
  60780. */
  60781. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60782. /**
  60783. * 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"
  60784. * This function works in right handed mode
  60785. * @param eye defines the final position of the entity
  60786. * @param target defines where the entity should look at
  60787. * @param up defines the up vector for the entity
  60788. * @returns the new matrix
  60789. */
  60790. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60791. /**
  60792. * 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".
  60793. * This function works in right handed mode
  60794. * @param eye defines the final position of the entity
  60795. * @param target defines where the entity should look at
  60796. * @param up defines the up vector for the entity
  60797. * @param result defines the target matrix
  60798. */
  60799. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60800. /**
  60801. * Create a left-handed orthographic projection matrix
  60802. * @param width defines the viewport width
  60803. * @param height defines the viewport height
  60804. * @param znear defines the near clip plane
  60805. * @param zfar defines the far clip plane
  60806. * @returns a new matrix as a left-handed orthographic projection matrix
  60807. */
  60808. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60809. /**
  60810. * Store a left-handed orthographic projection to a given matrix
  60811. * @param width defines the viewport width
  60812. * @param height defines the viewport height
  60813. * @param znear defines the near clip plane
  60814. * @param zfar defines the far clip plane
  60815. * @param result defines the target matrix
  60816. */
  60817. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60818. /**
  60819. * Create a left-handed orthographic projection matrix
  60820. * @param left defines the viewport left coordinate
  60821. * @param right defines the viewport right coordinate
  60822. * @param bottom defines the viewport bottom coordinate
  60823. * @param top defines the viewport top coordinate
  60824. * @param znear defines the near clip plane
  60825. * @param zfar defines the far clip plane
  60826. * @returns a new matrix as a left-handed orthographic projection matrix
  60827. */
  60828. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60829. /**
  60830. * Stores a left-handed orthographic projection into a given matrix
  60831. * @param left defines the viewport left coordinate
  60832. * @param right defines the viewport right coordinate
  60833. * @param bottom defines the viewport bottom coordinate
  60834. * @param top defines the viewport top coordinate
  60835. * @param znear defines the near clip plane
  60836. * @param zfar defines the far clip plane
  60837. * @param result defines the target matrix
  60838. */
  60839. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60840. /**
  60841. * Creates a right-handed orthographic projection matrix
  60842. * @param left defines the viewport left coordinate
  60843. * @param right defines the viewport right coordinate
  60844. * @param bottom defines the viewport bottom coordinate
  60845. * @param top defines the viewport top coordinate
  60846. * @param znear defines the near clip plane
  60847. * @param zfar defines the far clip plane
  60848. * @returns a new matrix as a right-handed orthographic projection matrix
  60849. */
  60850. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60851. /**
  60852. * Stores a right-handed orthographic projection into a given matrix
  60853. * @param left defines the viewport left coordinate
  60854. * @param right defines the viewport right coordinate
  60855. * @param bottom defines the viewport bottom coordinate
  60856. * @param top defines the viewport top coordinate
  60857. * @param znear defines the near clip plane
  60858. * @param zfar defines the far clip plane
  60859. * @param result defines the target matrix
  60860. */
  60861. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60862. /**
  60863. * Creates a left-handed perspective projection matrix
  60864. * @param width defines the viewport width
  60865. * @param height defines the viewport height
  60866. * @param znear defines the near clip plane
  60867. * @param zfar defines the far clip plane
  60868. * @returns a new matrix as a left-handed perspective projection matrix
  60869. */
  60870. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60871. /**
  60872. * Creates a left-handed perspective projection matrix
  60873. * @param fov defines the horizontal field of view
  60874. * @param aspect defines the aspect ratio
  60875. * @param znear defines the near clip plane
  60876. * @param zfar defines the far clip plane
  60877. * @returns a new matrix as a left-handed perspective projection matrix
  60878. */
  60879. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60880. /**
  60881. * Stores a left-handed perspective projection into a given matrix
  60882. * @param fov defines the horizontal field of view
  60883. * @param aspect defines the aspect ratio
  60884. * @param znear defines the near clip plane
  60885. * @param zfar defines the far clip plane
  60886. * @param result defines the target matrix
  60887. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60888. */
  60889. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60890. /**
  60891. * Creates a right-handed perspective projection matrix
  60892. * @param fov defines the horizontal field of view
  60893. * @param aspect defines the aspect ratio
  60894. * @param znear defines the near clip plane
  60895. * @param zfar defines the far clip plane
  60896. * @returns a new matrix as a right-handed perspective projection matrix
  60897. */
  60898. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60899. /**
  60900. * Stores a right-handed perspective projection into a given matrix
  60901. * @param fov defines the horizontal field of view
  60902. * @param aspect defines the aspect ratio
  60903. * @param znear defines the near clip plane
  60904. * @param zfar defines the far clip plane
  60905. * @param result defines the target matrix
  60906. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60907. */
  60908. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60909. /**
  60910. * Stores a perspective projection for WebVR info a given matrix
  60911. * @param fov defines the field of view
  60912. * @param znear defines the near clip plane
  60913. * @param zfar defines the far clip plane
  60914. * @param result defines the target matrix
  60915. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60916. */
  60917. static PerspectiveFovWebVRToRef(fov: {
  60918. upDegrees: number;
  60919. downDegrees: number;
  60920. leftDegrees: number;
  60921. rightDegrees: number;
  60922. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60923. /**
  60924. * Computes a complete transformation matrix
  60925. * @param viewport defines the viewport to use
  60926. * @param world defines the world matrix
  60927. * @param view defines the view matrix
  60928. * @param projection defines the projection matrix
  60929. * @param zmin defines the near clip plane
  60930. * @param zmax defines the far clip plane
  60931. * @returns the transformation matrix
  60932. */
  60933. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60934. /**
  60935. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60936. * @param matrix defines the matrix to use
  60937. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60938. */
  60939. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60940. /**
  60941. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60942. * @param matrix defines the matrix to use
  60943. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60944. */
  60945. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60946. /**
  60947. * Compute the transpose of a given matrix
  60948. * @param matrix defines the matrix to transpose
  60949. * @returns the new matrix
  60950. */
  60951. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60952. /**
  60953. * Compute the transpose of a matrix and store it in a target matrix
  60954. * @param matrix defines the matrix to transpose
  60955. * @param result defines the target matrix
  60956. */
  60957. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60958. /**
  60959. * Computes a reflection matrix from a plane
  60960. * @param plane defines the reflection plane
  60961. * @returns a new matrix
  60962. */
  60963. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60964. /**
  60965. * Computes a reflection matrix from a plane
  60966. * @param plane defines the reflection plane
  60967. * @param result defines the target matrix
  60968. */
  60969. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60970. /**
  60971. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60972. * @param xaxis defines the value of the 1st axis
  60973. * @param yaxis defines the value of the 2nd axis
  60974. * @param zaxis defines the value of the 3rd axis
  60975. * @param result defines the target matrix
  60976. */
  60977. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60978. /**
  60979. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60980. * @param quat defines the quaternion to use
  60981. * @param result defines the target matrix
  60982. */
  60983. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60984. }
  60985. /**
  60986. * Represens a plane by the equation ax + by + cz + d = 0
  60987. */
  60988. export class Plane {
  60989. /**
  60990. * Normal of the plane (a,b,c)
  60991. */
  60992. normal: Vector3;
  60993. /**
  60994. * d component of the plane
  60995. */
  60996. d: number;
  60997. /**
  60998. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60999. * @param a a component of the plane
  61000. * @param b b component of the plane
  61001. * @param c c component of the plane
  61002. * @param d d component of the plane
  61003. */
  61004. constructor(a: number, b: number, c: number, d: number);
  61005. /**
  61006. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61007. */
  61008. asArray(): number[];
  61009. /**
  61010. * @returns a new plane copied from the current Plane.
  61011. */
  61012. clone(): Plane;
  61013. /**
  61014. * @returns the string "Plane".
  61015. */
  61016. getClassName(): string;
  61017. /**
  61018. * @returns the Plane hash code.
  61019. */
  61020. getHashCode(): number;
  61021. /**
  61022. * Normalize the current Plane in place.
  61023. * @returns the updated Plane.
  61024. */
  61025. normalize(): Plane;
  61026. /**
  61027. * Applies a transformation the plane and returns the result
  61028. * @param transformation the transformation matrix to be applied to the plane
  61029. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61030. */
  61031. transform(transformation: DeepImmutable<Matrix>): Plane;
  61032. /**
  61033. * Calcualtte the dot product between the point and the plane normal
  61034. * @param point point to calculate the dot product with
  61035. * @returns the dot product (float) of the point coordinates and the plane normal.
  61036. */
  61037. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61038. /**
  61039. * Updates the current Plane from the plane defined by the three given points.
  61040. * @param point1 one of the points used to contruct the plane
  61041. * @param point2 one of the points used to contruct the plane
  61042. * @param point3 one of the points used to contruct the plane
  61043. * @returns the updated Plane.
  61044. */
  61045. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61046. /**
  61047. * Checks if the plane is facing a given direction
  61048. * @param direction the direction to check if the plane is facing
  61049. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61050. * @returns True is the vector "direction" is the same side than the plane normal.
  61051. */
  61052. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61053. /**
  61054. * Calculates the distance to a point
  61055. * @param point point to calculate distance to
  61056. * @returns the signed distance (float) from the given point to the Plane.
  61057. */
  61058. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61059. /**
  61060. * Creates a plane from an array
  61061. * @param array the array to create a plane from
  61062. * @returns a new Plane from the given array.
  61063. */
  61064. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61065. /**
  61066. * Creates a plane from three points
  61067. * @param point1 point used to create the plane
  61068. * @param point2 point used to create the plane
  61069. * @param point3 point used to create the plane
  61070. * @returns a new Plane defined by the three given points.
  61071. */
  61072. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61073. /**
  61074. * Creates a plane from an origin point and a normal
  61075. * @param origin origin of the plane to be constructed
  61076. * @param normal normal of the plane to be constructed
  61077. * @returns a new Plane the normal vector to this plane at the given origin point.
  61078. * Note : the vector "normal" is updated because normalized.
  61079. */
  61080. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61081. /**
  61082. * Calculates the distance from a plane and a point
  61083. * @param origin origin of the plane to be constructed
  61084. * @param normal normal of the plane to be constructed
  61085. * @param point point to calculate distance to
  61086. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61087. */
  61088. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61089. }
  61090. /**
  61091. * Class used to represent a viewport on screen
  61092. */
  61093. export class Viewport {
  61094. /** viewport left coordinate */
  61095. x: number;
  61096. /** viewport top coordinate */
  61097. y: number;
  61098. /**viewport width */
  61099. width: number;
  61100. /** viewport height */
  61101. height: number;
  61102. /**
  61103. * Creates a Viewport object located at (x, y) and sized (width, height)
  61104. * @param x defines viewport left coordinate
  61105. * @param y defines viewport top coordinate
  61106. * @param width defines the viewport width
  61107. * @param height defines the viewport height
  61108. */
  61109. constructor(
  61110. /** viewport left coordinate */
  61111. x: number,
  61112. /** viewport top coordinate */
  61113. y: number,
  61114. /**viewport width */
  61115. width: number,
  61116. /** viewport height */
  61117. height: number);
  61118. /**
  61119. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61120. * @param renderWidth defines the rendering width
  61121. * @param renderHeight defines the rendering height
  61122. * @returns a new Viewport
  61123. */
  61124. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61125. /**
  61126. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61127. * @param renderWidth defines the rendering width
  61128. * @param renderHeight defines the rendering height
  61129. * @param ref defines the target viewport
  61130. * @returns the current viewport
  61131. */
  61132. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61133. /**
  61134. * Returns a new Viewport copied from the current one
  61135. * @returns a new Viewport
  61136. */
  61137. clone(): Viewport;
  61138. }
  61139. /**
  61140. * Reprasents a camera frustum
  61141. */
  61142. export class Frustum {
  61143. /**
  61144. * Gets the planes representing the frustum
  61145. * @param transform matrix to be applied to the returned planes
  61146. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61147. */
  61148. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61149. /**
  61150. * Gets the near frustum plane transformed by the transform matrix
  61151. * @param transform transformation matrix to be applied to the resulting frustum plane
  61152. * @param frustumPlane the resuling frustum plane
  61153. */
  61154. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61155. /**
  61156. * Gets the far frustum plane transformed by the transform matrix
  61157. * @param transform transformation matrix to be applied to the resulting frustum plane
  61158. * @param frustumPlane the resuling frustum plane
  61159. */
  61160. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61161. /**
  61162. * Gets the left frustum plane transformed by the transform matrix
  61163. * @param transform transformation matrix to be applied to the resulting frustum plane
  61164. * @param frustumPlane the resuling frustum plane
  61165. */
  61166. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61167. /**
  61168. * Gets the right frustum plane transformed by the transform matrix
  61169. * @param transform transformation matrix to be applied to the resulting frustum plane
  61170. * @param frustumPlane the resuling frustum plane
  61171. */
  61172. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61173. /**
  61174. * Gets the top frustum plane transformed by the transform matrix
  61175. * @param transform transformation matrix to be applied to the resulting frustum plane
  61176. * @param frustumPlane the resuling frustum plane
  61177. */
  61178. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61179. /**
  61180. * Gets the bottom frustum plane transformed by the transform matrix
  61181. * @param transform transformation matrix to be applied to the resulting frustum plane
  61182. * @param frustumPlane the resuling frustum plane
  61183. */
  61184. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61185. /**
  61186. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61187. * @param transform transformation matrix to be applied to the resulting frustum planes
  61188. * @param frustumPlanes the resuling frustum planes
  61189. */
  61190. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61191. }
  61192. /** Defines supported spaces */
  61193. export enum Space {
  61194. /** Local (object) space */
  61195. LOCAL = 0,
  61196. /** World space */
  61197. WORLD = 1,
  61198. /** Bone space */
  61199. BONE = 2
  61200. }
  61201. /** Defines the 3 main axes */
  61202. export class Axis {
  61203. /** X axis */
  61204. static X: Vector3;
  61205. /** Y axis */
  61206. static Y: Vector3;
  61207. /** Z axis */
  61208. static Z: Vector3;
  61209. }
  61210. /** Class used to represent a Bezier curve */
  61211. export class BezierCurve {
  61212. /**
  61213. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61214. * @param t defines the time
  61215. * @param x1 defines the left coordinate on X axis
  61216. * @param y1 defines the left coordinate on Y axis
  61217. * @param x2 defines the right coordinate on X axis
  61218. * @param y2 defines the right coordinate on Y axis
  61219. * @returns the interpolated value
  61220. */
  61221. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61222. }
  61223. /**
  61224. * Defines potential orientation for back face culling
  61225. */
  61226. export enum Orientation {
  61227. /**
  61228. * Clockwise
  61229. */
  61230. CW = 0,
  61231. /** Counter clockwise */
  61232. CCW = 1
  61233. }
  61234. /**
  61235. * Defines angle representation
  61236. */
  61237. export class Angle {
  61238. private _radians;
  61239. /**
  61240. * Creates an Angle object of "radians" radians (float).
  61241. * @param radians the angle in radians
  61242. */
  61243. constructor(radians: number);
  61244. /**
  61245. * Get value in degrees
  61246. * @returns the Angle value in degrees (float)
  61247. */
  61248. degrees(): number;
  61249. /**
  61250. * Get value in radians
  61251. * @returns the Angle value in radians (float)
  61252. */
  61253. radians(): number;
  61254. /**
  61255. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61256. * @param a defines first vector
  61257. * @param b defines second vector
  61258. * @returns a new Angle
  61259. */
  61260. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61261. /**
  61262. * Gets a new Angle object from the given float in radians
  61263. * @param radians defines the angle value in radians
  61264. * @returns a new Angle
  61265. */
  61266. static FromRadians(radians: number): Angle;
  61267. /**
  61268. * Gets a new Angle object from the given float in degrees
  61269. * @param degrees defines the angle value in degrees
  61270. * @returns a new Angle
  61271. */
  61272. static FromDegrees(degrees: number): Angle;
  61273. }
  61274. /**
  61275. * This represents an arc in a 2d space.
  61276. */
  61277. export class Arc2 {
  61278. /** Defines the start point of the arc */
  61279. startPoint: Vector2;
  61280. /** Defines the mid point of the arc */
  61281. midPoint: Vector2;
  61282. /** Defines the end point of the arc */
  61283. endPoint: Vector2;
  61284. /**
  61285. * Defines the center point of the arc.
  61286. */
  61287. centerPoint: Vector2;
  61288. /**
  61289. * Defines the radius of the arc.
  61290. */
  61291. radius: number;
  61292. /**
  61293. * Defines the angle of the arc (from mid point to end point).
  61294. */
  61295. angle: Angle;
  61296. /**
  61297. * Defines the start angle of the arc (from start point to middle point).
  61298. */
  61299. startAngle: Angle;
  61300. /**
  61301. * Defines the orientation of the arc (clock wise/counter clock wise).
  61302. */
  61303. orientation: Orientation;
  61304. /**
  61305. * Creates an Arc object from the three given points : start, middle and end.
  61306. * @param startPoint Defines the start point of the arc
  61307. * @param midPoint Defines the midlle point of the arc
  61308. * @param endPoint Defines the end point of the arc
  61309. */
  61310. constructor(
  61311. /** Defines the start point of the arc */
  61312. startPoint: Vector2,
  61313. /** Defines the mid point of the arc */
  61314. midPoint: Vector2,
  61315. /** Defines the end point of the arc */
  61316. endPoint: Vector2);
  61317. }
  61318. /**
  61319. * Represents a 2D path made up of multiple 2D points
  61320. */
  61321. export class Path2 {
  61322. private _points;
  61323. private _length;
  61324. /**
  61325. * If the path start and end point are the same
  61326. */
  61327. closed: boolean;
  61328. /**
  61329. * Creates a Path2 object from the starting 2D coordinates x and y.
  61330. * @param x the starting points x value
  61331. * @param y the starting points y value
  61332. */
  61333. constructor(x: number, y: number);
  61334. /**
  61335. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61336. * @param x the added points x value
  61337. * @param y the added points y value
  61338. * @returns the updated Path2.
  61339. */
  61340. addLineTo(x: number, y: number): Path2;
  61341. /**
  61342. * 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.
  61343. * @param midX middle point x value
  61344. * @param midY middle point y value
  61345. * @param endX end point x value
  61346. * @param endY end point y value
  61347. * @param numberOfSegments (default: 36)
  61348. * @returns the updated Path2.
  61349. */
  61350. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61351. /**
  61352. * Closes the Path2.
  61353. * @returns the Path2.
  61354. */
  61355. close(): Path2;
  61356. /**
  61357. * Gets the sum of the distance between each sequential point in the path
  61358. * @returns the Path2 total length (float).
  61359. */
  61360. length(): number;
  61361. /**
  61362. * Gets the points which construct the path
  61363. * @returns the Path2 internal array of points.
  61364. */
  61365. getPoints(): Vector2[];
  61366. /**
  61367. * Retreives the point at the distance aways from the starting point
  61368. * @param normalizedLengthPosition the length along the path to retreive the point from
  61369. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61370. */
  61371. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61372. /**
  61373. * Creates a new path starting from an x and y position
  61374. * @param x starting x value
  61375. * @param y starting y value
  61376. * @returns a new Path2 starting at the coordinates (x, y).
  61377. */
  61378. static StartingAt(x: number, y: number): Path2;
  61379. }
  61380. /**
  61381. * Represents a 3D path made up of multiple 3D points
  61382. */
  61383. export class Path3D {
  61384. /**
  61385. * an array of Vector3, the curve axis of the Path3D
  61386. */
  61387. path: Vector3[];
  61388. private _curve;
  61389. private _distances;
  61390. private _tangents;
  61391. private _normals;
  61392. private _binormals;
  61393. private _raw;
  61394. /**
  61395. * new Path3D(path, normal, raw)
  61396. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61397. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61398. * @param path an array of Vector3, the curve axis of the Path3D
  61399. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61400. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61401. */
  61402. constructor(
  61403. /**
  61404. * an array of Vector3, the curve axis of the Path3D
  61405. */
  61406. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61407. /**
  61408. * Returns the Path3D array of successive Vector3 designing its curve.
  61409. * @returns the Path3D array of successive Vector3 designing its curve.
  61410. */
  61411. getCurve(): Vector3[];
  61412. /**
  61413. * Returns an array populated with tangent vectors on each Path3D curve point.
  61414. * @returns an array populated with tangent vectors on each Path3D curve point.
  61415. */
  61416. getTangents(): Vector3[];
  61417. /**
  61418. * Returns an array populated with normal vectors on each Path3D curve point.
  61419. * @returns an array populated with normal vectors on each Path3D curve point.
  61420. */
  61421. getNormals(): Vector3[];
  61422. /**
  61423. * Returns an array populated with binormal vectors on each Path3D curve point.
  61424. * @returns an array populated with binormal vectors on each Path3D curve point.
  61425. */
  61426. getBinormals(): Vector3[];
  61427. /**
  61428. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61429. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61430. */
  61431. getDistances(): number[];
  61432. /**
  61433. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61434. * @param path path which all values are copied into the curves points
  61435. * @param firstNormal which should be projected onto the curve
  61436. * @returns the same object updated.
  61437. */
  61438. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61439. private _compute;
  61440. private _getFirstNonNullVector;
  61441. private _getLastNonNullVector;
  61442. private _normalVector;
  61443. }
  61444. /**
  61445. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61446. * A Curve3 is designed from a series of successive Vector3.
  61447. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61448. */
  61449. export class Curve3 {
  61450. private _points;
  61451. private _length;
  61452. /**
  61453. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61454. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61455. * @param v1 (Vector3) the control point
  61456. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61457. * @param nbPoints (integer) the wanted number of points in the curve
  61458. * @returns the created Curve3
  61459. */
  61460. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61461. /**
  61462. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61463. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61464. * @param v1 (Vector3) the first control point
  61465. * @param v2 (Vector3) the second control point
  61466. * @param v3 (Vector3) the end point of the Cubic Bezier
  61467. * @param nbPoints (integer) the wanted number of points in the curve
  61468. * @returns the created Curve3
  61469. */
  61470. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61471. /**
  61472. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61473. * @param p1 (Vector3) the origin point of the Hermite Spline
  61474. * @param t1 (Vector3) the tangent vector at the origin point
  61475. * @param p2 (Vector3) the end point of the Hermite Spline
  61476. * @param t2 (Vector3) the tangent vector at the end point
  61477. * @param nbPoints (integer) the wanted number of points in the curve
  61478. * @returns the created Curve3
  61479. */
  61480. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61481. /**
  61482. * Returns a Curve3 object along a CatmullRom Spline curve :
  61483. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61484. * @param nbPoints (integer) the wanted number of points between each curve control points
  61485. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61486. * @returns the created Curve3
  61487. */
  61488. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61489. /**
  61490. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61491. * A Curve3 is designed from a series of successive Vector3.
  61492. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61493. * @param points points which make up the curve
  61494. */
  61495. constructor(points: Vector3[]);
  61496. /**
  61497. * @returns the Curve3 stored array of successive Vector3
  61498. */
  61499. getPoints(): Vector3[];
  61500. /**
  61501. * @returns the computed length (float) of the curve.
  61502. */
  61503. length(): number;
  61504. /**
  61505. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61506. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61507. * curveA and curveB keep unchanged.
  61508. * @param curve the curve to continue from this curve
  61509. * @returns the newly constructed curve
  61510. */
  61511. continue(curve: DeepImmutable<Curve3>): Curve3;
  61512. private _computeLength;
  61513. }
  61514. /**
  61515. * Contains position and normal vectors for a vertex
  61516. */
  61517. export class PositionNormalVertex {
  61518. /** the position of the vertex (defaut: 0,0,0) */
  61519. position: Vector3;
  61520. /** the normal of the vertex (defaut: 0,1,0) */
  61521. normal: Vector3;
  61522. /**
  61523. * Creates a PositionNormalVertex
  61524. * @param position the position of the vertex (defaut: 0,0,0)
  61525. * @param normal the normal of the vertex (defaut: 0,1,0)
  61526. */
  61527. constructor(
  61528. /** the position of the vertex (defaut: 0,0,0) */
  61529. position?: Vector3,
  61530. /** the normal of the vertex (defaut: 0,1,0) */
  61531. normal?: Vector3);
  61532. /**
  61533. * Clones the PositionNormalVertex
  61534. * @returns the cloned PositionNormalVertex
  61535. */
  61536. clone(): PositionNormalVertex;
  61537. }
  61538. /**
  61539. * Contains position, normal and uv vectors for a vertex
  61540. */
  61541. export class PositionNormalTextureVertex {
  61542. /** the position of the vertex (defaut: 0,0,0) */
  61543. position: Vector3;
  61544. /** the normal of the vertex (defaut: 0,1,0) */
  61545. normal: Vector3;
  61546. /** the uv of the vertex (default: 0,0) */
  61547. uv: Vector2;
  61548. /**
  61549. * Creates a PositionNormalTextureVertex
  61550. * @param position the position of the vertex (defaut: 0,0,0)
  61551. * @param normal the normal of the vertex (defaut: 0,1,0)
  61552. * @param uv the uv of the vertex (default: 0,0)
  61553. */
  61554. constructor(
  61555. /** the position of the vertex (defaut: 0,0,0) */
  61556. position?: Vector3,
  61557. /** the normal of the vertex (defaut: 0,1,0) */
  61558. normal?: Vector3,
  61559. /** the uv of the vertex (default: 0,0) */
  61560. uv?: Vector2);
  61561. /**
  61562. * Clones the PositionNormalTextureVertex
  61563. * @returns the cloned PositionNormalTextureVertex
  61564. */
  61565. clone(): PositionNormalTextureVertex;
  61566. }
  61567. /**
  61568. * @hidden
  61569. */
  61570. export class Tmp {
  61571. static Color3: Color3[];
  61572. static Color4: Color4[];
  61573. static Vector2: Vector2[];
  61574. static Vector3: Vector3[];
  61575. static Vector4: Vector4[];
  61576. static Quaternion: Quaternion[];
  61577. static Matrix: Matrix[];
  61578. }
  61579. }
  61580. declare module BABYLON {
  61581. /**
  61582. * Class used to enable access to offline support
  61583. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61584. */
  61585. export interface IOfflineProvider {
  61586. /**
  61587. * Gets a boolean indicating if scene must be saved in the database
  61588. */
  61589. enableSceneOffline: boolean;
  61590. /**
  61591. * Gets a boolean indicating if textures must be saved in the database
  61592. */
  61593. enableTexturesOffline: boolean;
  61594. /**
  61595. * Open the offline support and make it available
  61596. * @param successCallback defines the callback to call on success
  61597. * @param errorCallback defines the callback to call on error
  61598. */
  61599. open(successCallback: () => void, errorCallback: () => void): void;
  61600. /**
  61601. * Loads an image from the offline support
  61602. * @param url defines the url to load from
  61603. * @param image defines the target DOM image
  61604. */
  61605. loadImage(url: string, image: HTMLImageElement): void;
  61606. /**
  61607. * Loads a file from offline support
  61608. * @param url defines the URL to load from
  61609. * @param sceneLoaded defines a callback to call on success
  61610. * @param progressCallBack defines a callback to call when progress changed
  61611. * @param errorCallback defines a callback to call on error
  61612. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61613. */
  61614. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61615. }
  61616. }
  61617. declare module BABYLON {
  61618. /**
  61619. * A class serves as a medium between the observable and its observers
  61620. */
  61621. export class EventState {
  61622. /**
  61623. * Create a new EventState
  61624. * @param mask defines the mask associated with this state
  61625. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61626. * @param target defines the original target of the state
  61627. * @param currentTarget defines the current target of the state
  61628. */
  61629. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61630. /**
  61631. * Initialize the current event state
  61632. * @param mask defines the mask associated with this state
  61633. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61634. * @param target defines the original target of the state
  61635. * @param currentTarget defines the current target of the state
  61636. * @returns the current event state
  61637. */
  61638. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61639. /**
  61640. * An Observer can set this property to true to prevent subsequent observers of being notified
  61641. */
  61642. skipNextObservers: boolean;
  61643. /**
  61644. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61645. */
  61646. mask: number;
  61647. /**
  61648. * The object that originally notified the event
  61649. */
  61650. target?: any;
  61651. /**
  61652. * The current object in the bubbling phase
  61653. */
  61654. currentTarget?: any;
  61655. /**
  61656. * This will be populated with the return value of the last function that was executed.
  61657. * If it is the first function in the callback chain it will be the event data.
  61658. */
  61659. lastReturnValue?: any;
  61660. }
  61661. /**
  61662. * Represent an Observer registered to a given Observable object.
  61663. */
  61664. export class Observer<T> {
  61665. /**
  61666. * Defines the callback to call when the observer is notified
  61667. */
  61668. callback: (eventData: T, eventState: EventState) => void;
  61669. /**
  61670. * Defines the mask of the observer (used to filter notifications)
  61671. */
  61672. mask: number;
  61673. /**
  61674. * Defines the current scope used to restore the JS context
  61675. */
  61676. scope: any;
  61677. /** @hidden */
  61678. _willBeUnregistered: boolean;
  61679. /**
  61680. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61681. */
  61682. unregisterOnNextCall: boolean;
  61683. /**
  61684. * Creates a new observer
  61685. * @param callback defines the callback to call when the observer is notified
  61686. * @param mask defines the mask of the observer (used to filter notifications)
  61687. * @param scope defines the current scope used to restore the JS context
  61688. */
  61689. constructor(
  61690. /**
  61691. * Defines the callback to call when the observer is notified
  61692. */
  61693. callback: (eventData: T, eventState: EventState) => void,
  61694. /**
  61695. * Defines the mask of the observer (used to filter notifications)
  61696. */
  61697. mask: number,
  61698. /**
  61699. * Defines the current scope used to restore the JS context
  61700. */
  61701. scope?: any);
  61702. }
  61703. /**
  61704. * Represent a list of observers registered to multiple Observables object.
  61705. */
  61706. export class MultiObserver<T> {
  61707. private _observers;
  61708. private _observables;
  61709. /**
  61710. * Release associated resources
  61711. */
  61712. dispose(): void;
  61713. /**
  61714. * Raise a callback when one of the observable will notify
  61715. * @param observables defines a list of observables to watch
  61716. * @param callback defines the callback to call on notification
  61717. * @param mask defines the mask used to filter notifications
  61718. * @param scope defines the current scope used to restore the JS context
  61719. * @returns the new MultiObserver
  61720. */
  61721. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61722. }
  61723. /**
  61724. * The Observable class is a simple implementation of the Observable pattern.
  61725. *
  61726. * 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.
  61727. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61728. * 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).
  61729. * 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.
  61730. */
  61731. export class Observable<T> {
  61732. private _observers;
  61733. private _eventState;
  61734. private _onObserverAdded;
  61735. /**
  61736. * Creates a new observable
  61737. * @param onObserverAdded defines a callback to call when a new observer is added
  61738. */
  61739. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61740. /**
  61741. * Create a new Observer with the specified callback
  61742. * @param callback the callback that will be executed for that Observer
  61743. * @param mask the mask used to filter observers
  61744. * @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.
  61745. * @param scope optional scope for the callback to be called from
  61746. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61747. * @returns the new observer created for the callback
  61748. */
  61749. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61750. /**
  61751. * Create a new Observer with the specified callback and unregisters after the next notification
  61752. * @param callback the callback that will be executed for that Observer
  61753. * @returns the new observer created for the callback
  61754. */
  61755. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61756. /**
  61757. * Remove an Observer from the Observable object
  61758. * @param observer the instance of the Observer to remove
  61759. * @returns false if it doesn't belong to this Observable
  61760. */
  61761. remove(observer: Nullable<Observer<T>>): boolean;
  61762. /**
  61763. * Remove a callback from the Observable object
  61764. * @param callback the callback to remove
  61765. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61766. * @returns false if it doesn't belong to this Observable
  61767. */
  61768. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61769. private _deferUnregister;
  61770. private _remove;
  61771. /**
  61772. * Notify all Observers by calling their respective callback with the given data
  61773. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61774. * @param eventData defines the data to send to all observers
  61775. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61776. * @param target defines the original target of the state
  61777. * @param currentTarget defines the current target of the state
  61778. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61779. */
  61780. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61781. /**
  61782. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61783. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61784. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61785. * and it is crucial that all callbacks will be executed.
  61786. * The order of the callbacks is kept, callbacks are not executed parallel.
  61787. *
  61788. * @param eventData The data to be sent to each callback
  61789. * @param mask is used to filter observers defaults to -1
  61790. * @param target defines the callback target (see EventState)
  61791. * @param currentTarget defines he current object in the bubbling phase
  61792. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61793. */
  61794. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61795. /**
  61796. * Notify a specific observer
  61797. * @param observer defines the observer to notify
  61798. * @param eventData defines the data to be sent to each callback
  61799. * @param mask is used to filter observers defaults to -1
  61800. */
  61801. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61802. /**
  61803. * Gets a boolean indicating if the observable has at least one observer
  61804. * @returns true is the Observable has at least one Observer registered
  61805. */
  61806. hasObservers(): boolean;
  61807. /**
  61808. * Clear the list of observers
  61809. */
  61810. clear(): void;
  61811. /**
  61812. * Clone the current observable
  61813. * @returns a new observable
  61814. */
  61815. clone(): Observable<T>;
  61816. /**
  61817. * Does this observable handles observer registered with a given mask
  61818. * @param mask defines the mask to be tested
  61819. * @return whether or not one observer registered with the given mask is handeled
  61820. **/
  61821. hasSpecificMask(mask?: number): boolean;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Class used to help managing file picking and drag'n'drop
  61827. * File Storage
  61828. */
  61829. export class FilesInputStore {
  61830. /**
  61831. * List of files ready to be loaded
  61832. */
  61833. static FilesToLoad: {
  61834. [key: string]: File;
  61835. };
  61836. }
  61837. }
  61838. declare module BABYLON {
  61839. /** Defines the cross module used constants to avoid circular dependncies */
  61840. export class Constants {
  61841. /** Defines that alpha blending is disabled */
  61842. static readonly ALPHA_DISABLE: number;
  61843. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61844. static readonly ALPHA_ADD: number;
  61845. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61846. static readonly ALPHA_COMBINE: number;
  61847. /** Defines that alpha blending to DEST - SRC * DEST */
  61848. static readonly ALPHA_SUBTRACT: number;
  61849. /** Defines that alpha blending to SRC * DEST */
  61850. static readonly ALPHA_MULTIPLY: number;
  61851. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61852. static readonly ALPHA_MAXIMIZED: number;
  61853. /** Defines that alpha blending to SRC + DEST */
  61854. static readonly ALPHA_ONEONE: number;
  61855. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61856. static readonly ALPHA_PREMULTIPLIED: number;
  61857. /**
  61858. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61859. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61860. */
  61861. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61862. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61863. static readonly ALPHA_INTERPOLATE: number;
  61864. /**
  61865. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61866. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61867. */
  61868. static readonly ALPHA_SCREENMODE: number;
  61869. /** Defines that the ressource is not delayed*/
  61870. static readonly DELAYLOADSTATE_NONE: number;
  61871. /** Defines that the ressource was successfully delay loaded */
  61872. static readonly DELAYLOADSTATE_LOADED: number;
  61873. /** Defines that the ressource is currently delay loading */
  61874. static readonly DELAYLOADSTATE_LOADING: number;
  61875. /** Defines that the ressource is delayed and has not started loading */
  61876. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61878. static readonly NEVER: number;
  61879. /** 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 */
  61880. static readonly ALWAYS: number;
  61881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61882. static readonly LESS: number;
  61883. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61884. static readonly EQUAL: number;
  61885. /** 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 */
  61886. static readonly LEQUAL: number;
  61887. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61888. static readonly GREATER: number;
  61889. /** 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 */
  61890. static readonly GEQUAL: number;
  61891. /** 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 */
  61892. static readonly NOTEQUAL: number;
  61893. /** Passed to stencilOperation to specify that stencil value must be kept */
  61894. static readonly KEEP: number;
  61895. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61896. static readonly REPLACE: number;
  61897. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61898. static readonly INCR: number;
  61899. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61900. static readonly DECR: number;
  61901. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61902. static readonly INVERT: number;
  61903. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61904. static readonly INCR_WRAP: number;
  61905. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61906. static readonly DECR_WRAP: number;
  61907. /** Texture is not repeating outside of 0..1 UVs */
  61908. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61909. /** Texture is repeating outside of 0..1 UVs */
  61910. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61911. /** Texture is repeating and mirrored */
  61912. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61913. /** ALPHA */
  61914. static readonly TEXTUREFORMAT_ALPHA: number;
  61915. /** LUMINANCE */
  61916. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61917. /** LUMINANCE_ALPHA */
  61918. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61919. /** RGB */
  61920. static readonly TEXTUREFORMAT_RGB: number;
  61921. /** RGBA */
  61922. static readonly TEXTUREFORMAT_RGBA: number;
  61923. /** RED */
  61924. static readonly TEXTUREFORMAT_RED: number;
  61925. /** RED (2nd reference) */
  61926. static readonly TEXTUREFORMAT_R: number;
  61927. /** RG */
  61928. static readonly TEXTUREFORMAT_RG: number;
  61929. /** RED_INTEGER */
  61930. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61931. /** RED_INTEGER (2nd reference) */
  61932. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61933. /** RG_INTEGER */
  61934. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61935. /** RGB_INTEGER */
  61936. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61937. /** RGBA_INTEGER */
  61938. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61939. /** UNSIGNED_BYTE */
  61940. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61941. /** UNSIGNED_BYTE (2nd reference) */
  61942. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61943. /** FLOAT */
  61944. static readonly TEXTURETYPE_FLOAT: number;
  61945. /** HALF_FLOAT */
  61946. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61947. /** BYTE */
  61948. static readonly TEXTURETYPE_BYTE: number;
  61949. /** SHORT */
  61950. static readonly TEXTURETYPE_SHORT: number;
  61951. /** UNSIGNED_SHORT */
  61952. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61953. /** INT */
  61954. static readonly TEXTURETYPE_INT: number;
  61955. /** UNSIGNED_INT */
  61956. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61957. /** UNSIGNED_SHORT_4_4_4_4 */
  61958. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61959. /** UNSIGNED_SHORT_5_5_5_1 */
  61960. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61961. /** UNSIGNED_SHORT_5_6_5 */
  61962. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61963. /** UNSIGNED_INT_2_10_10_10_REV */
  61964. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61965. /** UNSIGNED_INT_24_8 */
  61966. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61967. /** UNSIGNED_INT_10F_11F_11F_REV */
  61968. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61969. /** UNSIGNED_INT_5_9_9_9_REV */
  61970. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61971. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61972. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61973. /** nearest is mag = nearest and min = nearest and mip = linear */
  61974. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61975. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61976. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61977. /** Trilinear is mag = linear and min = linear and mip = linear */
  61978. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61979. /** nearest is mag = nearest and min = nearest and mip = linear */
  61980. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61981. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61982. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61983. /** Trilinear is mag = linear and min = linear and mip = linear */
  61984. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61985. /** mag = nearest and min = nearest and mip = nearest */
  61986. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61987. /** mag = nearest and min = linear and mip = nearest */
  61988. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61989. /** mag = nearest and min = linear and mip = linear */
  61990. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61991. /** mag = nearest and min = linear and mip = none */
  61992. static readonly TEXTURE_NEAREST_LINEAR: number;
  61993. /** mag = nearest and min = nearest and mip = none */
  61994. static readonly TEXTURE_NEAREST_NEAREST: number;
  61995. /** mag = linear and min = nearest and mip = nearest */
  61996. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61997. /** mag = linear and min = nearest and mip = linear */
  61998. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61999. /** mag = linear and min = linear and mip = none */
  62000. static readonly TEXTURE_LINEAR_LINEAR: number;
  62001. /** mag = linear and min = nearest and mip = none */
  62002. static readonly TEXTURE_LINEAR_NEAREST: number;
  62003. /** Explicit coordinates mode */
  62004. static readonly TEXTURE_EXPLICIT_MODE: number;
  62005. /** Spherical coordinates mode */
  62006. static readonly TEXTURE_SPHERICAL_MODE: number;
  62007. /** Planar coordinates mode */
  62008. static readonly TEXTURE_PLANAR_MODE: number;
  62009. /** Cubic coordinates mode */
  62010. static readonly TEXTURE_CUBIC_MODE: number;
  62011. /** Projection coordinates mode */
  62012. static readonly TEXTURE_PROJECTION_MODE: number;
  62013. /** Skybox coordinates mode */
  62014. static readonly TEXTURE_SKYBOX_MODE: number;
  62015. /** Inverse Cubic coordinates mode */
  62016. static readonly TEXTURE_INVCUBIC_MODE: number;
  62017. /** Equirectangular coordinates mode */
  62018. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62019. /** Equirectangular Fixed coordinates mode */
  62020. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62021. /** Equirectangular Fixed Mirrored coordinates mode */
  62022. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62023. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62024. static readonly SCALEMODE_FLOOR: number;
  62025. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62026. static readonly SCALEMODE_NEAREST: number;
  62027. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62028. static readonly SCALEMODE_CEILING: number;
  62029. /**
  62030. * The dirty texture flag value
  62031. */
  62032. static readonly MATERIAL_TextureDirtyFlag: number;
  62033. /**
  62034. * The dirty light flag value
  62035. */
  62036. static readonly MATERIAL_LightDirtyFlag: number;
  62037. /**
  62038. * The dirty fresnel flag value
  62039. */
  62040. static readonly MATERIAL_FresnelDirtyFlag: number;
  62041. /**
  62042. * The dirty attribute flag value
  62043. */
  62044. static readonly MATERIAL_AttributesDirtyFlag: number;
  62045. /**
  62046. * The dirty misc flag value
  62047. */
  62048. static readonly MATERIAL_MiscDirtyFlag: number;
  62049. /**
  62050. * The all dirty flag value
  62051. */
  62052. static readonly MATERIAL_AllDirtyFlag: number;
  62053. /**
  62054. * Returns the triangle fill mode
  62055. */
  62056. static readonly MATERIAL_TriangleFillMode: number;
  62057. /**
  62058. * Returns the wireframe mode
  62059. */
  62060. static readonly MATERIAL_WireFrameFillMode: number;
  62061. /**
  62062. * Returns the point fill mode
  62063. */
  62064. static readonly MATERIAL_PointFillMode: number;
  62065. /**
  62066. * Returns the point list draw mode
  62067. */
  62068. static readonly MATERIAL_PointListDrawMode: number;
  62069. /**
  62070. * Returns the line list draw mode
  62071. */
  62072. static readonly MATERIAL_LineListDrawMode: number;
  62073. /**
  62074. * Returns the line loop draw mode
  62075. */
  62076. static readonly MATERIAL_LineLoopDrawMode: number;
  62077. /**
  62078. * Returns the line strip draw mode
  62079. */
  62080. static readonly MATERIAL_LineStripDrawMode: number;
  62081. /**
  62082. * Returns the triangle strip draw mode
  62083. */
  62084. static readonly MATERIAL_TriangleStripDrawMode: number;
  62085. /**
  62086. * Returns the triangle fan draw mode
  62087. */
  62088. static readonly MATERIAL_TriangleFanDrawMode: number;
  62089. /**
  62090. * Stores the clock-wise side orientation
  62091. */
  62092. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62093. /**
  62094. * Stores the counter clock-wise side orientation
  62095. */
  62096. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62097. /**
  62098. * Nothing
  62099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62100. */
  62101. static readonly ACTION_NothingTrigger: number;
  62102. /**
  62103. * On pick
  62104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62105. */
  62106. static readonly ACTION_OnPickTrigger: number;
  62107. /**
  62108. * On left pick
  62109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62110. */
  62111. static readonly ACTION_OnLeftPickTrigger: number;
  62112. /**
  62113. * On right pick
  62114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62115. */
  62116. static readonly ACTION_OnRightPickTrigger: number;
  62117. /**
  62118. * On center pick
  62119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62120. */
  62121. static readonly ACTION_OnCenterPickTrigger: number;
  62122. /**
  62123. * On pick down
  62124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62125. */
  62126. static readonly ACTION_OnPickDownTrigger: number;
  62127. /**
  62128. * On double pick
  62129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62130. */
  62131. static readonly ACTION_OnDoublePickTrigger: number;
  62132. /**
  62133. * On pick up
  62134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62135. */
  62136. static readonly ACTION_OnPickUpTrigger: number;
  62137. /**
  62138. * On pick out.
  62139. * This trigger will only be raised if you also declared a OnPickDown
  62140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62141. */
  62142. static readonly ACTION_OnPickOutTrigger: number;
  62143. /**
  62144. * On long press
  62145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62146. */
  62147. static readonly ACTION_OnLongPressTrigger: number;
  62148. /**
  62149. * On pointer over
  62150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62151. */
  62152. static readonly ACTION_OnPointerOverTrigger: number;
  62153. /**
  62154. * On pointer out
  62155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62156. */
  62157. static readonly ACTION_OnPointerOutTrigger: number;
  62158. /**
  62159. * On every frame
  62160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62161. */
  62162. static readonly ACTION_OnEveryFrameTrigger: number;
  62163. /**
  62164. * On intersection enter
  62165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62166. */
  62167. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62168. /**
  62169. * On intersection exit
  62170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62171. */
  62172. static readonly ACTION_OnIntersectionExitTrigger: number;
  62173. /**
  62174. * On key down
  62175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62176. */
  62177. static readonly ACTION_OnKeyDownTrigger: number;
  62178. /**
  62179. * On key up
  62180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62181. */
  62182. static readonly ACTION_OnKeyUpTrigger: number;
  62183. /**
  62184. * Billboard mode will only apply to Y axis
  62185. */
  62186. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62187. /**
  62188. * Billboard mode will apply to all axes
  62189. */
  62190. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62191. /**
  62192. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62193. */
  62194. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62195. /**
  62196. * Gets or sets base Assets URL
  62197. */
  62198. static readonly PARTICLES_BaseAssetsUrl: string;
  62199. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62200. * Test order :
  62201. * Is the bounding sphere outside the frustum ?
  62202. * If not, are the bounding box vertices outside the frustum ?
  62203. * It not, then the cullable object is in the frustum.
  62204. */
  62205. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62206. /** Culling strategy : Bounding Sphere Only.
  62207. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62208. * It's also less accurate than the standard because some not visible objects can still be selected.
  62209. * Test : is the bounding sphere outside the frustum ?
  62210. * If not, then the cullable object is in the frustum.
  62211. */
  62212. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62213. /** Culling strategy : Optimistic Inclusion.
  62214. * This in an inclusion test first, then the standard exclusion test.
  62215. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62216. * 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.
  62217. * Anyway, it's as accurate as the standard strategy.
  62218. * Test :
  62219. * Is the cullable object bounding sphere center in the frustum ?
  62220. * If not, apply the default culling strategy.
  62221. */
  62222. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62223. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62224. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62225. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62226. * 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.
  62227. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62228. * Test :
  62229. * Is the cullable object bounding sphere center in the frustum ?
  62230. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62231. */
  62232. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62233. /**
  62234. * No logging while loading
  62235. */
  62236. static readonly SCENELOADER_NO_LOGGING: number;
  62237. /**
  62238. * Minimal logging while loading
  62239. */
  62240. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62241. /**
  62242. * Summary logging while loading
  62243. */
  62244. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62245. /**
  62246. * Detailled logging while loading
  62247. */
  62248. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62249. }
  62250. }
  62251. declare module BABYLON {
  62252. /**
  62253. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62254. * Babylon.js
  62255. */
  62256. export class DomManagement {
  62257. /**
  62258. * Checks if the window object exists
  62259. * @returns true if the window object exists
  62260. */
  62261. static IsWindowObjectExist(): boolean;
  62262. /**
  62263. * Extracts text content from a DOM element hierarchy
  62264. * @param element defines the root element
  62265. * @returns a string
  62266. */
  62267. static GetDOMTextContent(element: HTMLElement): string;
  62268. }
  62269. }
  62270. declare module BABYLON {
  62271. /**
  62272. * Logger used througouht the application to allow configuration of
  62273. * the log level required for the messages.
  62274. */
  62275. export class Logger {
  62276. /**
  62277. * No log
  62278. */
  62279. static readonly NoneLogLevel: number;
  62280. /**
  62281. * Only message logs
  62282. */
  62283. static readonly MessageLogLevel: number;
  62284. /**
  62285. * Only warning logs
  62286. */
  62287. static readonly WarningLogLevel: number;
  62288. /**
  62289. * Only error logs
  62290. */
  62291. static readonly ErrorLogLevel: number;
  62292. /**
  62293. * All logs
  62294. */
  62295. static readonly AllLogLevel: number;
  62296. private static _LogCache;
  62297. /**
  62298. * Gets a value indicating the number of loading errors
  62299. * @ignorenaming
  62300. */
  62301. static errorsCount: number;
  62302. /**
  62303. * Callback called when a new log is added
  62304. */
  62305. static OnNewCacheEntry: (entry: string) => void;
  62306. private static _AddLogEntry;
  62307. private static _FormatMessage;
  62308. private static _LogDisabled;
  62309. private static _LogEnabled;
  62310. private static _WarnDisabled;
  62311. private static _WarnEnabled;
  62312. private static _ErrorDisabled;
  62313. private static _ErrorEnabled;
  62314. /**
  62315. * Log a message to the console
  62316. */
  62317. static Log: (message: string) => void;
  62318. /**
  62319. * Write a warning message to the console
  62320. */
  62321. static Warn: (message: string) => void;
  62322. /**
  62323. * Write an error message to the console
  62324. */
  62325. static Error: (message: string) => void;
  62326. /**
  62327. * Gets current log cache (list of logs)
  62328. */
  62329. static readonly LogCache: string;
  62330. /**
  62331. * Clears the log cache
  62332. */
  62333. static ClearLogCache(): void;
  62334. /**
  62335. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62336. */
  62337. static LogLevels: number;
  62338. }
  62339. }
  62340. declare module BABYLON {
  62341. /** @hidden */
  62342. export class _TypeStore {
  62343. /** @hidden */
  62344. static RegisteredTypes: {
  62345. [key: string]: Object;
  62346. };
  62347. /** @hidden */
  62348. static GetClass(fqdn: string): any;
  62349. }
  62350. }
  62351. declare module BABYLON {
  62352. /**
  62353. * Class containing a set of static utilities functions for deep copy.
  62354. */
  62355. export class DeepCopier {
  62356. /**
  62357. * Tries to copy an object by duplicating every property
  62358. * @param source defines the source object
  62359. * @param destination defines the target object
  62360. * @param doNotCopyList defines a list of properties to avoid
  62361. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62362. */
  62363. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62364. }
  62365. }
  62366. declare module BABYLON {
  62367. /**
  62368. * Class containing a set of static utilities functions for precision date
  62369. */
  62370. export class PrecisionDate {
  62371. /**
  62372. * Gets either window.performance.now() if supported or Date.now() else
  62373. */
  62374. static readonly Now: number;
  62375. }
  62376. }
  62377. declare module BABYLON {
  62378. /** @hidden */
  62379. export class _DevTools {
  62380. static WarnImport(name: string): string;
  62381. }
  62382. }
  62383. declare module BABYLON {
  62384. /**
  62385. * Class used to evalaute queries containing `and` and `or` operators
  62386. */
  62387. export class AndOrNotEvaluator {
  62388. /**
  62389. * Evaluate a query
  62390. * @param query defines the query to evaluate
  62391. * @param evaluateCallback defines the callback used to filter result
  62392. * @returns true if the query matches
  62393. */
  62394. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62395. private static _HandleParenthesisContent;
  62396. private static _SimplifyNegation;
  62397. }
  62398. }
  62399. declare module BABYLON {
  62400. /**
  62401. * Class used to store custom tags
  62402. */
  62403. export class Tags {
  62404. /**
  62405. * Adds support for tags on the given object
  62406. * @param obj defines the object to use
  62407. */
  62408. static EnableFor(obj: any): void;
  62409. /**
  62410. * Removes tags support
  62411. * @param obj defines the object to use
  62412. */
  62413. static DisableFor(obj: any): void;
  62414. /**
  62415. * Gets a boolean indicating if the given object has tags
  62416. * @param obj defines the object to use
  62417. * @returns a boolean
  62418. */
  62419. static HasTags(obj: any): boolean;
  62420. /**
  62421. * Gets the tags available on a given object
  62422. * @param obj defines the object to use
  62423. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62424. * @returns the tags
  62425. */
  62426. static GetTags(obj: any, asString?: boolean): any;
  62427. /**
  62428. * Adds tags to an object
  62429. * @param obj defines the object to use
  62430. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62431. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62432. */
  62433. static AddTagsTo(obj: any, tagsString: string): void;
  62434. /**
  62435. * @hidden
  62436. */
  62437. static _AddTagTo(obj: any, tag: string): void;
  62438. /**
  62439. * Removes specific tags from a specific object
  62440. * @param obj defines the object to use
  62441. * @param tagsString defines the tags to remove
  62442. */
  62443. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62444. /**
  62445. * @hidden
  62446. */
  62447. static _RemoveTagFrom(obj: any, tag: string): void;
  62448. /**
  62449. * Defines if tags hosted on an object match a given query
  62450. * @param obj defines the object to use
  62451. * @param tagsQuery defines the tag query
  62452. * @returns a boolean
  62453. */
  62454. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62455. }
  62456. }
  62457. declare module BABYLON {
  62458. /**
  62459. * Manages the defines for the Material
  62460. */
  62461. export class MaterialDefines {
  62462. private _keys;
  62463. private _isDirty;
  62464. /** @hidden */
  62465. _renderId: number;
  62466. /** @hidden */
  62467. _areLightsDirty: boolean;
  62468. /** @hidden */
  62469. _areAttributesDirty: boolean;
  62470. /** @hidden */
  62471. _areTexturesDirty: boolean;
  62472. /** @hidden */
  62473. _areFresnelDirty: boolean;
  62474. /** @hidden */
  62475. _areMiscDirty: boolean;
  62476. /** @hidden */
  62477. _areImageProcessingDirty: boolean;
  62478. /** @hidden */
  62479. _normals: boolean;
  62480. /** @hidden */
  62481. _uvs: boolean;
  62482. /** @hidden */
  62483. _needNormals: boolean;
  62484. /** @hidden */
  62485. _needUVs: boolean;
  62486. /**
  62487. * Specifies if the material needs to be re-calculated
  62488. */
  62489. readonly isDirty: boolean;
  62490. /**
  62491. * Marks the material to indicate that it has been re-calculated
  62492. */
  62493. markAsProcessed(): void;
  62494. /**
  62495. * Marks the material to indicate that it needs to be re-calculated
  62496. */
  62497. markAsUnprocessed(): void;
  62498. /**
  62499. * Marks the material to indicate all of its defines need to be re-calculated
  62500. */
  62501. markAllAsDirty(): void;
  62502. /**
  62503. * Marks the material to indicate that image processing needs to be re-calculated
  62504. */
  62505. markAsImageProcessingDirty(): void;
  62506. /**
  62507. * Marks the material to indicate the lights need to be re-calculated
  62508. */
  62509. markAsLightDirty(): void;
  62510. /**
  62511. * Marks the attribute state as changed
  62512. */
  62513. markAsAttributesDirty(): void;
  62514. /**
  62515. * Marks the texture state as changed
  62516. */
  62517. markAsTexturesDirty(): void;
  62518. /**
  62519. * Marks the fresnel state as changed
  62520. */
  62521. markAsFresnelDirty(): void;
  62522. /**
  62523. * Marks the misc state as changed
  62524. */
  62525. markAsMiscDirty(): void;
  62526. /**
  62527. * Rebuilds the material defines
  62528. */
  62529. rebuild(): void;
  62530. /**
  62531. * Specifies if two material defines are equal
  62532. * @param other - A material define instance to compare to
  62533. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62534. */
  62535. isEqual(other: MaterialDefines): boolean;
  62536. /**
  62537. * Clones this instance's defines to another instance
  62538. * @param other - material defines to clone values to
  62539. */
  62540. cloneTo(other: MaterialDefines): void;
  62541. /**
  62542. * Resets the material define values
  62543. */
  62544. reset(): void;
  62545. /**
  62546. * Converts the material define values to a string
  62547. * @returns - String of material define information
  62548. */
  62549. toString(): string;
  62550. }
  62551. }
  62552. declare module BABYLON {
  62553. /**
  62554. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62555. */
  62556. export class PerformanceMonitor {
  62557. private _enabled;
  62558. private _rollingFrameTime;
  62559. private _lastFrameTimeMs;
  62560. /**
  62561. * constructor
  62562. * @param frameSampleSize The number of samples required to saturate the sliding window
  62563. */
  62564. constructor(frameSampleSize?: number);
  62565. /**
  62566. * Samples current frame
  62567. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62568. */
  62569. sampleFrame(timeMs?: number): void;
  62570. /**
  62571. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62572. */
  62573. readonly averageFrameTime: number;
  62574. /**
  62575. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62576. */
  62577. readonly averageFrameTimeVariance: number;
  62578. /**
  62579. * Returns the frame time of the most recent frame
  62580. */
  62581. readonly instantaneousFrameTime: number;
  62582. /**
  62583. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62584. */
  62585. readonly averageFPS: number;
  62586. /**
  62587. * Returns the average framerate in frames per second using the most recent frame time
  62588. */
  62589. readonly instantaneousFPS: number;
  62590. /**
  62591. * Returns true if enough samples have been taken to completely fill the sliding window
  62592. */
  62593. readonly isSaturated: boolean;
  62594. /**
  62595. * Enables contributions to the sliding window sample set
  62596. */
  62597. enable(): void;
  62598. /**
  62599. * Disables contributions to the sliding window sample set
  62600. * Samples will not be interpolated over the disabled period
  62601. */
  62602. disable(): void;
  62603. /**
  62604. * Returns true if sampling is enabled
  62605. */
  62606. readonly isEnabled: boolean;
  62607. /**
  62608. * Resets performance monitor
  62609. */
  62610. reset(): void;
  62611. }
  62612. /**
  62613. * RollingAverage
  62614. *
  62615. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62616. */
  62617. export class RollingAverage {
  62618. /**
  62619. * Current average
  62620. */
  62621. average: number;
  62622. /**
  62623. * Current variance
  62624. */
  62625. variance: number;
  62626. protected _samples: Array<number>;
  62627. protected _sampleCount: number;
  62628. protected _pos: number;
  62629. protected _m2: number;
  62630. /**
  62631. * constructor
  62632. * @param length The number of samples required to saturate the sliding window
  62633. */
  62634. constructor(length: number);
  62635. /**
  62636. * Adds a sample to the sample set
  62637. * @param v The sample value
  62638. */
  62639. add(v: number): void;
  62640. /**
  62641. * Returns previously added values or null if outside of history or outside the sliding window domain
  62642. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62643. * @return Value previously recorded with add() or null if outside of range
  62644. */
  62645. history(i: number): number;
  62646. /**
  62647. * Returns true if enough samples have been taken to completely fill the sliding window
  62648. * @return true if sample-set saturated
  62649. */
  62650. isSaturated(): boolean;
  62651. /**
  62652. * Resets the rolling average (equivalent to 0 samples taken so far)
  62653. */
  62654. reset(): void;
  62655. /**
  62656. * Wraps a value around the sample range boundaries
  62657. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62658. * @return Wrapped position in sample range
  62659. */
  62660. protected _wrapPosition(i: number): number;
  62661. }
  62662. }
  62663. declare module BABYLON {
  62664. /**
  62665. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62666. * The underlying implementation relies on an associative array to ensure the best performances.
  62667. * The value can be anything including 'null' but except 'undefined'
  62668. */
  62669. export class StringDictionary<T> {
  62670. /**
  62671. * This will clear this dictionary and copy the content from the 'source' one.
  62672. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62673. * @param source the dictionary to take the content from and copy to this dictionary
  62674. */
  62675. copyFrom(source: StringDictionary<T>): void;
  62676. /**
  62677. * Get a value based from its key
  62678. * @param key the given key to get the matching value from
  62679. * @return the value if found, otherwise undefined is returned
  62680. */
  62681. get(key: string): T | undefined;
  62682. /**
  62683. * Get a value from its key or add it if it doesn't exist.
  62684. * This method will ensure you that a given key/data will be present in the dictionary.
  62685. * @param key the given key to get the matching value from
  62686. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62687. * The factory will only be invoked if there's no data for the given key.
  62688. * @return the value corresponding to the key.
  62689. */
  62690. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62691. /**
  62692. * Get a value from its key if present in the dictionary otherwise add it
  62693. * @param key the key to get the value from
  62694. * @param val if there's no such key/value pair in the dictionary add it with this value
  62695. * @return the value corresponding to the key
  62696. */
  62697. getOrAdd(key: string, val: T): T;
  62698. /**
  62699. * Check if there's a given key in the dictionary
  62700. * @param key the key to check for
  62701. * @return true if the key is present, false otherwise
  62702. */
  62703. contains(key: string): boolean;
  62704. /**
  62705. * Add a new key and its corresponding value
  62706. * @param key the key to add
  62707. * @param value the value corresponding to the key
  62708. * @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
  62709. */
  62710. add(key: string, value: T): boolean;
  62711. /**
  62712. * Update a specific value associated to a key
  62713. * @param key defines the key to use
  62714. * @param value defines the value to store
  62715. * @returns true if the value was updated (or false if the key was not found)
  62716. */
  62717. set(key: string, value: T): boolean;
  62718. /**
  62719. * Get the element of the given key and remove it from the dictionary
  62720. * @param key defines the key to search
  62721. * @returns the value associated with the key or null if not found
  62722. */
  62723. getAndRemove(key: string): Nullable<T>;
  62724. /**
  62725. * Remove a key/value from the dictionary.
  62726. * @param key the key to remove
  62727. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62728. */
  62729. remove(key: string): boolean;
  62730. /**
  62731. * Clear the whole content of the dictionary
  62732. */
  62733. clear(): void;
  62734. /**
  62735. * Gets the current count
  62736. */
  62737. readonly count: number;
  62738. /**
  62739. * Execute a callback on each key/val of the dictionary.
  62740. * Note that you can remove any element in this dictionary in the callback implementation
  62741. * @param callback the callback to execute on a given key/value pair
  62742. */
  62743. forEach(callback: (key: string, val: T) => void): void;
  62744. /**
  62745. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62746. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62747. * Note that you can remove any element in this dictionary in the callback implementation
  62748. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62749. * @returns the first item
  62750. */
  62751. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62752. private _count;
  62753. private _data;
  62754. }
  62755. }
  62756. declare module BABYLON {
  62757. /**
  62758. * Helper class that provides a small promise polyfill
  62759. */
  62760. export class PromisePolyfill {
  62761. /**
  62762. * Static function used to check if the polyfill is required
  62763. * If this is the case then the function will inject the polyfill to window.Promise
  62764. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62765. */
  62766. static Apply(force?: boolean): void;
  62767. }
  62768. }
  62769. declare module BABYLON {
  62770. /**
  62771. * Class used to store data that will be store in GPU memory
  62772. */
  62773. export class Buffer {
  62774. private _engine;
  62775. private _buffer;
  62776. /** @hidden */
  62777. _data: Nullable<DataArray>;
  62778. private _updatable;
  62779. private _instanced;
  62780. /**
  62781. * Gets the byte stride.
  62782. */
  62783. readonly byteStride: number;
  62784. /**
  62785. * Constructor
  62786. * @param engine the engine
  62787. * @param data the data to use for this buffer
  62788. * @param updatable whether the data is updatable
  62789. * @param stride the stride (optional)
  62790. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62791. * @param instanced whether the buffer is instanced (optional)
  62792. * @param useBytes set to true if the stride in in bytes (optional)
  62793. */
  62794. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62795. /**
  62796. * Create a new VertexBuffer based on the current buffer
  62797. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62798. * @param offset defines offset in the buffer (0 by default)
  62799. * @param size defines the size in floats of attributes (position is 3 for instance)
  62800. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62801. * @param instanced defines if the vertex buffer contains indexed data
  62802. * @param useBytes defines if the offset and stride are in bytes
  62803. * @returns the new vertex buffer
  62804. */
  62805. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62806. /**
  62807. * Gets a boolean indicating if the Buffer is updatable?
  62808. * @returns true if the buffer is updatable
  62809. */
  62810. isUpdatable(): boolean;
  62811. /**
  62812. * Gets current buffer's data
  62813. * @returns a DataArray or null
  62814. */
  62815. getData(): Nullable<DataArray>;
  62816. /**
  62817. * Gets underlying native buffer
  62818. * @returns underlying native buffer
  62819. */
  62820. getBuffer(): Nullable<WebGLBuffer>;
  62821. /**
  62822. * Gets the stride in float32 units (i.e. byte stride / 4).
  62823. * May not be an integer if the byte stride is not divisible by 4.
  62824. * DEPRECATED. Use byteStride instead.
  62825. * @returns the stride in float32 units
  62826. */
  62827. getStrideSize(): number;
  62828. /**
  62829. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62830. * @param data defines the data to store
  62831. */
  62832. create(data?: Nullable<DataArray>): void;
  62833. /** @hidden */
  62834. _rebuild(): void;
  62835. /**
  62836. * Update current buffer data
  62837. * @param data defines the data to store
  62838. */
  62839. update(data: DataArray): void;
  62840. /**
  62841. * Updates the data directly.
  62842. * @param data the new data
  62843. * @param offset the new offset
  62844. * @param vertexCount the vertex count (optional)
  62845. * @param useBytes set to true if the offset is in bytes
  62846. */
  62847. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62848. /**
  62849. * Release all resources
  62850. */
  62851. dispose(): void;
  62852. }
  62853. /**
  62854. * Specialized buffer used to store vertex data
  62855. */
  62856. export class VertexBuffer {
  62857. /** @hidden */
  62858. _buffer: Buffer;
  62859. private _kind;
  62860. private _size;
  62861. private _ownsBuffer;
  62862. private _instanced;
  62863. private _instanceDivisor;
  62864. /**
  62865. * The byte type.
  62866. */
  62867. static readonly BYTE: number;
  62868. /**
  62869. * The unsigned byte type.
  62870. */
  62871. static readonly UNSIGNED_BYTE: number;
  62872. /**
  62873. * The short type.
  62874. */
  62875. static readonly SHORT: number;
  62876. /**
  62877. * The unsigned short type.
  62878. */
  62879. static readonly UNSIGNED_SHORT: number;
  62880. /**
  62881. * The integer type.
  62882. */
  62883. static readonly INT: number;
  62884. /**
  62885. * The unsigned integer type.
  62886. */
  62887. static readonly UNSIGNED_INT: number;
  62888. /**
  62889. * The float type.
  62890. */
  62891. static readonly FLOAT: number;
  62892. /**
  62893. * Gets or sets the instance divisor when in instanced mode
  62894. */
  62895. instanceDivisor: number;
  62896. /**
  62897. * Gets the byte stride.
  62898. */
  62899. readonly byteStride: number;
  62900. /**
  62901. * Gets the byte offset.
  62902. */
  62903. readonly byteOffset: number;
  62904. /**
  62905. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62906. */
  62907. readonly normalized: boolean;
  62908. /**
  62909. * Gets the data type of each component in the array.
  62910. */
  62911. readonly type: number;
  62912. /**
  62913. * Constructor
  62914. * @param engine the engine
  62915. * @param data the data to use for this vertex buffer
  62916. * @param kind the vertex buffer kind
  62917. * @param updatable whether the data is updatable
  62918. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62919. * @param stride the stride (optional)
  62920. * @param instanced whether the buffer is instanced (optional)
  62921. * @param offset the offset of the data (optional)
  62922. * @param size the number of components (optional)
  62923. * @param type the type of the component (optional)
  62924. * @param normalized whether the data contains normalized data (optional)
  62925. * @param useBytes set to true if stride and offset are in bytes (optional)
  62926. */
  62927. 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);
  62928. /** @hidden */
  62929. _rebuild(): void;
  62930. /**
  62931. * Returns the kind of the VertexBuffer (string)
  62932. * @returns a string
  62933. */
  62934. getKind(): string;
  62935. /**
  62936. * Gets a boolean indicating if the VertexBuffer is updatable?
  62937. * @returns true if the buffer is updatable
  62938. */
  62939. isUpdatable(): boolean;
  62940. /**
  62941. * Gets current buffer's data
  62942. * @returns a DataArray or null
  62943. */
  62944. getData(): Nullable<DataArray>;
  62945. /**
  62946. * Gets underlying native buffer
  62947. * @returns underlying native buffer
  62948. */
  62949. getBuffer(): Nullable<WebGLBuffer>;
  62950. /**
  62951. * Gets the stride in float32 units (i.e. byte stride / 4).
  62952. * May not be an integer if the byte stride is not divisible by 4.
  62953. * DEPRECATED. Use byteStride instead.
  62954. * @returns the stride in float32 units
  62955. */
  62956. getStrideSize(): number;
  62957. /**
  62958. * Returns the offset as a multiple of the type byte length.
  62959. * DEPRECATED. Use byteOffset instead.
  62960. * @returns the offset in bytes
  62961. */
  62962. getOffset(): number;
  62963. /**
  62964. * Returns the number of components per vertex attribute (integer)
  62965. * @returns the size in float
  62966. */
  62967. getSize(): number;
  62968. /**
  62969. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62970. * @returns true if this buffer is instanced
  62971. */
  62972. getIsInstanced(): boolean;
  62973. /**
  62974. * Returns the instancing divisor, zero for non-instanced (integer).
  62975. * @returns a number
  62976. */
  62977. getInstanceDivisor(): number;
  62978. /**
  62979. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62980. * @param data defines the data to store
  62981. */
  62982. create(data?: DataArray): void;
  62983. /**
  62984. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62985. * This function will create a new buffer if the current one is not updatable
  62986. * @param data defines the data to store
  62987. */
  62988. update(data: DataArray): void;
  62989. /**
  62990. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62991. * Returns the directly updated WebGLBuffer.
  62992. * @param data the new data
  62993. * @param offset the new offset
  62994. * @param useBytes set to true if the offset is in bytes
  62995. */
  62996. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62997. /**
  62998. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62999. */
  63000. dispose(): void;
  63001. /**
  63002. * Enumerates each value of this vertex buffer as numbers.
  63003. * @param count the number of values to enumerate
  63004. * @param callback the callback function called for each value
  63005. */
  63006. forEach(count: number, callback: (value: number, index: number) => void): void;
  63007. /**
  63008. * Positions
  63009. */
  63010. static readonly PositionKind: string;
  63011. /**
  63012. * Normals
  63013. */
  63014. static readonly NormalKind: string;
  63015. /**
  63016. * Tangents
  63017. */
  63018. static readonly TangentKind: string;
  63019. /**
  63020. * Texture coordinates
  63021. */
  63022. static readonly UVKind: string;
  63023. /**
  63024. * Texture coordinates 2
  63025. */
  63026. static readonly UV2Kind: string;
  63027. /**
  63028. * Texture coordinates 3
  63029. */
  63030. static readonly UV3Kind: string;
  63031. /**
  63032. * Texture coordinates 4
  63033. */
  63034. static readonly UV4Kind: string;
  63035. /**
  63036. * Texture coordinates 5
  63037. */
  63038. static readonly UV5Kind: string;
  63039. /**
  63040. * Texture coordinates 6
  63041. */
  63042. static readonly UV6Kind: string;
  63043. /**
  63044. * Colors
  63045. */
  63046. static readonly ColorKind: string;
  63047. /**
  63048. * Matrix indices (for bones)
  63049. */
  63050. static readonly MatricesIndicesKind: string;
  63051. /**
  63052. * Matrix weights (for bones)
  63053. */
  63054. static readonly MatricesWeightsKind: string;
  63055. /**
  63056. * Additional matrix indices (for bones)
  63057. */
  63058. static readonly MatricesIndicesExtraKind: string;
  63059. /**
  63060. * Additional matrix weights (for bones)
  63061. */
  63062. static readonly MatricesWeightsExtraKind: string;
  63063. /**
  63064. * Deduces the stride given a kind.
  63065. * @param kind The kind string to deduce
  63066. * @returns The deduced stride
  63067. */
  63068. static DeduceStride(kind: string): number;
  63069. /**
  63070. * Gets the byte length of the given type.
  63071. * @param type the type
  63072. * @returns the number of bytes
  63073. */
  63074. static GetTypeByteLength(type: number): number;
  63075. /**
  63076. * Enumerates each value of the given parameters as numbers.
  63077. * @param data the data to enumerate
  63078. * @param byteOffset the byte offset of the data
  63079. * @param byteStride the byte stride of the data
  63080. * @param componentCount the number of components per element
  63081. * @param componentType the type of the component
  63082. * @param count the total number of components
  63083. * @param normalized whether the data is normalized
  63084. * @param callback the callback function called for each value
  63085. */
  63086. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63087. private static _GetFloatValue;
  63088. }
  63089. }
  63090. declare module BABYLON {
  63091. /**
  63092. * Class representing spherical polynomial coefficients to the 3rd degree
  63093. */
  63094. export class SphericalPolynomial {
  63095. /**
  63096. * The x coefficients of the spherical polynomial
  63097. */
  63098. x: Vector3;
  63099. /**
  63100. * The y coefficients of the spherical polynomial
  63101. */
  63102. y: Vector3;
  63103. /**
  63104. * The z coefficients of the spherical polynomial
  63105. */
  63106. z: Vector3;
  63107. /**
  63108. * The xx coefficients of the spherical polynomial
  63109. */
  63110. xx: Vector3;
  63111. /**
  63112. * The yy coefficients of the spherical polynomial
  63113. */
  63114. yy: Vector3;
  63115. /**
  63116. * The zz coefficients of the spherical polynomial
  63117. */
  63118. zz: Vector3;
  63119. /**
  63120. * The xy coefficients of the spherical polynomial
  63121. */
  63122. xy: Vector3;
  63123. /**
  63124. * The yz coefficients of the spherical polynomial
  63125. */
  63126. yz: Vector3;
  63127. /**
  63128. * The zx coefficients of the spherical polynomial
  63129. */
  63130. zx: Vector3;
  63131. /**
  63132. * Adds an ambient color to the spherical polynomial
  63133. * @param color the color to add
  63134. */
  63135. addAmbient(color: Color3): void;
  63136. /**
  63137. * Scales the spherical polynomial by the given amount
  63138. * @param scale the amount to scale
  63139. */
  63140. scale(scale: number): void;
  63141. /**
  63142. * Gets the spherical polynomial from harmonics
  63143. * @param harmonics the spherical harmonics
  63144. * @returns the spherical polynomial
  63145. */
  63146. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63147. /**
  63148. * Constructs a spherical polynomial from an array.
  63149. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63150. * @returns the spherical polynomial
  63151. */
  63152. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63153. }
  63154. /**
  63155. * Class representing spherical harmonics coefficients to the 3rd degree
  63156. */
  63157. export class SphericalHarmonics {
  63158. /**
  63159. * The l0,0 coefficients of the spherical harmonics
  63160. */
  63161. l00: Vector3;
  63162. /**
  63163. * The l1,-1 coefficients of the spherical harmonics
  63164. */
  63165. l1_1: Vector3;
  63166. /**
  63167. * The l1,0 coefficients of the spherical harmonics
  63168. */
  63169. l10: Vector3;
  63170. /**
  63171. * The l1,1 coefficients of the spherical harmonics
  63172. */
  63173. l11: Vector3;
  63174. /**
  63175. * The l2,-2 coefficients of the spherical harmonics
  63176. */
  63177. l2_2: Vector3;
  63178. /**
  63179. * The l2,-1 coefficients of the spherical harmonics
  63180. */
  63181. l2_1: Vector3;
  63182. /**
  63183. * The l2,0 coefficients of the spherical harmonics
  63184. */
  63185. l20: Vector3;
  63186. /**
  63187. * The l2,1 coefficients of the spherical harmonics
  63188. */
  63189. l21: Vector3;
  63190. /**
  63191. * The l2,2 coefficients of the spherical harmonics
  63192. */
  63193. lL22: Vector3;
  63194. /**
  63195. * Adds a light to the spherical harmonics
  63196. * @param direction the direction of the light
  63197. * @param color the color of the light
  63198. * @param deltaSolidAngle the delta solid angle of the light
  63199. */
  63200. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63201. /**
  63202. * Scales the spherical harmonics by the given amount
  63203. * @param scale the amount to scale
  63204. */
  63205. scale(scale: number): void;
  63206. /**
  63207. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63208. *
  63209. * ```
  63210. * E_lm = A_l * L_lm
  63211. * ```
  63212. *
  63213. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63214. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63215. * the scaling factors are given in equation 9.
  63216. */
  63217. convertIncidentRadianceToIrradiance(): void;
  63218. /**
  63219. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63220. *
  63221. * ```
  63222. * L = (1/pi) * E * rho
  63223. * ```
  63224. *
  63225. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63226. */
  63227. convertIrradianceToLambertianRadiance(): void;
  63228. /**
  63229. * Gets the spherical harmonics from polynomial
  63230. * @param polynomial the spherical polynomial
  63231. * @returns the spherical harmonics
  63232. */
  63233. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63234. /**
  63235. * Constructs a spherical harmonics from an array.
  63236. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63237. * @returns the spherical harmonics
  63238. */
  63239. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63240. }
  63241. }
  63242. declare module BABYLON {
  63243. /**
  63244. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63245. */
  63246. export interface CubeMapInfo {
  63247. /**
  63248. * The pixel array for the front face.
  63249. * This is stored in format, left to right, up to down format.
  63250. */
  63251. front: Nullable<ArrayBufferView>;
  63252. /**
  63253. * The pixel array for the back face.
  63254. * This is stored in format, left to right, up to down format.
  63255. */
  63256. back: Nullable<ArrayBufferView>;
  63257. /**
  63258. * The pixel array for the left face.
  63259. * This is stored in format, left to right, up to down format.
  63260. */
  63261. left: Nullable<ArrayBufferView>;
  63262. /**
  63263. * The pixel array for the right face.
  63264. * This is stored in format, left to right, up to down format.
  63265. */
  63266. right: Nullable<ArrayBufferView>;
  63267. /**
  63268. * The pixel array for the up face.
  63269. * This is stored in format, left to right, up to down format.
  63270. */
  63271. up: Nullable<ArrayBufferView>;
  63272. /**
  63273. * The pixel array for the down face.
  63274. * This is stored in format, left to right, up to down format.
  63275. */
  63276. down: Nullable<ArrayBufferView>;
  63277. /**
  63278. * The size of the cubemap stored.
  63279. *
  63280. * Each faces will be size * size pixels.
  63281. */
  63282. size: number;
  63283. /**
  63284. * The format of the texture.
  63285. *
  63286. * RGBA, RGB.
  63287. */
  63288. format: number;
  63289. /**
  63290. * The type of the texture data.
  63291. *
  63292. * UNSIGNED_INT, FLOAT.
  63293. */
  63294. type: number;
  63295. /**
  63296. * Specifies whether the texture is in gamma space.
  63297. */
  63298. gammaSpace: boolean;
  63299. }
  63300. /**
  63301. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63302. */
  63303. export class PanoramaToCubeMapTools {
  63304. private static FACE_FRONT;
  63305. private static FACE_BACK;
  63306. private static FACE_RIGHT;
  63307. private static FACE_LEFT;
  63308. private static FACE_DOWN;
  63309. private static FACE_UP;
  63310. /**
  63311. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63312. *
  63313. * @param float32Array The source data.
  63314. * @param inputWidth The width of the input panorama.
  63315. * @param inputHeight The height of the input panorama.
  63316. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63317. * @return The cubemap data
  63318. */
  63319. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63320. private static CreateCubemapTexture;
  63321. private static CalcProjectionSpherical;
  63322. }
  63323. }
  63324. declare module BABYLON {
  63325. /**
  63326. * Helper class dealing with the extraction of spherical polynomial dataArray
  63327. * from a cube map.
  63328. */
  63329. export class CubeMapToSphericalPolynomialTools {
  63330. private static FileFaces;
  63331. /**
  63332. * Converts a texture to the according Spherical Polynomial data.
  63333. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63334. *
  63335. * @param texture The texture to extract the information from.
  63336. * @return The Spherical Polynomial data.
  63337. */
  63338. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63339. /**
  63340. * Converts a cubemap to the according Spherical Polynomial data.
  63341. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63342. *
  63343. * @param cubeInfo The Cube map to extract the information from.
  63344. * @return The Spherical Polynomial data.
  63345. */
  63346. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63347. }
  63348. }
  63349. declare module BABYLON {
  63350. /**
  63351. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63352. * during the life time of the application.
  63353. */
  63354. export class EngineStore {
  63355. /** Gets the list of created engines */
  63356. static Instances: Engine[];
  63357. /**
  63358. * Gets the latest created engine
  63359. */
  63360. static readonly LastCreatedEngine: Nullable<Engine>;
  63361. /**
  63362. * Gets the latest created scene
  63363. */
  63364. static readonly LastCreatedScene: Nullable<Scene>;
  63365. }
  63366. }
  63367. declare module BABYLON {
  63368. /**
  63369. * Define options used to create a render target texture
  63370. */
  63371. export class RenderTargetCreationOptions {
  63372. /**
  63373. * Specifies is mipmaps must be generated
  63374. */
  63375. generateMipMaps?: boolean;
  63376. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63377. generateDepthBuffer?: boolean;
  63378. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63379. generateStencilBuffer?: boolean;
  63380. /** Defines texture type (int by default) */
  63381. type?: number;
  63382. /** Defines sampling mode (trilinear by default) */
  63383. samplingMode?: number;
  63384. /** Defines format (RGBA by default) */
  63385. format?: number;
  63386. }
  63387. }
  63388. declare module BABYLON {
  63389. /**
  63390. * @hidden
  63391. **/
  63392. export class _AlphaState {
  63393. private _isAlphaBlendDirty;
  63394. private _isBlendFunctionParametersDirty;
  63395. private _isBlendEquationParametersDirty;
  63396. private _isBlendConstantsDirty;
  63397. private _alphaBlend;
  63398. private _blendFunctionParameters;
  63399. private _blendEquationParameters;
  63400. private _blendConstants;
  63401. /**
  63402. * Initializes the state.
  63403. */
  63404. constructor();
  63405. readonly isDirty: boolean;
  63406. alphaBlend: boolean;
  63407. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63408. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63409. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63410. reset(): void;
  63411. apply(gl: WebGLRenderingContext): void;
  63412. }
  63413. }
  63414. declare module BABYLON {
  63415. /**
  63416. * @hidden
  63417. **/
  63418. export class _DepthCullingState {
  63419. private _isDepthTestDirty;
  63420. private _isDepthMaskDirty;
  63421. private _isDepthFuncDirty;
  63422. private _isCullFaceDirty;
  63423. private _isCullDirty;
  63424. private _isZOffsetDirty;
  63425. private _isFrontFaceDirty;
  63426. private _depthTest;
  63427. private _depthMask;
  63428. private _depthFunc;
  63429. private _cull;
  63430. private _cullFace;
  63431. private _zOffset;
  63432. private _frontFace;
  63433. /**
  63434. * Initializes the state.
  63435. */
  63436. constructor();
  63437. readonly isDirty: boolean;
  63438. zOffset: number;
  63439. cullFace: Nullable<number>;
  63440. cull: Nullable<boolean>;
  63441. depthFunc: Nullable<number>;
  63442. depthMask: boolean;
  63443. depthTest: boolean;
  63444. frontFace: Nullable<number>;
  63445. reset(): void;
  63446. apply(gl: WebGLRenderingContext): void;
  63447. }
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * @hidden
  63452. **/
  63453. export class _StencilState {
  63454. /** 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 */
  63455. static readonly ALWAYS: number;
  63456. /** Passed to stencilOperation to specify that stencil value must be kept */
  63457. static readonly KEEP: number;
  63458. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63459. static readonly REPLACE: number;
  63460. private _isStencilTestDirty;
  63461. private _isStencilMaskDirty;
  63462. private _isStencilFuncDirty;
  63463. private _isStencilOpDirty;
  63464. private _stencilTest;
  63465. private _stencilMask;
  63466. private _stencilFunc;
  63467. private _stencilFuncRef;
  63468. private _stencilFuncMask;
  63469. private _stencilOpStencilFail;
  63470. private _stencilOpDepthFail;
  63471. private _stencilOpStencilDepthPass;
  63472. readonly isDirty: boolean;
  63473. stencilFunc: number;
  63474. stencilFuncRef: number;
  63475. stencilFuncMask: number;
  63476. stencilOpStencilFail: number;
  63477. stencilOpDepthFail: number;
  63478. stencilOpStencilDepthPass: number;
  63479. stencilMask: number;
  63480. stencilTest: boolean;
  63481. constructor();
  63482. reset(): void;
  63483. apply(gl: WebGLRenderingContext): void;
  63484. }
  63485. }
  63486. declare module BABYLON {
  63487. /**
  63488. * @hidden
  63489. **/
  63490. export class _TimeToken {
  63491. _startTimeQuery: Nullable<WebGLQuery>;
  63492. _endTimeQuery: Nullable<WebGLQuery>;
  63493. _timeElapsedQuery: Nullable<WebGLQuery>;
  63494. _timeElapsedQueryEnded: boolean;
  63495. }
  63496. }
  63497. declare module BABYLON {
  63498. /**
  63499. * Internal interface used to track InternalTexture already bound to the GL context
  63500. */
  63501. export interface IInternalTextureTracker {
  63502. /**
  63503. * Gets or set the previous tracker in the list
  63504. */
  63505. previous: Nullable<IInternalTextureTracker>;
  63506. /**
  63507. * Gets or set the next tracker in the list
  63508. */
  63509. next: Nullable<IInternalTextureTracker>;
  63510. }
  63511. /**
  63512. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63513. */
  63514. export class DummyInternalTextureTracker {
  63515. /**
  63516. * Gets or set the previous tracker in the list
  63517. */
  63518. previous: Nullable<IInternalTextureTracker>;
  63519. /**
  63520. * Gets or set the next tracker in the list
  63521. */
  63522. next: Nullable<IInternalTextureTracker>;
  63523. }
  63524. }
  63525. declare module BABYLON {
  63526. /**
  63527. * Class used to store data associated with WebGL texture data for the engine
  63528. * This class should not be used directly
  63529. */
  63530. export class InternalTexture implements IInternalTextureTracker {
  63531. /** hidden */
  63532. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63533. /**
  63534. * The source of the texture data is unknown
  63535. */
  63536. static DATASOURCE_UNKNOWN: number;
  63537. /**
  63538. * Texture data comes from an URL
  63539. */
  63540. static DATASOURCE_URL: number;
  63541. /**
  63542. * Texture data is only used for temporary storage
  63543. */
  63544. static DATASOURCE_TEMP: number;
  63545. /**
  63546. * Texture data comes from raw data (ArrayBuffer)
  63547. */
  63548. static DATASOURCE_RAW: number;
  63549. /**
  63550. * Texture content is dynamic (video or dynamic texture)
  63551. */
  63552. static DATASOURCE_DYNAMIC: number;
  63553. /**
  63554. * Texture content is generated by rendering to it
  63555. */
  63556. static DATASOURCE_RENDERTARGET: number;
  63557. /**
  63558. * Texture content is part of a multi render target process
  63559. */
  63560. static DATASOURCE_MULTIRENDERTARGET: number;
  63561. /**
  63562. * Texture data comes from a cube data file
  63563. */
  63564. static DATASOURCE_CUBE: number;
  63565. /**
  63566. * Texture data comes from a raw cube data
  63567. */
  63568. static DATASOURCE_CUBERAW: number;
  63569. /**
  63570. * Texture data come from a prefiltered cube data file
  63571. */
  63572. static DATASOURCE_CUBEPREFILTERED: number;
  63573. /**
  63574. * Texture content is raw 3D data
  63575. */
  63576. static DATASOURCE_RAW3D: number;
  63577. /**
  63578. * Texture content is a depth texture
  63579. */
  63580. static DATASOURCE_DEPTHTEXTURE: number;
  63581. /**
  63582. * Texture data comes from a raw cube data encoded with RGBD
  63583. */
  63584. static DATASOURCE_CUBERAW_RGBD: number;
  63585. /**
  63586. * Defines if the texture is ready
  63587. */
  63588. isReady: boolean;
  63589. /**
  63590. * Defines if the texture is a cube texture
  63591. */
  63592. isCube: boolean;
  63593. /**
  63594. * Defines if the texture contains 3D data
  63595. */
  63596. is3D: boolean;
  63597. /**
  63598. * Gets the URL used to load this texture
  63599. */
  63600. url: string;
  63601. /**
  63602. * Gets the sampling mode of the texture
  63603. */
  63604. samplingMode: number;
  63605. /**
  63606. * Gets a boolean indicating if the texture needs mipmaps generation
  63607. */
  63608. generateMipMaps: boolean;
  63609. /**
  63610. * Gets the number of samples used by the texture (WebGL2+ only)
  63611. */
  63612. samples: number;
  63613. /**
  63614. * Gets the type of the texture (int, float...)
  63615. */
  63616. type: number;
  63617. /**
  63618. * Gets the format of the texture (RGB, RGBA...)
  63619. */
  63620. format: number;
  63621. /**
  63622. * Observable called when the texture is loaded
  63623. */
  63624. onLoadedObservable: Observable<InternalTexture>;
  63625. /**
  63626. * Gets the width of the texture
  63627. */
  63628. width: number;
  63629. /**
  63630. * Gets the height of the texture
  63631. */
  63632. height: number;
  63633. /**
  63634. * Gets the depth of the texture
  63635. */
  63636. depth: number;
  63637. /**
  63638. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63639. */
  63640. baseWidth: number;
  63641. /**
  63642. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63643. */
  63644. baseHeight: number;
  63645. /**
  63646. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63647. */
  63648. baseDepth: number;
  63649. /**
  63650. * Gets a boolean indicating if the texture is inverted on Y axis
  63651. */
  63652. invertY: boolean;
  63653. /**
  63654. * Gets or set the previous tracker in the list
  63655. */
  63656. previous: Nullable<IInternalTextureTracker>;
  63657. /**
  63658. * Gets or set the next tracker in the list
  63659. */
  63660. next: Nullable<IInternalTextureTracker>;
  63661. /** @hidden */
  63662. _invertVScale: boolean;
  63663. /** @hidden */
  63664. _initialSlot: number;
  63665. /** @hidden */
  63666. _designatedSlot: number;
  63667. /** @hidden */
  63668. _dataSource: number;
  63669. /** @hidden */
  63670. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63671. /** @hidden */
  63672. _bufferView: Nullable<ArrayBufferView>;
  63673. /** @hidden */
  63674. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63675. /** @hidden */
  63676. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63677. /** @hidden */
  63678. _size: number;
  63679. /** @hidden */
  63680. _extension: string;
  63681. /** @hidden */
  63682. _files: Nullable<string[]>;
  63683. /** @hidden */
  63684. _workingCanvas: HTMLCanvasElement;
  63685. /** @hidden */
  63686. _workingContext: CanvasRenderingContext2D;
  63687. /** @hidden */
  63688. _framebuffer: Nullable<WebGLFramebuffer>;
  63689. /** @hidden */
  63690. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63691. /** @hidden */
  63692. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63693. /** @hidden */
  63694. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63695. /** @hidden */
  63696. _attachments: Nullable<number[]>;
  63697. /** @hidden */
  63698. _cachedCoordinatesMode: Nullable<number>;
  63699. /** @hidden */
  63700. _cachedWrapU: Nullable<number>;
  63701. /** @hidden */
  63702. _cachedWrapV: Nullable<number>;
  63703. /** @hidden */
  63704. _cachedWrapR: Nullable<number>;
  63705. /** @hidden */
  63706. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63707. /** @hidden */
  63708. _isDisabled: boolean;
  63709. /** @hidden */
  63710. _compression: Nullable<string>;
  63711. /** @hidden */
  63712. _generateStencilBuffer: boolean;
  63713. /** @hidden */
  63714. _generateDepthBuffer: boolean;
  63715. /** @hidden */
  63716. _comparisonFunction: number;
  63717. /** @hidden */
  63718. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63719. /** @hidden */
  63720. _lodGenerationScale: number;
  63721. /** @hidden */
  63722. _lodGenerationOffset: number;
  63723. /** @hidden */
  63724. _lodTextureHigh: BaseTexture;
  63725. /** @hidden */
  63726. _lodTextureMid: BaseTexture;
  63727. /** @hidden */
  63728. _lodTextureLow: BaseTexture;
  63729. /** @hidden */
  63730. _isRGBD: boolean;
  63731. /** @hidden */
  63732. _webGLTexture: Nullable<WebGLTexture>;
  63733. /** @hidden */
  63734. _references: number;
  63735. private _engine;
  63736. /**
  63737. * Gets the Engine the texture belongs to.
  63738. * @returns The babylon engine
  63739. */
  63740. getEngine(): Engine;
  63741. /**
  63742. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63743. */
  63744. readonly dataSource: number;
  63745. /**
  63746. * Creates a new InternalTexture
  63747. * @param engine defines the engine to use
  63748. * @param dataSource defines the type of data that will be used
  63749. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63750. */
  63751. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63752. /**
  63753. * Increments the number of references (ie. the number of Texture that point to it)
  63754. */
  63755. incrementReferences(): void;
  63756. /**
  63757. * Change the size of the texture (not the size of the content)
  63758. * @param width defines the new width
  63759. * @param height defines the new height
  63760. * @param depth defines the new depth (1 by default)
  63761. */
  63762. updateSize(width: int, height: int, depth?: int): void;
  63763. /** @hidden */
  63764. _rebuild(): void;
  63765. /** @hidden */
  63766. _swapAndDie(target: InternalTexture): void;
  63767. /**
  63768. * Dispose the current allocated resources
  63769. */
  63770. dispose(): void;
  63771. }
  63772. }
  63773. declare module BABYLON {
  63774. /**
  63775. * This represents the main contract an easing function should follow.
  63776. * Easing functions are used throughout the animation system.
  63777. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63778. */
  63779. export interface IEasingFunction {
  63780. /**
  63781. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63782. * of the easing function.
  63783. * The link below provides some of the most common examples of easing functions.
  63784. * @see https://easings.net/
  63785. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63786. * @returns the corresponding value on the curve defined by the easing function
  63787. */
  63788. ease(gradient: number): number;
  63789. }
  63790. /**
  63791. * Base class used for every default easing function.
  63792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63793. */
  63794. export class EasingFunction implements IEasingFunction {
  63795. /**
  63796. * Interpolation follows the mathematical formula associated with the easing function.
  63797. */
  63798. static readonly EASINGMODE_EASEIN: number;
  63799. /**
  63800. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63801. */
  63802. static readonly EASINGMODE_EASEOUT: number;
  63803. /**
  63804. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63805. */
  63806. static readonly EASINGMODE_EASEINOUT: number;
  63807. private _easingMode;
  63808. /**
  63809. * Sets the easing mode of the current function.
  63810. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63811. */
  63812. setEasingMode(easingMode: number): void;
  63813. /**
  63814. * Gets the current easing mode.
  63815. * @returns the easing mode
  63816. */
  63817. getEasingMode(): number;
  63818. /**
  63819. * @hidden
  63820. */
  63821. easeInCore(gradient: number): number;
  63822. /**
  63823. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63824. * of the easing function.
  63825. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63826. * @returns the corresponding value on the curve defined by the easing function
  63827. */
  63828. ease(gradient: number): number;
  63829. }
  63830. /**
  63831. * Easing function with a circle shape (see link below).
  63832. * @see https://easings.net/#easeInCirc
  63833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63834. */
  63835. export class CircleEase extends EasingFunction implements IEasingFunction {
  63836. /** @hidden */
  63837. easeInCore(gradient: number): number;
  63838. }
  63839. /**
  63840. * Easing function with a ease back shape (see link below).
  63841. * @see https://easings.net/#easeInBack
  63842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63843. */
  63844. export class BackEase extends EasingFunction implements IEasingFunction {
  63845. /** Defines the amplitude of the function */
  63846. amplitude: number;
  63847. /**
  63848. * Instantiates a back ease easing
  63849. * @see https://easings.net/#easeInBack
  63850. * @param amplitude Defines the amplitude of the function
  63851. */
  63852. constructor(
  63853. /** Defines the amplitude of the function */
  63854. amplitude?: number);
  63855. /** @hidden */
  63856. easeInCore(gradient: number): number;
  63857. }
  63858. /**
  63859. * Easing function with a bouncing shape (see link below).
  63860. * @see https://easings.net/#easeInBounce
  63861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63862. */
  63863. export class BounceEase extends EasingFunction implements IEasingFunction {
  63864. /** Defines the number of bounces */
  63865. bounces: number;
  63866. /** Defines the amplitude of the bounce */
  63867. bounciness: number;
  63868. /**
  63869. * Instantiates a bounce easing
  63870. * @see https://easings.net/#easeInBounce
  63871. * @param bounces Defines the number of bounces
  63872. * @param bounciness Defines the amplitude of the bounce
  63873. */
  63874. constructor(
  63875. /** Defines the number of bounces */
  63876. bounces?: number,
  63877. /** Defines the amplitude of the bounce */
  63878. bounciness?: number);
  63879. /** @hidden */
  63880. easeInCore(gradient: number): number;
  63881. }
  63882. /**
  63883. * Easing function with a power of 3 shape (see link below).
  63884. * @see https://easings.net/#easeInCubic
  63885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63886. */
  63887. export class CubicEase extends EasingFunction implements IEasingFunction {
  63888. /** @hidden */
  63889. easeInCore(gradient: number): number;
  63890. }
  63891. /**
  63892. * Easing function with an elastic shape (see link below).
  63893. * @see https://easings.net/#easeInElastic
  63894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63895. */
  63896. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63897. /** Defines the number of oscillations*/
  63898. oscillations: number;
  63899. /** Defines the amplitude of the oscillations*/
  63900. springiness: number;
  63901. /**
  63902. * Instantiates an elastic easing function
  63903. * @see https://easings.net/#easeInElastic
  63904. * @param oscillations Defines the number of oscillations
  63905. * @param springiness Defines the amplitude of the oscillations
  63906. */
  63907. constructor(
  63908. /** Defines the number of oscillations*/
  63909. oscillations?: number,
  63910. /** Defines the amplitude of the oscillations*/
  63911. springiness?: number);
  63912. /** @hidden */
  63913. easeInCore(gradient: number): number;
  63914. }
  63915. /**
  63916. * Easing function with an exponential shape (see link below).
  63917. * @see https://easings.net/#easeInExpo
  63918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63919. */
  63920. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63921. /** Defines the exponent of the function */
  63922. exponent: number;
  63923. /**
  63924. * Instantiates an exponential easing function
  63925. * @see https://easings.net/#easeInExpo
  63926. * @param exponent Defines the exponent of the function
  63927. */
  63928. constructor(
  63929. /** Defines the exponent of the function */
  63930. exponent?: number);
  63931. /** @hidden */
  63932. easeInCore(gradient: number): number;
  63933. }
  63934. /**
  63935. * Easing function with a power shape (see link below).
  63936. * @see https://easings.net/#easeInQuad
  63937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63938. */
  63939. export class PowerEase extends EasingFunction implements IEasingFunction {
  63940. /** Defines the power of the function */
  63941. power: number;
  63942. /**
  63943. * Instantiates an power base easing function
  63944. * @see https://easings.net/#easeInQuad
  63945. * @param power Defines the power of the function
  63946. */
  63947. constructor(
  63948. /** Defines the power of the function */
  63949. power?: number);
  63950. /** @hidden */
  63951. easeInCore(gradient: number): number;
  63952. }
  63953. /**
  63954. * Easing function with a power of 2 shape (see link below).
  63955. * @see https://easings.net/#easeInQuad
  63956. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63957. */
  63958. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63959. /** @hidden */
  63960. easeInCore(gradient: number): number;
  63961. }
  63962. /**
  63963. * Easing function with a power of 4 shape (see link below).
  63964. * @see https://easings.net/#easeInQuart
  63965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63966. */
  63967. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63968. /** @hidden */
  63969. easeInCore(gradient: number): number;
  63970. }
  63971. /**
  63972. * Easing function with a power of 5 shape (see link below).
  63973. * @see https://easings.net/#easeInQuint
  63974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63975. */
  63976. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63977. /** @hidden */
  63978. easeInCore(gradient: number): number;
  63979. }
  63980. /**
  63981. * Easing function with a sin shape (see link below).
  63982. * @see https://easings.net/#easeInSine
  63983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63984. */
  63985. export class SineEase extends EasingFunction implements IEasingFunction {
  63986. /** @hidden */
  63987. easeInCore(gradient: number): number;
  63988. }
  63989. /**
  63990. * Easing function with a bezier shape (see link below).
  63991. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63993. */
  63994. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63995. /** Defines the x component of the start tangent in the bezier curve */
  63996. x1: number;
  63997. /** Defines the y component of the start tangent in the bezier curve */
  63998. y1: number;
  63999. /** Defines the x component of the end tangent in the bezier curve */
  64000. x2: number;
  64001. /** Defines the y component of the end tangent in the bezier curve */
  64002. y2: number;
  64003. /**
  64004. * Instantiates a bezier function
  64005. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64006. * @param x1 Defines the x component of the start tangent in the bezier curve
  64007. * @param y1 Defines the y component of the start tangent in the bezier curve
  64008. * @param x2 Defines the x component of the end tangent in the bezier curve
  64009. * @param y2 Defines the y component of the end tangent in the bezier curve
  64010. */
  64011. constructor(
  64012. /** Defines the x component of the start tangent in the bezier curve */
  64013. x1?: number,
  64014. /** Defines the y component of the start tangent in the bezier curve */
  64015. y1?: number,
  64016. /** Defines the x component of the end tangent in the bezier curve */
  64017. x2?: number,
  64018. /** Defines the y component of the end tangent in the bezier curve */
  64019. y2?: number);
  64020. /** @hidden */
  64021. easeInCore(gradient: number): number;
  64022. }
  64023. }
  64024. declare module BABYLON {
  64025. /**
  64026. * Defines an interface which represents an animation key frame
  64027. */
  64028. export interface IAnimationKey {
  64029. /**
  64030. * Frame of the key frame
  64031. */
  64032. frame: number;
  64033. /**
  64034. * Value at the specifies key frame
  64035. */
  64036. value: any;
  64037. /**
  64038. * The input tangent for the cubic hermite spline
  64039. */
  64040. inTangent?: any;
  64041. /**
  64042. * The output tangent for the cubic hermite spline
  64043. */
  64044. outTangent?: any;
  64045. /**
  64046. * The animation interpolation type
  64047. */
  64048. interpolation?: AnimationKeyInterpolation;
  64049. }
  64050. /**
  64051. * Enum for the animation key frame interpolation type
  64052. */
  64053. export enum AnimationKeyInterpolation {
  64054. /**
  64055. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64056. */
  64057. STEP = 1
  64058. }
  64059. }
  64060. declare module BABYLON {
  64061. /**
  64062. * Represents the range of an animation
  64063. */
  64064. export class AnimationRange {
  64065. /**The name of the animation range**/
  64066. name: string;
  64067. /**The starting frame of the animation */
  64068. from: number;
  64069. /**The ending frame of the animation*/
  64070. to: number;
  64071. /**
  64072. * Initializes the range of an animation
  64073. * @param name The name of the animation range
  64074. * @param from The starting frame of the animation
  64075. * @param to The ending frame of the animation
  64076. */
  64077. constructor(
  64078. /**The name of the animation range**/
  64079. name: string,
  64080. /**The starting frame of the animation */
  64081. from: number,
  64082. /**The ending frame of the animation*/
  64083. to: number);
  64084. /**
  64085. * Makes a copy of the animation range
  64086. * @returns A copy of the animation range
  64087. */
  64088. clone(): AnimationRange;
  64089. }
  64090. }
  64091. declare module BABYLON {
  64092. /**
  64093. * Composed of a frame, and an action function
  64094. */
  64095. export class AnimationEvent {
  64096. /** The frame for which the event is triggered **/
  64097. frame: number;
  64098. /** The event to perform when triggered **/
  64099. action: (currentFrame: number) => void;
  64100. /** Specifies if the event should be triggered only once**/
  64101. onlyOnce?: boolean | undefined;
  64102. /**
  64103. * Specifies if the animation event is done
  64104. */
  64105. isDone: boolean;
  64106. /**
  64107. * Initializes the animation event
  64108. * @param frame The frame for which the event is triggered
  64109. * @param action The event to perform when triggered
  64110. * @param onlyOnce Specifies if the event should be triggered only once
  64111. */
  64112. constructor(
  64113. /** The frame for which the event is triggered **/
  64114. frame: number,
  64115. /** The event to perform when triggered **/
  64116. action: (currentFrame: number) => void,
  64117. /** Specifies if the event should be triggered only once**/
  64118. onlyOnce?: boolean | undefined);
  64119. /** @hidden */
  64120. _clone(): AnimationEvent;
  64121. }
  64122. }
  64123. declare module BABYLON {
  64124. /**
  64125. * Interface used to define a behavior
  64126. */
  64127. export interface Behavior<T> {
  64128. /** gets or sets behavior's name */
  64129. name: string;
  64130. /**
  64131. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64132. */
  64133. init(): void;
  64134. /**
  64135. * Called when the behavior is attached to a target
  64136. * @param target defines the target where the behavior is attached to
  64137. */
  64138. attach(target: T): void;
  64139. /**
  64140. * Called when the behavior is detached from its target
  64141. */
  64142. detach(): void;
  64143. }
  64144. /**
  64145. * Interface implemented by classes supporting behaviors
  64146. */
  64147. export interface IBehaviorAware<T> {
  64148. /**
  64149. * Attach a behavior
  64150. * @param behavior defines the behavior to attach
  64151. * @returns the current host
  64152. */
  64153. addBehavior(behavior: Behavior<T>): T;
  64154. /**
  64155. * Remove a behavior from the current object
  64156. * @param behavior defines the behavior to detach
  64157. * @returns the current host
  64158. */
  64159. removeBehavior(behavior: Behavior<T>): T;
  64160. /**
  64161. * Gets a behavior using its name to search
  64162. * @param name defines the name to search
  64163. * @returns the behavior or null if not found
  64164. */
  64165. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64166. }
  64167. }
  64168. declare module BABYLON {
  64169. /**
  64170. * @hidden
  64171. */
  64172. export class IntersectionInfo {
  64173. bu: Nullable<number>;
  64174. bv: Nullable<number>;
  64175. distance: number;
  64176. faceId: number;
  64177. subMeshId: number;
  64178. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64179. }
  64180. }
  64181. declare module BABYLON {
  64182. /**
  64183. * Class used to store bounding sphere information
  64184. */
  64185. export class BoundingSphere {
  64186. /**
  64187. * Gets the center of the bounding sphere in local space
  64188. */
  64189. readonly center: Vector3;
  64190. /**
  64191. * Radius of the bounding sphere in local space
  64192. */
  64193. radius: number;
  64194. /**
  64195. * Gets the center of the bounding sphere in world space
  64196. */
  64197. readonly centerWorld: Vector3;
  64198. /**
  64199. * Radius of the bounding sphere in world space
  64200. */
  64201. radiusWorld: number;
  64202. /**
  64203. * Gets the minimum vector in local space
  64204. */
  64205. readonly minimum: Vector3;
  64206. /**
  64207. * Gets the maximum vector in local space
  64208. */
  64209. readonly maximum: Vector3;
  64210. private _worldMatrix;
  64211. private static readonly TmpVector3;
  64212. /**
  64213. * Creates a new bounding sphere
  64214. * @param min defines the minimum vector (in local space)
  64215. * @param max defines the maximum vector (in local space)
  64216. * @param worldMatrix defines the new world matrix
  64217. */
  64218. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64219. /**
  64220. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64221. * @param min defines the new minimum vector (in local space)
  64222. * @param max defines the new maximum vector (in local space)
  64223. * @param worldMatrix defines the new world matrix
  64224. */
  64225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64226. /**
  64227. * Scale the current bounding sphere by applying a scale factor
  64228. * @param factor defines the scale factor to apply
  64229. * @returns the current bounding box
  64230. */
  64231. scale(factor: number): BoundingSphere;
  64232. /**
  64233. * Gets the world matrix of the bounding box
  64234. * @returns a matrix
  64235. */
  64236. getWorldMatrix(): DeepImmutable<Matrix>;
  64237. /** @hidden */
  64238. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64239. /**
  64240. * Tests if the bounding sphere is intersecting the frustum planes
  64241. * @param frustumPlanes defines the frustum planes to test
  64242. * @returns true if there is an intersection
  64243. */
  64244. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64245. /**
  64246. * Tests if the bounding sphere center is in between the frustum planes.
  64247. * Used for optimistic fast inclusion.
  64248. * @param frustumPlanes defines the frustum planes to test
  64249. * @returns true if the sphere center is in between the frustum planes
  64250. */
  64251. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64252. /**
  64253. * Tests if a point is inside the bounding sphere
  64254. * @param point defines the point to test
  64255. * @returns true if the point is inside the bounding sphere
  64256. */
  64257. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64258. /**
  64259. * Checks if two sphere intersct
  64260. * @param sphere0 sphere 0
  64261. * @param sphere1 sphere 1
  64262. * @returns true if the speres intersect
  64263. */
  64264. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /**
  64269. * Class used to store bounding box information
  64270. */
  64271. export class BoundingBox implements ICullable {
  64272. /**
  64273. * Gets the 8 vectors representing the bounding box in local space
  64274. */
  64275. readonly vectors: Vector3[];
  64276. /**
  64277. * Gets the center of the bounding box in local space
  64278. */
  64279. readonly center: Vector3;
  64280. /**
  64281. * Gets the center of the bounding box in world space
  64282. */
  64283. readonly centerWorld: Vector3;
  64284. /**
  64285. * Gets the extend size in local space
  64286. */
  64287. readonly extendSize: Vector3;
  64288. /**
  64289. * Gets the extend size in world space
  64290. */
  64291. readonly extendSizeWorld: Vector3;
  64292. /**
  64293. * Gets the OBB (object bounding box) directions
  64294. */
  64295. readonly directions: Vector3[];
  64296. /**
  64297. * Gets the 8 vectors representing the bounding box in world space
  64298. */
  64299. readonly vectorsWorld: Vector3[];
  64300. /**
  64301. * Gets the minimum vector in world space
  64302. */
  64303. readonly minimumWorld: Vector3;
  64304. /**
  64305. * Gets the maximum vector in world space
  64306. */
  64307. readonly maximumWorld: Vector3;
  64308. /**
  64309. * Gets the minimum vector in local space
  64310. */
  64311. readonly minimum: Vector3;
  64312. /**
  64313. * Gets the maximum vector in local space
  64314. */
  64315. readonly maximum: Vector3;
  64316. private _worldMatrix;
  64317. private static readonly TmpVector3;
  64318. /**
  64319. * @hidden
  64320. */
  64321. _tag: number;
  64322. /**
  64323. * Creates a new bounding box
  64324. * @param min defines the minimum vector (in local space)
  64325. * @param max defines the maximum vector (in local space)
  64326. * @param worldMatrix defines the new world matrix
  64327. */
  64328. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64329. /**
  64330. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64331. * @param min defines the new minimum vector (in local space)
  64332. * @param max defines the new maximum vector (in local space)
  64333. * @param worldMatrix defines the new world matrix
  64334. */
  64335. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64336. /**
  64337. * Scale the current bounding box by applying a scale factor
  64338. * @param factor defines the scale factor to apply
  64339. * @returns the current bounding box
  64340. */
  64341. scale(factor: number): BoundingBox;
  64342. /**
  64343. * Gets the world matrix of the bounding box
  64344. * @returns a matrix
  64345. */
  64346. getWorldMatrix(): DeepImmutable<Matrix>;
  64347. /** @hidden */
  64348. _update(world: DeepImmutable<Matrix>): void;
  64349. /**
  64350. * Tests if the bounding box is intersecting the frustum planes
  64351. * @param frustumPlanes defines the frustum planes to test
  64352. * @returns true if there is an intersection
  64353. */
  64354. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64355. /**
  64356. * Tests if the bounding box is entirely inside the frustum planes
  64357. * @param frustumPlanes defines the frustum planes to test
  64358. * @returns true if there is an inclusion
  64359. */
  64360. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64361. /**
  64362. * Tests if a point is inside the bounding box
  64363. * @param point defines the point to test
  64364. * @returns true if the point is inside the bounding box
  64365. */
  64366. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64367. /**
  64368. * Tests if the bounding box intersects with a bounding sphere
  64369. * @param sphere defines the sphere to test
  64370. * @returns true if there is an intersection
  64371. */
  64372. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64373. /**
  64374. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64375. * @param min defines the min vector to use
  64376. * @param max defines the max vector to use
  64377. * @returns true if there is an intersection
  64378. */
  64379. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64380. /**
  64381. * Tests if two bounding boxes are intersections
  64382. * @param box0 defines the first box to test
  64383. * @param box1 defines the second box to test
  64384. * @returns true if there is an intersection
  64385. */
  64386. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64387. /**
  64388. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64389. * @param minPoint defines the minimum vector of the bounding box
  64390. * @param maxPoint defines the maximum vector of the bounding box
  64391. * @param sphereCenter defines the sphere center
  64392. * @param sphereRadius defines the sphere radius
  64393. * @returns true if there is an intersection
  64394. */
  64395. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64396. /**
  64397. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64398. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64399. * @param frustumPlanes defines the frustum planes to test
  64400. * @return true if there is an inclusion
  64401. */
  64402. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64403. /**
  64404. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64405. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64406. * @param frustumPlanes defines the frustum planes to test
  64407. * @return true if there is an intersection
  64408. */
  64409. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64410. }
  64411. }
  64412. declare module BABYLON {
  64413. /** @hidden */
  64414. export class Collider {
  64415. /** Define if a collision was found */
  64416. collisionFound: boolean;
  64417. /**
  64418. * Define last intersection point in local space
  64419. */
  64420. intersectionPoint: Vector3;
  64421. /**
  64422. * Define last collided mesh
  64423. */
  64424. collidedMesh: Nullable<AbstractMesh>;
  64425. private _collisionPoint;
  64426. private _planeIntersectionPoint;
  64427. private _tempVector;
  64428. private _tempVector2;
  64429. private _tempVector3;
  64430. private _tempVector4;
  64431. private _edge;
  64432. private _baseToVertex;
  64433. private _destinationPoint;
  64434. private _slidePlaneNormal;
  64435. private _displacementVector;
  64436. /** @hidden */
  64437. _radius: Vector3;
  64438. /** @hidden */
  64439. _retry: number;
  64440. private _velocity;
  64441. private _basePoint;
  64442. private _epsilon;
  64443. /** @hidden */
  64444. _velocityWorldLength: number;
  64445. /** @hidden */
  64446. _basePointWorld: Vector3;
  64447. private _velocityWorld;
  64448. private _normalizedVelocity;
  64449. /** @hidden */
  64450. _initialVelocity: Vector3;
  64451. /** @hidden */
  64452. _initialPosition: Vector3;
  64453. private _nearestDistance;
  64454. private _collisionMask;
  64455. collisionMask: number;
  64456. /**
  64457. * Gets the plane normal used to compute the sliding response (in local space)
  64458. */
  64459. readonly slidePlaneNormal: Vector3;
  64460. /** @hidden */
  64461. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64462. /** @hidden */
  64463. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64464. /** @hidden */
  64465. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64466. /** @hidden */
  64467. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64468. /** @hidden */
  64469. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64470. /** @hidden */
  64471. _getResponse(pos: Vector3, vel: Vector3): void;
  64472. }
  64473. }
  64474. declare module BABYLON {
  64475. /**
  64476. * Interface for cullable objects
  64477. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64478. */
  64479. export interface ICullable {
  64480. /**
  64481. * Checks if the object or part of the object is in the frustum
  64482. * @param frustumPlanes Camera near/planes
  64483. * @returns true if the object is in frustum otherwise false
  64484. */
  64485. isInFrustum(frustumPlanes: Plane[]): boolean;
  64486. /**
  64487. * Checks if a cullable object (mesh...) is in the camera frustum
  64488. * Unlike isInFrustum this cheks the full bounding box
  64489. * @param frustumPlanes Camera near/planes
  64490. * @returns true if the object is in frustum otherwise false
  64491. */
  64492. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64493. }
  64494. /**
  64495. * Info for a bounding data of a mesh
  64496. */
  64497. export class BoundingInfo implements ICullable {
  64498. /**
  64499. * Bounding box for the mesh
  64500. */
  64501. readonly boundingBox: BoundingBox;
  64502. /**
  64503. * Bounding sphere for the mesh
  64504. */
  64505. readonly boundingSphere: BoundingSphere;
  64506. private _isLocked;
  64507. private static readonly TmpVector3;
  64508. /**
  64509. * Constructs bounding info
  64510. * @param minimum min vector of the bounding box/sphere
  64511. * @param maximum max vector of the bounding box/sphere
  64512. * @param worldMatrix defines the new world matrix
  64513. */
  64514. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64515. /**
  64516. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64517. * @param min defines the new minimum vector (in local space)
  64518. * @param max defines the new maximum vector (in local space)
  64519. * @param worldMatrix defines the new world matrix
  64520. */
  64521. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64522. /**
  64523. * min vector of the bounding box/sphere
  64524. */
  64525. readonly minimum: Vector3;
  64526. /**
  64527. * max vector of the bounding box/sphere
  64528. */
  64529. readonly maximum: Vector3;
  64530. /**
  64531. * If the info is locked and won't be updated to avoid perf overhead
  64532. */
  64533. isLocked: boolean;
  64534. /**
  64535. * Updates the bounding sphere and box
  64536. * @param world world matrix to be used to update
  64537. */
  64538. update(world: DeepImmutable<Matrix>): void;
  64539. /**
  64540. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64541. * @param center New center of the bounding info
  64542. * @param extend New extend of the bounding info
  64543. * @returns the current bounding info
  64544. */
  64545. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64546. /**
  64547. * Scale the current bounding info by applying a scale factor
  64548. * @param factor defines the scale factor to apply
  64549. * @returns the current bounding info
  64550. */
  64551. scale(factor: number): BoundingInfo;
  64552. /**
  64553. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64554. * @param frustumPlanes defines the frustum to test
  64555. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64556. * @returns true if the bounding info is in the frustum planes
  64557. */
  64558. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64559. /**
  64560. * Gets the world distance between the min and max points of the bounding box
  64561. */
  64562. readonly diagonalLength: number;
  64563. /**
  64564. * Checks if a cullable object (mesh...) is in the camera frustum
  64565. * Unlike isInFrustum this cheks the full bounding box
  64566. * @param frustumPlanes Camera near/planes
  64567. * @returns true if the object is in frustum otherwise false
  64568. */
  64569. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64570. /** @hidden */
  64571. _checkCollision(collider: Collider): boolean;
  64572. /**
  64573. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64574. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64575. * @param point the point to check intersection with
  64576. * @returns if the point intersects
  64577. */
  64578. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64579. /**
  64580. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64581. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64582. * @param boundingInfo the bounding info to check intersection with
  64583. * @param precise if the intersection should be done using OBB
  64584. * @returns if the bounding info intersects
  64585. */
  64586. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64587. }
  64588. }
  64589. declare module BABYLON {
  64590. /**
  64591. * Defines an array and its length.
  64592. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64593. */
  64594. export interface ISmartArrayLike<T> {
  64595. /**
  64596. * The data of the array.
  64597. */
  64598. data: Array<T>;
  64599. /**
  64600. * The active length of the array.
  64601. */
  64602. length: number;
  64603. }
  64604. /**
  64605. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64606. */
  64607. export class SmartArray<T> implements ISmartArrayLike<T> {
  64608. /**
  64609. * The full set of data from the array.
  64610. */
  64611. data: Array<T>;
  64612. /**
  64613. * The active length of the array.
  64614. */
  64615. length: number;
  64616. protected _id: number;
  64617. /**
  64618. * Instantiates a Smart Array.
  64619. * @param capacity defines the default capacity of the array.
  64620. */
  64621. constructor(capacity: number);
  64622. /**
  64623. * Pushes a value at the end of the active data.
  64624. * @param value defines the object to push in the array.
  64625. */
  64626. push(value: T): void;
  64627. /**
  64628. * Iterates over the active data and apply the lambda to them.
  64629. * @param func defines the action to apply on each value.
  64630. */
  64631. forEach(func: (content: T) => void): void;
  64632. /**
  64633. * Sorts the full sets of data.
  64634. * @param compareFn defines the comparison function to apply.
  64635. */
  64636. sort(compareFn: (a: T, b: T) => number): void;
  64637. /**
  64638. * Resets the active data to an empty array.
  64639. */
  64640. reset(): void;
  64641. /**
  64642. * Releases all the data from the array as well as the array.
  64643. */
  64644. dispose(): void;
  64645. /**
  64646. * Concats the active data with a given array.
  64647. * @param array defines the data to concatenate with.
  64648. */
  64649. concat(array: any): void;
  64650. /**
  64651. * Returns the position of a value in the active data.
  64652. * @param value defines the value to find the index for
  64653. * @returns the index if found in the active data otherwise -1
  64654. */
  64655. indexOf(value: T): number;
  64656. /**
  64657. * Returns whether an element is part of the active data.
  64658. * @param value defines the value to look for
  64659. * @returns true if found in the active data otherwise false
  64660. */
  64661. contains(value: T): boolean;
  64662. private static _GlobalId;
  64663. }
  64664. /**
  64665. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64666. * The data in this array can only be present once
  64667. */
  64668. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64669. private _duplicateId;
  64670. /**
  64671. * Pushes a value at the end of the active data.
  64672. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64673. * @param value defines the object to push in the array.
  64674. */
  64675. push(value: T): void;
  64676. /**
  64677. * Pushes a value at the end of the active data.
  64678. * If the data is already present, it won t be added again
  64679. * @param value defines the object to push in the array.
  64680. * @returns true if added false if it was already present
  64681. */
  64682. pushNoDuplicate(value: T): boolean;
  64683. /**
  64684. * Resets the active data to an empty array.
  64685. */
  64686. reset(): void;
  64687. /**
  64688. * Concats the active data with a given array.
  64689. * This ensures no dupplicate will be present in the result.
  64690. * @param array defines the data to concatenate with.
  64691. */
  64692. concatWithNoDuplicate(array: any): void;
  64693. }
  64694. }
  64695. declare module BABYLON {
  64696. /**
  64697. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64698. * separate meshes. This can be use to improve performances.
  64699. * @see http://doc.babylonjs.com/how_to/multi_materials
  64700. */
  64701. export class MultiMaterial extends Material {
  64702. private _subMaterials;
  64703. /**
  64704. * Gets or Sets the list of Materials used within the multi material.
  64705. * They need to be ordered according to the submeshes order in the associated mesh
  64706. */
  64707. subMaterials: Nullable<Material>[];
  64708. /**
  64709. * Function used to align with Node.getChildren()
  64710. * @returns the list of Materials used within the multi material
  64711. */
  64712. getChildren(): Nullable<Material>[];
  64713. /**
  64714. * Instantiates a new Multi Material
  64715. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64716. * separate meshes. This can be use to improve performances.
  64717. * @see http://doc.babylonjs.com/how_to/multi_materials
  64718. * @param name Define the name in the scene
  64719. * @param scene Define the scene the material belongs to
  64720. */
  64721. constructor(name: string, scene: Scene);
  64722. private _hookArray;
  64723. /**
  64724. * Get one of the submaterial by its index in the submaterials array
  64725. * @param index The index to look the sub material at
  64726. * @returns The Material if the index has been defined
  64727. */
  64728. getSubMaterial(index: number): Nullable<Material>;
  64729. /**
  64730. * Get the list of active textures for the whole sub materials list.
  64731. * @returns All the textures that will be used during the rendering
  64732. */
  64733. getActiveTextures(): BaseTexture[];
  64734. /**
  64735. * Gets the current class name of the material e.g. "MultiMaterial"
  64736. * Mainly use in serialization.
  64737. * @returns the class name
  64738. */
  64739. getClassName(): string;
  64740. /**
  64741. * Checks if the material is ready to render the requested sub mesh
  64742. * @param mesh Define the mesh the submesh belongs to
  64743. * @param subMesh Define the sub mesh to look readyness for
  64744. * @param useInstances Define whether or not the material is used with instances
  64745. * @returns true if ready, otherwise false
  64746. */
  64747. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64748. /**
  64749. * Clones the current material and its related sub materials
  64750. * @param name Define the name of the newly cloned material
  64751. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64752. * @returns the cloned material
  64753. */
  64754. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64755. /**
  64756. * Serializes the materials into a JSON representation.
  64757. * @returns the JSON representation
  64758. */
  64759. serialize(): any;
  64760. /**
  64761. * Dispose the material and release its associated resources
  64762. * @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)
  64763. * @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)
  64764. * @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)
  64765. */
  64766. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64767. /**
  64768. * Creates a MultiMaterial from parsed MultiMaterial data.
  64769. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64770. * @param scene defines the hosting scene
  64771. * @returns a new MultiMaterial
  64772. */
  64773. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64774. }
  64775. }
  64776. declare module BABYLON {
  64777. /**
  64778. * Class used to represent data loading progression
  64779. */
  64780. export class SceneLoaderFlags {
  64781. private static _ForceFullSceneLoadingForIncremental;
  64782. private static _ShowLoadingScreen;
  64783. private static _CleanBoneMatrixWeights;
  64784. private static _loggingLevel;
  64785. /**
  64786. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64787. */
  64788. static ForceFullSceneLoadingForIncremental: boolean;
  64789. /**
  64790. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64791. */
  64792. static ShowLoadingScreen: boolean;
  64793. /**
  64794. * Defines the current logging level (while loading the scene)
  64795. * @ignorenaming
  64796. */
  64797. static loggingLevel: number;
  64798. /**
  64799. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64800. */
  64801. static CleanBoneMatrixWeights: boolean;
  64802. }
  64803. }
  64804. declare module BABYLON {
  64805. /**
  64806. * 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.
  64807. * @see https://doc.babylonjs.com/how_to/transformnode
  64808. */
  64809. export class TransformNode extends Node {
  64810. /**
  64811. * Object will not rotate to face the camera
  64812. */
  64813. static BILLBOARDMODE_NONE: number;
  64814. /**
  64815. * Object will rotate to face the camera but only on the x axis
  64816. */
  64817. static BILLBOARDMODE_X: number;
  64818. /**
  64819. * Object will rotate to face the camera but only on the y axis
  64820. */
  64821. static BILLBOARDMODE_Y: number;
  64822. /**
  64823. * Object will rotate to face the camera but only on the z axis
  64824. */
  64825. static BILLBOARDMODE_Z: number;
  64826. /**
  64827. * Object will rotate to face the camera
  64828. */
  64829. static BILLBOARDMODE_ALL: number;
  64830. private _forward;
  64831. private _forwardInverted;
  64832. private _up;
  64833. private _right;
  64834. private _rightInverted;
  64835. private _position;
  64836. private _rotation;
  64837. private _rotationQuaternion;
  64838. protected _scaling: Vector3;
  64839. protected _isDirty: boolean;
  64840. private _transformToBoneReferal;
  64841. /**
  64842. * Set the billboard mode. Default is 0.
  64843. *
  64844. * | Value | Type | Description |
  64845. * | --- | --- | --- |
  64846. * | 0 | BILLBOARDMODE_NONE | |
  64847. * | 1 | BILLBOARDMODE_X | |
  64848. * | 2 | BILLBOARDMODE_Y | |
  64849. * | 4 | BILLBOARDMODE_Z | |
  64850. * | 7 | BILLBOARDMODE_ALL | |
  64851. *
  64852. */
  64853. billboardMode: number;
  64854. /**
  64855. * 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
  64856. */
  64857. scalingDeterminant: number;
  64858. /**
  64859. * Sets the distance of the object to max, often used by skybox
  64860. */
  64861. infiniteDistance: boolean;
  64862. /**
  64863. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64864. * By default the system will update normals to compensate
  64865. */
  64866. ignoreNonUniformScaling: boolean;
  64867. /** @hidden */
  64868. _poseMatrix: Matrix;
  64869. /** @hidden */
  64870. _localMatrix: Matrix;
  64871. private _absolutePosition;
  64872. private _pivotMatrix;
  64873. private _pivotMatrixInverse;
  64874. protected _postMultiplyPivotMatrix: boolean;
  64875. private _tempMatrix;
  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. * Called on JS contextmenu event.
  69370. * Override this method to provide functionality.
  69371. */
  69372. protected onContextMenu(evt: PointerEvent): void;
  69373. /**
  69374. * Detach the current controls from the specified dom element.
  69375. * @param element Defines the element to stop listening the inputs from
  69376. */
  69377. detachControl(element: Nullable<HTMLElement>): void;
  69378. /**
  69379. * Gets the class name of the current intput.
  69380. * @returns the class name
  69381. */
  69382. getClassName(): string;
  69383. /**
  69384. * Get the friendly name associated with the input class.
  69385. * @returns the input friendly name
  69386. */
  69387. getSimpleName(): string;
  69388. }
  69389. }
  69390. declare module BABYLON {
  69391. /**
  69392. * Manage the touch inputs to control the movement of a free camera.
  69393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69394. */
  69395. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69396. /**
  69397. * Defines the camera the input is attached to.
  69398. */
  69399. camera: FreeCamera;
  69400. /**
  69401. * Defines the touch sensibility for rotation.
  69402. * The higher the faster.
  69403. */
  69404. touchAngularSensibility: number;
  69405. /**
  69406. * Defines the touch sensibility for move.
  69407. * The higher the faster.
  69408. */
  69409. touchMoveSensibility: number;
  69410. private _offsetX;
  69411. private _offsetY;
  69412. private _pointerPressed;
  69413. private _pointerInput;
  69414. private _observer;
  69415. private _onLostFocus;
  69416. /**
  69417. * Attach the input controls to a specific dom element to get the input from.
  69418. * @param element Defines the element the controls should be listened from
  69419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69420. */
  69421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69422. /**
  69423. * Detach the current controls from the specified dom element.
  69424. * @param element Defines the element to stop listening the inputs from
  69425. */
  69426. detachControl(element: Nullable<HTMLElement>): void;
  69427. /**
  69428. * Update the current camera state depending on the inputs that have been used this frame.
  69429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69430. */
  69431. checkInputs(): void;
  69432. /**
  69433. * Gets the class name of the current intput.
  69434. * @returns the class name
  69435. */
  69436. getClassName(): string;
  69437. /**
  69438. * Get the friendly name associated with the input class.
  69439. * @returns the input friendly name
  69440. */
  69441. getSimpleName(): string;
  69442. }
  69443. }
  69444. declare module BABYLON {
  69445. /**
  69446. * Default Inputs manager for the FreeCamera.
  69447. * It groups all the default supported inputs for ease of use.
  69448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69449. */
  69450. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69451. /**
  69452. * Instantiates a new FreeCameraInputsManager.
  69453. * @param camera Defines the camera the inputs belong to
  69454. */
  69455. constructor(camera: FreeCamera);
  69456. /**
  69457. * Add keyboard input support to the input manager.
  69458. * @returns the current input manager
  69459. */
  69460. addKeyboard(): FreeCameraInputsManager;
  69461. /**
  69462. * Add mouse input support to the input manager.
  69463. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69464. * @returns the current input manager
  69465. */
  69466. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69467. /**
  69468. * Add touch input support to the input manager.
  69469. * @returns the current input manager
  69470. */
  69471. addTouch(): FreeCameraInputsManager;
  69472. }
  69473. }
  69474. declare module BABYLON {
  69475. /**
  69476. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69477. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69478. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69479. */
  69480. export class FreeCamera extends TargetCamera {
  69481. /**
  69482. * Define the collision ellipsoid of the camera.
  69483. * This is helpful to simulate a camera body like the player body around the camera
  69484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69485. */
  69486. ellipsoid: Vector3;
  69487. /**
  69488. * Define an offset for the position of the ellipsoid around the camera.
  69489. * This can be helpful to determine the center of the body near the gravity center of the body
  69490. * instead of its head.
  69491. */
  69492. ellipsoidOffset: Vector3;
  69493. /**
  69494. * Enable or disable collisions of the camera with the rest of the scene objects.
  69495. */
  69496. checkCollisions: boolean;
  69497. /**
  69498. * Enable or disable gravity on the camera.
  69499. */
  69500. applyGravity: boolean;
  69501. /**
  69502. * Define the input manager associated to the camera.
  69503. */
  69504. inputs: FreeCameraInputsManager;
  69505. /**
  69506. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69507. * Higher values reduce sensitivity.
  69508. */
  69509. /**
  69510. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69511. * Higher values reduce sensitivity.
  69512. */
  69513. angularSensibility: number;
  69514. /**
  69515. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69516. */
  69517. keysUp: number[];
  69518. /**
  69519. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69520. */
  69521. keysDown: number[];
  69522. /**
  69523. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69524. */
  69525. keysLeft: number[];
  69526. /**
  69527. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69528. */
  69529. keysRight: number[];
  69530. /**
  69531. * Event raised when the camera collide with a mesh in the scene.
  69532. */
  69533. onCollide: (collidedMesh: AbstractMesh) => void;
  69534. private _collider;
  69535. private _needMoveForGravity;
  69536. private _oldPosition;
  69537. private _diffPosition;
  69538. private _newPosition;
  69539. /** @hidden */
  69540. _localDirection: Vector3;
  69541. /** @hidden */
  69542. _transformedDirection: Vector3;
  69543. /**
  69544. * Instantiates a Free Camera.
  69545. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69546. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69548. * @param name Define the name of the camera in the scene
  69549. * @param position Define the start position of the camera in the scene
  69550. * @param scene Define the scene the camera belongs to
  69551. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69552. */
  69553. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69554. /**
  69555. * Attached controls to the current camera.
  69556. * @param element Defines the element the controls should be listened from
  69557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69558. */
  69559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69560. /**
  69561. * Detach the current controls from the camera.
  69562. * The camera will stop reacting to inputs.
  69563. * @param element Defines the element to stop listening the inputs from
  69564. */
  69565. detachControl(element: HTMLElement): void;
  69566. private _collisionMask;
  69567. /**
  69568. * Define a collision mask to limit the list of object the camera can collide with
  69569. */
  69570. collisionMask: number;
  69571. /** @hidden */
  69572. _collideWithWorld(displacement: Vector3): void;
  69573. private _onCollisionPositionChange;
  69574. /** @hidden */
  69575. _checkInputs(): void;
  69576. /** @hidden */
  69577. _decideIfNeedsToMove(): boolean;
  69578. /** @hidden */
  69579. _updatePosition(): void;
  69580. /**
  69581. * Destroy the camera and release the current resources hold by it.
  69582. */
  69583. dispose(): void;
  69584. /**
  69585. * Gets the current object class name.
  69586. * @return the class name
  69587. */
  69588. getClassName(): string;
  69589. }
  69590. }
  69591. declare module BABYLON {
  69592. /**
  69593. * Represents a gamepad control stick position
  69594. */
  69595. export class StickValues {
  69596. /**
  69597. * The x component of the control stick
  69598. */
  69599. x: number;
  69600. /**
  69601. * The y component of the control stick
  69602. */
  69603. y: number;
  69604. /**
  69605. * Initializes the gamepad x and y control stick values
  69606. * @param x The x component of the gamepad control stick value
  69607. * @param y The y component of the gamepad control stick value
  69608. */
  69609. constructor(
  69610. /**
  69611. * The x component of the control stick
  69612. */
  69613. x: number,
  69614. /**
  69615. * The y component of the control stick
  69616. */
  69617. y: number);
  69618. }
  69619. /**
  69620. * An interface which manages callbacks for gamepad button changes
  69621. */
  69622. export interface GamepadButtonChanges {
  69623. /**
  69624. * Called when a gamepad has been changed
  69625. */
  69626. changed: boolean;
  69627. /**
  69628. * Called when a gamepad press event has been triggered
  69629. */
  69630. pressChanged: boolean;
  69631. /**
  69632. * Called when a touch event has been triggered
  69633. */
  69634. touchChanged: boolean;
  69635. /**
  69636. * Called when a value has changed
  69637. */
  69638. valueChanged: boolean;
  69639. }
  69640. /**
  69641. * Represents a gamepad
  69642. */
  69643. export class Gamepad {
  69644. /**
  69645. * The id of the gamepad
  69646. */
  69647. id: string;
  69648. /**
  69649. * The index of the gamepad
  69650. */
  69651. index: number;
  69652. /**
  69653. * The browser gamepad
  69654. */
  69655. browserGamepad: any;
  69656. /**
  69657. * Specifies what type of gamepad this represents
  69658. */
  69659. type: number;
  69660. private _leftStick;
  69661. private _rightStick;
  69662. /** @hidden */
  69663. _isConnected: boolean;
  69664. private _leftStickAxisX;
  69665. private _leftStickAxisY;
  69666. private _rightStickAxisX;
  69667. private _rightStickAxisY;
  69668. /**
  69669. * Triggered when the left control stick has been changed
  69670. */
  69671. private _onleftstickchanged;
  69672. /**
  69673. * Triggered when the right control stick has been changed
  69674. */
  69675. private _onrightstickchanged;
  69676. /**
  69677. * Represents a gamepad controller
  69678. */
  69679. static GAMEPAD: number;
  69680. /**
  69681. * Represents a generic controller
  69682. */
  69683. static GENERIC: number;
  69684. /**
  69685. * Represents an XBox controller
  69686. */
  69687. static XBOX: number;
  69688. /**
  69689. * Represents a pose-enabled controller
  69690. */
  69691. static POSE_ENABLED: number;
  69692. /**
  69693. * Specifies whether the left control stick should be Y-inverted
  69694. */
  69695. protected _invertLeftStickY: boolean;
  69696. /**
  69697. * Specifies if the gamepad has been connected
  69698. */
  69699. readonly isConnected: boolean;
  69700. /**
  69701. * Initializes the gamepad
  69702. * @param id The id of the gamepad
  69703. * @param index The index of the gamepad
  69704. * @param browserGamepad The browser gamepad
  69705. * @param leftStickX The x component of the left joystick
  69706. * @param leftStickY The y component of the left joystick
  69707. * @param rightStickX The x component of the right joystick
  69708. * @param rightStickY The y component of the right joystick
  69709. */
  69710. constructor(
  69711. /**
  69712. * The id of the gamepad
  69713. */
  69714. id: string,
  69715. /**
  69716. * The index of the gamepad
  69717. */
  69718. index: number,
  69719. /**
  69720. * The browser gamepad
  69721. */
  69722. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69723. /**
  69724. * Callback triggered when the left joystick has changed
  69725. * @param callback
  69726. */
  69727. onleftstickchanged(callback: (values: StickValues) => void): void;
  69728. /**
  69729. * Callback triggered when the right joystick has changed
  69730. * @param callback
  69731. */
  69732. onrightstickchanged(callback: (values: StickValues) => void): void;
  69733. /**
  69734. * Gets the left joystick
  69735. */
  69736. /**
  69737. * Sets the left joystick values
  69738. */
  69739. leftStick: StickValues;
  69740. /**
  69741. * Gets the right joystick
  69742. */
  69743. /**
  69744. * Sets the right joystick value
  69745. */
  69746. rightStick: StickValues;
  69747. /**
  69748. * Updates the gamepad joystick positions
  69749. */
  69750. update(): void;
  69751. /**
  69752. * Disposes the gamepad
  69753. */
  69754. dispose(): void;
  69755. }
  69756. /**
  69757. * Represents a generic gamepad
  69758. */
  69759. export class GenericPad extends Gamepad {
  69760. private _buttons;
  69761. private _onbuttondown;
  69762. private _onbuttonup;
  69763. /**
  69764. * Observable triggered when a button has been pressed
  69765. */
  69766. onButtonDownObservable: Observable<number>;
  69767. /**
  69768. * Observable triggered when a button has been released
  69769. */
  69770. onButtonUpObservable: Observable<number>;
  69771. /**
  69772. * Callback triggered when a button has been pressed
  69773. * @param callback Called when a button has been pressed
  69774. */
  69775. onbuttondown(callback: (buttonPressed: number) => void): void;
  69776. /**
  69777. * Callback triggered when a button has been released
  69778. * @param callback Called when a button has been released
  69779. */
  69780. onbuttonup(callback: (buttonReleased: number) => void): void;
  69781. /**
  69782. * Initializes the generic gamepad
  69783. * @param id The id of the generic gamepad
  69784. * @param index The index of the generic gamepad
  69785. * @param browserGamepad The browser gamepad
  69786. */
  69787. constructor(id: string, index: number, browserGamepad: any);
  69788. private _setButtonValue;
  69789. /**
  69790. * Updates the generic gamepad
  69791. */
  69792. update(): void;
  69793. /**
  69794. * Disposes the generic gamepad
  69795. */
  69796. dispose(): void;
  69797. }
  69798. }
  69799. declare module BABYLON {
  69800. /**
  69801. * Defines the types of pose enabled controllers that are supported
  69802. */
  69803. export enum PoseEnabledControllerType {
  69804. /**
  69805. * HTC Vive
  69806. */
  69807. VIVE = 0,
  69808. /**
  69809. * Oculus Rift
  69810. */
  69811. OCULUS = 1,
  69812. /**
  69813. * Windows mixed reality
  69814. */
  69815. WINDOWS = 2,
  69816. /**
  69817. * Samsung gear VR
  69818. */
  69819. GEAR_VR = 3,
  69820. /**
  69821. * Google Daydream
  69822. */
  69823. DAYDREAM = 4,
  69824. /**
  69825. * Generic
  69826. */
  69827. GENERIC = 5
  69828. }
  69829. /**
  69830. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69831. */
  69832. export interface MutableGamepadButton {
  69833. /**
  69834. * Value of the button/trigger
  69835. */
  69836. value: number;
  69837. /**
  69838. * If the button/trigger is currently touched
  69839. */
  69840. touched: boolean;
  69841. /**
  69842. * If the button/trigger is currently pressed
  69843. */
  69844. pressed: boolean;
  69845. }
  69846. /**
  69847. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69848. * @hidden
  69849. */
  69850. export interface ExtendedGamepadButton extends GamepadButton {
  69851. /**
  69852. * If the button/trigger is currently pressed
  69853. */
  69854. readonly pressed: boolean;
  69855. /**
  69856. * If the button/trigger is currently touched
  69857. */
  69858. readonly touched: boolean;
  69859. /**
  69860. * Value of the button/trigger
  69861. */
  69862. readonly value: number;
  69863. }
  69864. /** @hidden */
  69865. export interface _GamePadFactory {
  69866. /**
  69867. * Returns wether or not the current gamepad can be created for this type of controller.
  69868. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69869. * @returns true if it can be created, otherwise false
  69870. */
  69871. canCreate(gamepadInfo: any): boolean;
  69872. /**
  69873. * Creates a new instance of the Gamepad.
  69874. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69875. * @returns the new gamepad instance
  69876. */
  69877. create(gamepadInfo: any): Gamepad;
  69878. }
  69879. /**
  69880. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69881. */
  69882. export class PoseEnabledControllerHelper {
  69883. /** @hidden */
  69884. static _ControllerFactories: _GamePadFactory[];
  69885. /** @hidden */
  69886. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69887. /**
  69888. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69889. * @param vrGamepad the gamepad to initialized
  69890. * @returns a vr controller of the type the gamepad identified as
  69891. */
  69892. static InitiateController(vrGamepad: any): Gamepad;
  69893. }
  69894. /**
  69895. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69896. */
  69897. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69898. private _deviceRoomPosition;
  69899. private _deviceRoomRotationQuaternion;
  69900. /**
  69901. * The device position in babylon space
  69902. */
  69903. devicePosition: Vector3;
  69904. /**
  69905. * The device rotation in babylon space
  69906. */
  69907. deviceRotationQuaternion: Quaternion;
  69908. /**
  69909. * The scale factor of the device in babylon space
  69910. */
  69911. deviceScaleFactor: number;
  69912. /**
  69913. * (Likely devicePosition should be used instead) The device position in its room space
  69914. */
  69915. position: Vector3;
  69916. /**
  69917. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69918. */
  69919. rotationQuaternion: Quaternion;
  69920. /**
  69921. * The type of controller (Eg. Windows mixed reality)
  69922. */
  69923. controllerType: PoseEnabledControllerType;
  69924. protected _calculatedPosition: Vector3;
  69925. private _calculatedRotation;
  69926. /**
  69927. * The raw pose from the device
  69928. */
  69929. rawPose: DevicePose;
  69930. private _trackPosition;
  69931. private _maxRotationDistFromHeadset;
  69932. private _draggedRoomRotation;
  69933. /**
  69934. * @hidden
  69935. */
  69936. _disableTrackPosition(fixedPosition: Vector3): void;
  69937. /**
  69938. * Internal, the mesh attached to the controller
  69939. * @hidden
  69940. */
  69941. _mesh: Nullable<AbstractMesh>;
  69942. private _poseControlledCamera;
  69943. private _leftHandSystemQuaternion;
  69944. /**
  69945. * Internal, matrix used to convert room space to babylon space
  69946. * @hidden
  69947. */
  69948. _deviceToWorld: Matrix;
  69949. /**
  69950. * Node to be used when casting a ray from the controller
  69951. * @hidden
  69952. */
  69953. _pointingPoseNode: Nullable<TransformNode>;
  69954. /**
  69955. * Name of the child mesh that can be used to cast a ray from the controller
  69956. */
  69957. static readonly POINTING_POSE: string;
  69958. /**
  69959. * Creates a new PoseEnabledController from a gamepad
  69960. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69961. */
  69962. constructor(browserGamepad: any);
  69963. private _workingMatrix;
  69964. /**
  69965. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69966. */
  69967. update(): void;
  69968. /**
  69969. * Updates only the pose device and mesh without doing any button event checking
  69970. */
  69971. protected _updatePoseAndMesh(): void;
  69972. /**
  69973. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69974. * @param poseData raw pose fromthe device
  69975. */
  69976. updateFromDevice(poseData: DevicePose): void;
  69977. /**
  69978. * @hidden
  69979. */
  69980. _meshAttachedObservable: Observable<AbstractMesh>;
  69981. /**
  69982. * Attaches a mesh to the controller
  69983. * @param mesh the mesh to be attached
  69984. */
  69985. attachToMesh(mesh: AbstractMesh): void;
  69986. /**
  69987. * Attaches the controllers mesh to a camera
  69988. * @param camera the camera the mesh should be attached to
  69989. */
  69990. attachToPoseControlledCamera(camera: TargetCamera): void;
  69991. /**
  69992. * Disposes of the controller
  69993. */
  69994. dispose(): void;
  69995. /**
  69996. * The mesh that is attached to the controller
  69997. */
  69998. readonly mesh: Nullable<AbstractMesh>;
  69999. /**
  70000. * Gets the ray of the controller in the direction the controller is pointing
  70001. * @param length the length the resulting ray should be
  70002. * @returns a ray in the direction the controller is pointing
  70003. */
  70004. getForwardRay(length?: number): Ray;
  70005. }
  70006. }
  70007. declare module BABYLON {
  70008. /**
  70009. * Defines the WebVRController object that represents controllers tracked in 3D space
  70010. */
  70011. export abstract class WebVRController extends PoseEnabledController {
  70012. /**
  70013. * Internal, the default controller model for the controller
  70014. */
  70015. protected _defaultModel: AbstractMesh;
  70016. /**
  70017. * Fired when the trigger state has changed
  70018. */
  70019. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70020. /**
  70021. * Fired when the main button state has changed
  70022. */
  70023. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70024. /**
  70025. * Fired when the secondary button state has changed
  70026. */
  70027. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70028. /**
  70029. * Fired when the pad state has changed
  70030. */
  70031. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70032. /**
  70033. * Fired when controllers stick values have changed
  70034. */
  70035. onPadValuesChangedObservable: Observable<StickValues>;
  70036. /**
  70037. * Array of button availible on the controller
  70038. */
  70039. protected _buttons: Array<MutableGamepadButton>;
  70040. private _onButtonStateChange;
  70041. /**
  70042. * Fired when a controller button's state has changed
  70043. * @param callback the callback containing the button that was modified
  70044. */
  70045. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70046. /**
  70047. * X and Y axis corrisponding to the controllers joystick
  70048. */
  70049. pad: StickValues;
  70050. /**
  70051. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70052. */
  70053. hand: string;
  70054. /**
  70055. * The default controller model for the controller
  70056. */
  70057. readonly defaultModel: AbstractMesh;
  70058. /**
  70059. * Creates a new WebVRController from a gamepad
  70060. * @param vrGamepad the gamepad that the WebVRController should be created from
  70061. */
  70062. constructor(vrGamepad: any);
  70063. /**
  70064. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70065. */
  70066. update(): void;
  70067. /**
  70068. * Function to be called when a button is modified
  70069. */
  70070. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70071. /**
  70072. * Loads a mesh and attaches it to the controller
  70073. * @param scene the scene the mesh should be added to
  70074. * @param meshLoaded callback for when the mesh has been loaded
  70075. */
  70076. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70077. private _setButtonValue;
  70078. private _changes;
  70079. private _checkChanges;
  70080. /**
  70081. * Disposes of th webVRCOntroller
  70082. */
  70083. dispose(): void;
  70084. }
  70085. }
  70086. declare module BABYLON {
  70087. /**
  70088. * The HemisphericLight simulates the ambient environment light,
  70089. * so the passed direction is the light reflection direction, not the incoming direction.
  70090. */
  70091. export class HemisphericLight extends Light {
  70092. /**
  70093. * The groundColor is the light in the opposite direction to the one specified during creation.
  70094. * 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.
  70095. */
  70096. groundColor: Color3;
  70097. /**
  70098. * The light reflection direction, not the incoming direction.
  70099. */
  70100. direction: Vector3;
  70101. /**
  70102. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70103. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70104. * The HemisphericLight can't cast shadows.
  70105. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70106. * @param name The friendly name of the light
  70107. * @param direction The direction of the light reflection
  70108. * @param scene The scene the light belongs to
  70109. */
  70110. constructor(name: string, direction: Vector3, scene: Scene);
  70111. protected _buildUniformLayout(): void;
  70112. /**
  70113. * Returns the string "HemisphericLight".
  70114. * @return The class name
  70115. */
  70116. getClassName(): string;
  70117. /**
  70118. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70119. * Returns the updated direction.
  70120. * @param target The target the direction should point to
  70121. * @return The computed direction
  70122. */
  70123. setDirectionToTarget(target: Vector3): Vector3;
  70124. /**
  70125. * Returns the shadow generator associated to the light.
  70126. * @returns Always null for hemispheric lights because it does not support shadows.
  70127. */
  70128. getShadowGenerator(): Nullable<IShadowGenerator>;
  70129. /**
  70130. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70131. * @param effect The effect to update
  70132. * @param lightIndex The index of the light in the effect to update
  70133. * @returns The hemispheric light
  70134. */
  70135. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70136. /**
  70137. * Computes the world matrix of the node
  70138. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70139. * @param useWasUpdatedFlag defines a reserved property
  70140. * @returns the world matrix
  70141. */
  70142. computeWorldMatrix(): Matrix;
  70143. /**
  70144. * Returns the integer 3.
  70145. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70146. */
  70147. getTypeID(): number;
  70148. /**
  70149. * Prepares the list of defines specific to the light type.
  70150. * @param defines the list of defines
  70151. * @param lightIndex defines the index of the light for the effect
  70152. */
  70153. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70154. }
  70155. }
  70156. declare module BABYLON {
  70157. /**
  70158. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70159. * IMPORTANT!! The data is right-hand data.
  70160. * @export
  70161. * @interface DevicePose
  70162. */
  70163. export interface DevicePose {
  70164. /**
  70165. * The position of the device, values in array are [x,y,z].
  70166. */
  70167. readonly position: Nullable<Float32Array>;
  70168. /**
  70169. * The linearVelocity of the device, values in array are [x,y,z].
  70170. */
  70171. readonly linearVelocity: Nullable<Float32Array>;
  70172. /**
  70173. * The linearAcceleration of the device, values in array are [x,y,z].
  70174. */
  70175. readonly linearAcceleration: Nullable<Float32Array>;
  70176. /**
  70177. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70178. */
  70179. readonly orientation: Nullable<Float32Array>;
  70180. /**
  70181. * The angularVelocity of the device, values in array are [x,y,z].
  70182. */
  70183. readonly angularVelocity: Nullable<Float32Array>;
  70184. /**
  70185. * The angularAcceleration of the device, values in array are [x,y,z].
  70186. */
  70187. readonly angularAcceleration: Nullable<Float32Array>;
  70188. }
  70189. /**
  70190. * Interface representing a pose controlled object in Babylon.
  70191. * A pose controlled object has both regular pose values as well as pose values
  70192. * from an external device such as a VR head mounted display
  70193. */
  70194. export interface PoseControlled {
  70195. /**
  70196. * The position of the object in babylon space.
  70197. */
  70198. position: Vector3;
  70199. /**
  70200. * The rotation quaternion of the object in babylon space.
  70201. */
  70202. rotationQuaternion: Quaternion;
  70203. /**
  70204. * The position of the device in babylon space.
  70205. */
  70206. devicePosition?: Vector3;
  70207. /**
  70208. * The rotation quaternion of the device in babylon space.
  70209. */
  70210. deviceRotationQuaternion: Quaternion;
  70211. /**
  70212. * The raw pose coming from the device.
  70213. */
  70214. rawPose: Nullable<DevicePose>;
  70215. /**
  70216. * The scale of the device to be used when translating from device space to babylon space.
  70217. */
  70218. deviceScaleFactor: number;
  70219. /**
  70220. * Updates the poseControlled values based on the input device pose.
  70221. * @param poseData the pose data to update the object with
  70222. */
  70223. updateFromDevice(poseData: DevicePose): void;
  70224. }
  70225. /**
  70226. * Set of options to customize the webVRCamera
  70227. */
  70228. export interface WebVROptions {
  70229. /**
  70230. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70231. */
  70232. trackPosition?: boolean;
  70233. /**
  70234. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70235. */
  70236. positionScale?: number;
  70237. /**
  70238. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70239. */
  70240. displayName?: string;
  70241. /**
  70242. * Should the native controller meshes be initialized. (default: true)
  70243. */
  70244. controllerMeshes?: boolean;
  70245. /**
  70246. * Creating a default HemiLight only on controllers. (default: true)
  70247. */
  70248. defaultLightingOnControllers?: boolean;
  70249. /**
  70250. * If you don't want to use the default VR button of the helper. (default: false)
  70251. */
  70252. useCustomVRButton?: boolean;
  70253. /**
  70254. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70255. */
  70256. customVRButton?: HTMLButtonElement;
  70257. /**
  70258. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70259. */
  70260. rayLength?: number;
  70261. /**
  70262. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70263. */
  70264. defaultHeight?: number;
  70265. }
  70266. /**
  70267. * This represents a WebVR camera.
  70268. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70269. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70270. */
  70271. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70272. private webVROptions;
  70273. /**
  70274. * @hidden
  70275. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70276. */
  70277. _vrDevice: any;
  70278. /**
  70279. * The rawPose of the vrDevice.
  70280. */
  70281. rawPose: Nullable<DevicePose>;
  70282. private _onVREnabled;
  70283. private _specsVersion;
  70284. private _attached;
  70285. private _frameData;
  70286. protected _descendants: Array<Node>;
  70287. private _deviceRoomPosition;
  70288. /** @hidden */
  70289. _deviceRoomRotationQuaternion: Quaternion;
  70290. private _standingMatrix;
  70291. /**
  70292. * Represents device position in babylon space.
  70293. */
  70294. devicePosition: Vector3;
  70295. /**
  70296. * Represents device rotation in babylon space.
  70297. */
  70298. deviceRotationQuaternion: Quaternion;
  70299. /**
  70300. * The scale of the device to be used when translating from device space to babylon space.
  70301. */
  70302. deviceScaleFactor: number;
  70303. private _deviceToWorld;
  70304. private _worldToDevice;
  70305. /**
  70306. * References to the webVR controllers for the vrDevice.
  70307. */
  70308. controllers: Array<WebVRController>;
  70309. /**
  70310. * Emits an event when a controller is attached.
  70311. */
  70312. onControllersAttachedObservable: Observable<WebVRController[]>;
  70313. /**
  70314. * Emits an event when a controller's mesh has been loaded;
  70315. */
  70316. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70317. /**
  70318. * Emits an event when the HMD's pose has been updated.
  70319. */
  70320. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70321. private _poseSet;
  70322. /**
  70323. * If the rig cameras be used as parent instead of this camera.
  70324. */
  70325. rigParenting: boolean;
  70326. private _lightOnControllers;
  70327. private _defaultHeight?;
  70328. /**
  70329. * Instantiates a WebVRFreeCamera.
  70330. * @param name The name of the WebVRFreeCamera
  70331. * @param position The starting anchor position for the camera
  70332. * @param scene The scene the camera belongs to
  70333. * @param webVROptions a set of customizable options for the webVRCamera
  70334. */
  70335. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70336. /**
  70337. * Gets the device distance from the ground in meters.
  70338. * @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.
  70339. */
  70340. deviceDistanceToRoomGround(): number;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70344. */
  70345. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70346. /**
  70347. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70348. * @returns A promise with a boolean set to if the standing matrix is supported.
  70349. */
  70350. useStandingMatrixAsync(): Promise<boolean>;
  70351. /**
  70352. * Disposes the camera
  70353. */
  70354. dispose(): void;
  70355. /**
  70356. * Gets a vrController by name.
  70357. * @param name The name of the controller to retreive
  70358. * @returns the controller matching the name specified or null if not found
  70359. */
  70360. getControllerByName(name: string): Nullable<WebVRController>;
  70361. private _leftController;
  70362. /**
  70363. * The controller corrisponding to the users left hand.
  70364. */
  70365. readonly leftController: Nullable<WebVRController>;
  70366. private _rightController;
  70367. /**
  70368. * The controller corrisponding to the users right hand.
  70369. */
  70370. readonly rightController: Nullable<WebVRController>;
  70371. /**
  70372. * Casts a ray forward from the vrCamera's gaze.
  70373. * @param length Length of the ray (default: 100)
  70374. * @returns the ray corrisponding to the gaze
  70375. */
  70376. getForwardRay(length?: number): Ray;
  70377. /**
  70378. * @hidden
  70379. * Updates the camera based on device's frame data
  70380. */
  70381. _checkInputs(): void;
  70382. /**
  70383. * Updates the poseControlled values based on the input device pose.
  70384. * @param poseData Pose coming from the device
  70385. */
  70386. updateFromDevice(poseData: DevicePose): void;
  70387. private _htmlElementAttached;
  70388. private _detachIfAttached;
  70389. /**
  70390. * WebVR's attach control will start broadcasting frames to the device.
  70391. * Note that in certain browsers (chrome for example) this function must be called
  70392. * within a user-interaction callback. Example:
  70393. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70394. *
  70395. * @param element html element to attach the vrDevice to
  70396. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70397. */
  70398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70399. /**
  70400. * Detaches the camera from the html element and disables VR
  70401. *
  70402. * @param element html element to detach from
  70403. */
  70404. detachControl(element: HTMLElement): void;
  70405. /**
  70406. * @returns the name of this class
  70407. */
  70408. getClassName(): string;
  70409. /**
  70410. * Calls resetPose on the vrDisplay
  70411. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70412. */
  70413. resetToCurrentRotation(): void;
  70414. /**
  70415. * @hidden
  70416. * Updates the rig cameras (left and right eye)
  70417. */
  70418. _updateRigCameras(): void;
  70419. private _workingVector;
  70420. private _oneVector;
  70421. private _workingMatrix;
  70422. private updateCacheCalled;
  70423. private _correctPositionIfNotTrackPosition;
  70424. /**
  70425. * @hidden
  70426. * Updates the cached values of the camera
  70427. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70428. */
  70429. _updateCache(ignoreParentClass?: boolean): void;
  70430. /**
  70431. * @hidden
  70432. * Get current device position in babylon world
  70433. */
  70434. _computeDevicePosition(): void;
  70435. /**
  70436. * Updates the current device position and rotation in the babylon world
  70437. */
  70438. update(): void;
  70439. /**
  70440. * @hidden
  70441. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70442. * @returns an identity matrix
  70443. */
  70444. _getViewMatrix(): Matrix;
  70445. private _tmpMatrix;
  70446. /**
  70447. * This function is called by the two RIG cameras.
  70448. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70449. * @hidden
  70450. */
  70451. _getWebVRViewMatrix(): Matrix;
  70452. /** @hidden */
  70453. _getWebVRProjectionMatrix(): Matrix;
  70454. private _onGamepadConnectedObserver;
  70455. private _onGamepadDisconnectedObserver;
  70456. private _updateCacheWhenTrackingDisabledObserver;
  70457. /**
  70458. * Initializes the controllers and their meshes
  70459. */
  70460. initControllers(): void;
  70461. }
  70462. }
  70463. declare module BABYLON {
  70464. /**
  70465. * Size options for a post process
  70466. */
  70467. export type PostProcessOptions = {
  70468. width: number;
  70469. height: number;
  70470. };
  70471. /**
  70472. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70473. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70474. */
  70475. export class PostProcess {
  70476. /** Name of the PostProcess. */
  70477. name: string;
  70478. /**
  70479. * Gets or sets the unique id of the post process
  70480. */
  70481. uniqueId: number;
  70482. /**
  70483. * Width of the texture to apply the post process on
  70484. */
  70485. width: number;
  70486. /**
  70487. * Height of the texture to apply the post process on
  70488. */
  70489. height: number;
  70490. /**
  70491. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70492. * @hidden
  70493. */
  70494. _outputTexture: Nullable<InternalTexture>;
  70495. /**
  70496. * Sampling mode used by the shader
  70497. * See https://doc.babylonjs.com/classes/3.1/texture
  70498. */
  70499. renderTargetSamplingMode: number;
  70500. /**
  70501. * Clear color to use when screen clearing
  70502. */
  70503. clearColor: Color4;
  70504. /**
  70505. * If the buffer needs to be cleared before applying the post process. (default: true)
  70506. * Should be set to false if shader will overwrite all previous pixels.
  70507. */
  70508. autoClear: boolean;
  70509. /**
  70510. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70511. */
  70512. alphaMode: number;
  70513. /**
  70514. * Sets the setAlphaBlendConstants of the babylon engine
  70515. */
  70516. alphaConstants: Color4;
  70517. /**
  70518. * Animations to be used for the post processing
  70519. */
  70520. animations: Animation[];
  70521. /**
  70522. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70523. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70524. */
  70525. enablePixelPerfectMode: boolean;
  70526. /**
  70527. * Force the postprocess to be applied without taking in account viewport
  70528. */
  70529. forceFullscreenViewport: boolean;
  70530. /**
  70531. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70532. *
  70533. * | Value | Type | Description |
  70534. * | ----- | ----------------------------------- | ----------- |
  70535. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70536. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70537. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70538. *
  70539. */
  70540. scaleMode: number;
  70541. /**
  70542. * Force textures to be a power of two (default: false)
  70543. */
  70544. alwaysForcePOT: boolean;
  70545. private _samples;
  70546. /**
  70547. * Number of sample textures (default: 1)
  70548. */
  70549. samples: number;
  70550. /**
  70551. * Modify the scale of the post process to be the same as the viewport (default: false)
  70552. */
  70553. adaptScaleToCurrentViewport: boolean;
  70554. private _camera;
  70555. private _scene;
  70556. private _engine;
  70557. private _options;
  70558. private _reusable;
  70559. private _textureType;
  70560. /**
  70561. * Smart array of input and output textures for the post process.
  70562. * @hidden
  70563. */
  70564. _textures: SmartArray<InternalTexture>;
  70565. /**
  70566. * The index in _textures that corresponds to the output texture.
  70567. * @hidden
  70568. */
  70569. _currentRenderTextureInd: number;
  70570. private _effect;
  70571. private _samplers;
  70572. private _fragmentUrl;
  70573. private _vertexUrl;
  70574. private _parameters;
  70575. private _scaleRatio;
  70576. protected _indexParameters: any;
  70577. private _shareOutputWithPostProcess;
  70578. private _texelSize;
  70579. private _forcedOutputTexture;
  70580. /**
  70581. * Returns the fragment url or shader name used in the post process.
  70582. * @returns the fragment url or name in the shader store.
  70583. */
  70584. getEffectName(): string;
  70585. /**
  70586. * An event triggered when the postprocess is activated.
  70587. */
  70588. onActivateObservable: Observable<Camera>;
  70589. private _onActivateObserver;
  70590. /**
  70591. * A function that is added to the onActivateObservable
  70592. */
  70593. onActivate: Nullable<(camera: Camera) => void>;
  70594. /**
  70595. * An event triggered when the postprocess changes its size.
  70596. */
  70597. onSizeChangedObservable: Observable<PostProcess>;
  70598. private _onSizeChangedObserver;
  70599. /**
  70600. * A function that is added to the onSizeChangedObservable
  70601. */
  70602. onSizeChanged: (postProcess: PostProcess) => void;
  70603. /**
  70604. * An event triggered when the postprocess applies its effect.
  70605. */
  70606. onApplyObservable: Observable<Effect>;
  70607. private _onApplyObserver;
  70608. /**
  70609. * A function that is added to the onApplyObservable
  70610. */
  70611. onApply: (effect: Effect) => void;
  70612. /**
  70613. * An event triggered before rendering the postprocess
  70614. */
  70615. onBeforeRenderObservable: Observable<Effect>;
  70616. private _onBeforeRenderObserver;
  70617. /**
  70618. * A function that is added to the onBeforeRenderObservable
  70619. */
  70620. onBeforeRender: (effect: Effect) => void;
  70621. /**
  70622. * An event triggered after rendering the postprocess
  70623. */
  70624. onAfterRenderObservable: Observable<Effect>;
  70625. private _onAfterRenderObserver;
  70626. /**
  70627. * A function that is added to the onAfterRenderObservable
  70628. */
  70629. onAfterRender: (efect: Effect) => void;
  70630. /**
  70631. * 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
  70632. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70633. */
  70634. inputTexture: InternalTexture;
  70635. /**
  70636. * Gets the camera which post process is applied to.
  70637. * @returns The camera the post process is applied to.
  70638. */
  70639. getCamera(): Camera;
  70640. /**
  70641. * Gets the texel size of the postprocess.
  70642. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70643. */
  70644. readonly texelSize: Vector2;
  70645. /**
  70646. * Creates a new instance PostProcess
  70647. * @param name The name of the PostProcess.
  70648. * @param fragmentUrl The url of the fragment shader to be used.
  70649. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70650. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70651. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70652. * @param camera The camera to apply the render pass to.
  70653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70654. * @param engine The engine which the post process will be applied. (default: current engine)
  70655. * @param reusable If the post process can be reused on the same frame. (default: false)
  70656. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70657. * @param textureType Type of textures used when performing the post process. (default: 0)
  70658. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70659. * @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
  70660. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70661. */
  70662. constructor(
  70663. /** Name of the PostProcess. */
  70664. 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);
  70665. /**
  70666. * Gets a string idenfifying the name of the class
  70667. * @returns "PostProcess" string
  70668. */
  70669. getClassName(): string;
  70670. /**
  70671. * Gets the engine which this post process belongs to.
  70672. * @returns The engine the post process was enabled with.
  70673. */
  70674. getEngine(): Engine;
  70675. /**
  70676. * The effect that is created when initializing the post process.
  70677. * @returns The created effect corrisponding the the postprocess.
  70678. */
  70679. getEffect(): Effect;
  70680. /**
  70681. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70682. * @param postProcess The post process to share the output with.
  70683. * @returns This post process.
  70684. */
  70685. shareOutputWith(postProcess: PostProcess): PostProcess;
  70686. /**
  70687. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70688. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70689. */
  70690. useOwnOutput(): void;
  70691. /**
  70692. * Updates the effect with the current post process compile time values and recompiles the shader.
  70693. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70694. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70695. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70696. * @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
  70697. * @param onCompiled Called when the shader has been compiled.
  70698. * @param onError Called if there is an error when compiling a shader.
  70699. */
  70700. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70701. /**
  70702. * The post process is reusable if it can be used multiple times within one frame.
  70703. * @returns If the post process is reusable
  70704. */
  70705. isReusable(): boolean;
  70706. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70707. markTextureDirty(): void;
  70708. /**
  70709. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70710. * 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.
  70711. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70712. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70713. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70714. * @returns The target texture that was bound to be written to.
  70715. */
  70716. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70717. /**
  70718. * If the post process is supported.
  70719. */
  70720. readonly isSupported: boolean;
  70721. /**
  70722. * The aspect ratio of the output texture.
  70723. */
  70724. readonly aspectRatio: number;
  70725. /**
  70726. * Get a value indicating if the post-process is ready to be used
  70727. * @returns true if the post-process is ready (shader is compiled)
  70728. */
  70729. isReady(): boolean;
  70730. /**
  70731. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70732. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70733. */
  70734. apply(): Nullable<Effect>;
  70735. private _disposeTextures;
  70736. /**
  70737. * Disposes the post process.
  70738. * @param camera The camera to dispose the post process on.
  70739. */
  70740. dispose(camera?: Camera): void;
  70741. }
  70742. }
  70743. declare module BABYLON {
  70744. /**
  70745. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70746. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70747. */
  70748. export class PostProcessManager {
  70749. private _scene;
  70750. private _indexBuffer;
  70751. private _vertexBuffers;
  70752. /**
  70753. * Creates a new instance PostProcess
  70754. * @param scene The scene that the post process is associated with.
  70755. */
  70756. constructor(scene: Scene);
  70757. private _prepareBuffers;
  70758. private _buildIndexBuffer;
  70759. /**
  70760. * Rebuilds the vertex buffers of the manager.
  70761. * @hidden
  70762. */
  70763. _rebuild(): void;
  70764. /**
  70765. * Prepares a frame to be run through a post process.
  70766. * @param sourceTexture The input texture to the post procesess. (default: null)
  70767. * @param postProcesses An array of post processes to be run. (default: null)
  70768. * @returns True if the post processes were able to be run.
  70769. * @hidden
  70770. */
  70771. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70772. /**
  70773. * Manually render a set of post processes to a texture.
  70774. * @param postProcesses An array of post processes to be run.
  70775. * @param targetTexture The target texture to render to.
  70776. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70777. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70778. * @param lodLevel defines which lod of the texture to render to
  70779. */
  70780. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70781. /**
  70782. * Finalize the result of the output of the postprocesses.
  70783. * @param doNotPresent If true the result will not be displayed to the screen.
  70784. * @param targetTexture The target texture to render to.
  70785. * @param faceIndex The index of the face to bind the target texture to.
  70786. * @param postProcesses The array of post processes to render.
  70787. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70788. * @hidden
  70789. */
  70790. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70791. /**
  70792. * Disposes of the post process manager.
  70793. */
  70794. dispose(): void;
  70795. }
  70796. }
  70797. declare module BABYLON {
  70798. interface AbstractScene {
  70799. /**
  70800. * The list of layers (background and foreground) of the scene
  70801. */
  70802. layers: Array<Layer>;
  70803. }
  70804. /**
  70805. * Defines the layer scene component responsible to manage any layers
  70806. * in a given scene.
  70807. */
  70808. export class LayerSceneComponent implements ISceneComponent {
  70809. /**
  70810. * The component name helpfull to identify the component in the list of scene components.
  70811. */
  70812. readonly name: string;
  70813. /**
  70814. * The scene the component belongs to.
  70815. */
  70816. scene: Scene;
  70817. private _engine;
  70818. /**
  70819. * Creates a new instance of the component for the given scene
  70820. * @param scene Defines the scene to register the component in
  70821. */
  70822. constructor(scene: Scene);
  70823. /**
  70824. * Registers the component in a given scene
  70825. */
  70826. register(): void;
  70827. /**
  70828. * Rebuilds the elements related to this component in case of
  70829. * context lost for instance.
  70830. */
  70831. rebuild(): void;
  70832. /**
  70833. * Disposes the component and the associated ressources.
  70834. */
  70835. dispose(): void;
  70836. private _draw;
  70837. private _drawCameraPredicate;
  70838. private _drawCameraBackground;
  70839. private _drawCameraForeground;
  70840. private _drawRenderTargetPredicate;
  70841. private _drawRenderTargetBackground;
  70842. private _drawRenderTargetForeground;
  70843. }
  70844. }
  70845. declare module BABYLON {
  70846. /** @hidden */
  70847. export var layerPixelShader: {
  70848. name: string;
  70849. shader: string;
  70850. };
  70851. }
  70852. declare module BABYLON {
  70853. /** @hidden */
  70854. export var layerVertexShader: {
  70855. name: string;
  70856. shader: string;
  70857. };
  70858. }
  70859. declare module BABYLON {
  70860. /**
  70861. * This represents a full screen 2d layer.
  70862. * This can be useful to display a picture in the background of your scene for instance.
  70863. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70864. */
  70865. export class Layer {
  70866. /**
  70867. * Define the name of the layer.
  70868. */
  70869. name: string;
  70870. /**
  70871. * Define the texture the layer should display.
  70872. */
  70873. texture: Nullable<Texture>;
  70874. /**
  70875. * Is the layer in background or foreground.
  70876. */
  70877. isBackground: boolean;
  70878. /**
  70879. * Define the color of the layer (instead of texture).
  70880. */
  70881. color: Color4;
  70882. /**
  70883. * Define the scale of the layer in order to zoom in out of the texture.
  70884. */
  70885. scale: Vector2;
  70886. /**
  70887. * Define an offset for the layer in order to shift the texture.
  70888. */
  70889. offset: Vector2;
  70890. /**
  70891. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70892. */
  70893. alphaBlendingMode: number;
  70894. /**
  70895. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70896. * Alpha test will not mix with the background color in case of transparency.
  70897. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70898. */
  70899. alphaTest: boolean;
  70900. /**
  70901. * Define a mask to restrict the layer to only some of the scene cameras.
  70902. */
  70903. layerMask: number;
  70904. /**
  70905. * Define the list of render target the layer is visible into.
  70906. */
  70907. renderTargetTextures: RenderTargetTexture[];
  70908. /**
  70909. * Define if the layer is only used in renderTarget or if it also
  70910. * renders in the main frame buffer of the canvas.
  70911. */
  70912. renderOnlyInRenderTargetTextures: boolean;
  70913. private _scene;
  70914. private _vertexBuffers;
  70915. private _indexBuffer;
  70916. private _effect;
  70917. private _alphaTestEffect;
  70918. /**
  70919. * An event triggered when the layer is disposed.
  70920. */
  70921. onDisposeObservable: Observable<Layer>;
  70922. private _onDisposeObserver;
  70923. /**
  70924. * Back compatibility with callback before the onDisposeObservable existed.
  70925. * The set callback will be triggered when the layer has been disposed.
  70926. */
  70927. onDispose: () => void;
  70928. /**
  70929. * An event triggered before rendering the scene
  70930. */
  70931. onBeforeRenderObservable: Observable<Layer>;
  70932. private _onBeforeRenderObserver;
  70933. /**
  70934. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70935. * The set callback will be triggered just before rendering the layer.
  70936. */
  70937. onBeforeRender: () => void;
  70938. /**
  70939. * An event triggered after rendering the scene
  70940. */
  70941. onAfterRenderObservable: Observable<Layer>;
  70942. private _onAfterRenderObserver;
  70943. /**
  70944. * Back compatibility with callback before the onAfterRenderObservable existed.
  70945. * The set callback will be triggered just after rendering the layer.
  70946. */
  70947. onAfterRender: () => void;
  70948. /**
  70949. * Instantiates a new layer.
  70950. * This represents a full screen 2d layer.
  70951. * This can be useful to display a picture in the background of your scene for instance.
  70952. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70953. * @param name Define the name of the layer in the scene
  70954. * @param imgUrl Define the url of the texture to display in the layer
  70955. * @param scene Define the scene the layer belongs to
  70956. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70957. * @param color Defines a color for the layer
  70958. */
  70959. constructor(
  70960. /**
  70961. * Define the name of the layer.
  70962. */
  70963. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70964. private _createIndexBuffer;
  70965. /** @hidden */
  70966. _rebuild(): void;
  70967. /**
  70968. * Renders the layer in the scene.
  70969. */
  70970. render(): void;
  70971. /**
  70972. * Disposes and releases the associated ressources.
  70973. */
  70974. dispose(): void;
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. interface AbstractScene {
  70979. /**
  70980. * The list of procedural textures added to the scene
  70981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70982. */
  70983. proceduralTextures: Array<ProceduralTexture>;
  70984. }
  70985. /**
  70986. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70987. * in a given scene.
  70988. */
  70989. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70990. /**
  70991. * The component name helpfull to identify the component in the list of scene components.
  70992. */
  70993. readonly name: string;
  70994. /**
  70995. * The scene the component belongs to.
  70996. */
  70997. scene: Scene;
  70998. /**
  70999. * Creates a new instance of the component for the given scene
  71000. * @param scene Defines the scene to register the component in
  71001. */
  71002. constructor(scene: Scene);
  71003. /**
  71004. * Registers the component in a given scene
  71005. */
  71006. register(): void;
  71007. /**
  71008. * Rebuilds the elements related to this component in case of
  71009. * context lost for instance.
  71010. */
  71011. rebuild(): void;
  71012. /**
  71013. * Disposes the component and the associated ressources.
  71014. */
  71015. dispose(): void;
  71016. private _beforeClear;
  71017. }
  71018. }
  71019. declare module BABYLON {
  71020. /** @hidden */
  71021. export var proceduralVertexShader: {
  71022. name: string;
  71023. shader: string;
  71024. };
  71025. }
  71026. declare module BABYLON {
  71027. /**
  71028. * 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.
  71029. * This is the base class of any Procedural texture and contains most of the shareable code.
  71030. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71031. */
  71032. export class ProceduralTexture extends Texture {
  71033. isCube: boolean;
  71034. /**
  71035. * Define if the texture is enabled or not (disabled texture will not render)
  71036. */
  71037. isEnabled: boolean;
  71038. /**
  71039. * Define if the texture must be cleared before rendering (default is true)
  71040. */
  71041. autoClear: boolean;
  71042. /**
  71043. * Callback called when the texture is generated
  71044. */
  71045. onGenerated: () => void;
  71046. /**
  71047. * Event raised when the texture is generated
  71048. */
  71049. onGeneratedObservable: Observable<ProceduralTexture>;
  71050. /** @hidden */
  71051. _generateMipMaps: boolean;
  71052. /** @hidden **/
  71053. _effect: Effect;
  71054. /** @hidden */
  71055. _textures: {
  71056. [key: string]: Texture;
  71057. };
  71058. private _size;
  71059. private _currentRefreshId;
  71060. private _refreshRate;
  71061. private _vertexBuffers;
  71062. private _indexBuffer;
  71063. private _uniforms;
  71064. private _samplers;
  71065. private _fragment;
  71066. private _floats;
  71067. private _ints;
  71068. private _floatsArrays;
  71069. private _colors3;
  71070. private _colors4;
  71071. private _vectors2;
  71072. private _vectors3;
  71073. private _matrices;
  71074. private _fallbackTexture;
  71075. private _fallbackTextureUsed;
  71076. private _engine;
  71077. private _cachedDefines;
  71078. private _contentUpdateId;
  71079. private _contentData;
  71080. /**
  71081. * Instantiates a new procedural texture.
  71082. * 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.
  71083. * This is the base class of any Procedural texture and contains most of the shareable code.
  71084. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71085. * @param name Define the name of the texture
  71086. * @param size Define the size of the texture to create
  71087. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71088. * @param scene Define the scene the texture belongs to
  71089. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71090. * @param generateMipMaps Define if the texture should creates mip maps or not
  71091. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71092. */
  71093. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71094. /**
  71095. * The effect that is created when initializing the post process.
  71096. * @returns The created effect corrisponding the the postprocess.
  71097. */
  71098. getEffect(): Effect;
  71099. /**
  71100. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71101. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71102. */
  71103. getContent(): Nullable<ArrayBufferView>;
  71104. private _createIndexBuffer;
  71105. /** @hidden */
  71106. _rebuild(): void;
  71107. /**
  71108. * Resets the texture in order to recreate its associated resources.
  71109. * This can be called in case of context loss
  71110. */
  71111. reset(): void;
  71112. protected _getDefines(): string;
  71113. /**
  71114. * Is the texture ready to be used ? (rendered at least once)
  71115. * @returns true if ready, otherwise, false.
  71116. */
  71117. isReady(): boolean;
  71118. /**
  71119. * Resets the refresh counter of the texture and start bak from scratch.
  71120. * Could be useful to regenerate the texture if it is setup to render only once.
  71121. */
  71122. resetRefreshCounter(): void;
  71123. /**
  71124. * Set the fragment shader to use in order to render the texture.
  71125. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71126. */
  71127. setFragment(fragment: any): void;
  71128. /**
  71129. * Define the refresh rate of the texture or the rendering frequency.
  71130. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71131. */
  71132. refreshRate: number;
  71133. /** @hidden */
  71134. _shouldRender(): boolean;
  71135. /**
  71136. * Get the size the texture is rendering at.
  71137. * @returns the size (texture is always squared)
  71138. */
  71139. getRenderSize(): number;
  71140. /**
  71141. * Resize the texture to new value.
  71142. * @param size Define the new size the texture should have
  71143. * @param generateMipMaps Define whether the new texture should create mip maps
  71144. */
  71145. resize(size: number, generateMipMaps: boolean): void;
  71146. private _checkUniform;
  71147. /**
  71148. * Set a texture in the shader program used to render.
  71149. * @param name Define the name of the uniform samplers as defined in the shader
  71150. * @param texture Define the texture to bind to this sampler
  71151. * @return the texture itself allowing "fluent" like uniform updates
  71152. */
  71153. setTexture(name: string, texture: Texture): ProceduralTexture;
  71154. /**
  71155. * Set a float in the shader.
  71156. * @param name Define the name of the uniform as defined in the shader
  71157. * @param value Define the value to give to the uniform
  71158. * @return the texture itself allowing "fluent" like uniform updates
  71159. */
  71160. setFloat(name: string, value: number): ProceduralTexture;
  71161. /**
  71162. * Set a int in the shader.
  71163. * @param name Define the name of the uniform as defined in the shader
  71164. * @param value Define the value to give to the uniform
  71165. * @return the texture itself allowing "fluent" like uniform updates
  71166. */
  71167. setInt(name: string, value: number): ProceduralTexture;
  71168. /**
  71169. * Set an array of floats in the shader.
  71170. * @param name Define the name of the uniform as defined in the shader
  71171. * @param value Define the value to give to the uniform
  71172. * @return the texture itself allowing "fluent" like uniform updates
  71173. */
  71174. setFloats(name: string, value: number[]): ProceduralTexture;
  71175. /**
  71176. * Set a vec3 in the shader from a Color3.
  71177. * @param name Define the name of the uniform as defined in the shader
  71178. * @param value Define the value to give to the uniform
  71179. * @return the texture itself allowing "fluent" like uniform updates
  71180. */
  71181. setColor3(name: string, value: Color3): ProceduralTexture;
  71182. /**
  71183. * Set a vec4 in the shader from a Color4.
  71184. * @param name Define the name of the uniform as defined in the shader
  71185. * @param value Define the value to give to the uniform
  71186. * @return the texture itself allowing "fluent" like uniform updates
  71187. */
  71188. setColor4(name: string, value: Color4): ProceduralTexture;
  71189. /**
  71190. * Set a vec2 in the shader from a Vector2.
  71191. * @param name Define the name of the uniform as defined in the shader
  71192. * @param value Define the value to give to the uniform
  71193. * @return the texture itself allowing "fluent" like uniform updates
  71194. */
  71195. setVector2(name: string, value: Vector2): ProceduralTexture;
  71196. /**
  71197. * Set a vec3 in the shader from a Vector3.
  71198. * @param name Define the name of the uniform as defined in the shader
  71199. * @param value Define the value to give to the uniform
  71200. * @return the texture itself allowing "fluent" like uniform updates
  71201. */
  71202. setVector3(name: string, value: Vector3): ProceduralTexture;
  71203. /**
  71204. * Set a mat4 in the shader from a MAtrix.
  71205. * @param name Define the name of the uniform as defined in the shader
  71206. * @param value Define the value to give to the uniform
  71207. * @return the texture itself allowing "fluent" like uniform updates
  71208. */
  71209. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71210. /**
  71211. * Render the texture to its associated render target.
  71212. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71213. */
  71214. render(useCameraPostProcess?: boolean): void;
  71215. /**
  71216. * Clone the texture.
  71217. * @returns the cloned texture
  71218. */
  71219. clone(): ProceduralTexture;
  71220. /**
  71221. * Dispose the texture and release its asoociated resources.
  71222. */
  71223. dispose(): void;
  71224. }
  71225. }
  71226. declare module BABYLON {
  71227. /**
  71228. * This represents the base class for particle system in Babylon.
  71229. * 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.
  71230. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71231. * @example https://doc.babylonjs.com/babylon101/particles
  71232. */
  71233. export class BaseParticleSystem {
  71234. /**
  71235. * Source color is added to the destination color without alpha affecting the result
  71236. */
  71237. static BLENDMODE_ONEONE: number;
  71238. /**
  71239. * Blend current color and particle color using particle’s alpha
  71240. */
  71241. static BLENDMODE_STANDARD: number;
  71242. /**
  71243. * Add current color and particle color multiplied by particle’s alpha
  71244. */
  71245. static BLENDMODE_ADD: number;
  71246. /**
  71247. * Multiply current color with particle color
  71248. */
  71249. static BLENDMODE_MULTIPLY: number;
  71250. /**
  71251. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71252. */
  71253. static BLENDMODE_MULTIPLYADD: number;
  71254. /**
  71255. * List of animations used by the particle system.
  71256. */
  71257. animations: Animation[];
  71258. /**
  71259. * The id of the Particle system.
  71260. */
  71261. id: string;
  71262. /**
  71263. * The friendly name of the Particle system.
  71264. */
  71265. name: string;
  71266. /**
  71267. * The rendering group used by the Particle system to chose when to render.
  71268. */
  71269. renderingGroupId: number;
  71270. /**
  71271. * The emitter represents the Mesh or position we are attaching the particle system to.
  71272. */
  71273. emitter: Nullable<AbstractMesh | Vector3>;
  71274. /**
  71275. * The maximum number of particles to emit per frame
  71276. */
  71277. emitRate: number;
  71278. /**
  71279. * If you want to launch only a few particles at once, that can be done, as well.
  71280. */
  71281. manualEmitCount: number;
  71282. /**
  71283. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71284. */
  71285. updateSpeed: number;
  71286. /**
  71287. * The amount of time the particle system is running (depends of the overall update speed).
  71288. */
  71289. targetStopDuration: number;
  71290. /**
  71291. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71292. */
  71293. disposeOnStop: boolean;
  71294. /**
  71295. * Minimum power of emitting particles.
  71296. */
  71297. minEmitPower: number;
  71298. /**
  71299. * Maximum power of emitting particles.
  71300. */
  71301. maxEmitPower: number;
  71302. /**
  71303. * Minimum life time of emitting particles.
  71304. */
  71305. minLifeTime: number;
  71306. /**
  71307. * Maximum life time of emitting particles.
  71308. */
  71309. maxLifeTime: number;
  71310. /**
  71311. * Minimum Size of emitting particles.
  71312. */
  71313. minSize: number;
  71314. /**
  71315. * Maximum Size of emitting particles.
  71316. */
  71317. maxSize: number;
  71318. /**
  71319. * Minimum scale of emitting particles on X axis.
  71320. */
  71321. minScaleX: number;
  71322. /**
  71323. * Maximum scale of emitting particles on X axis.
  71324. */
  71325. maxScaleX: number;
  71326. /**
  71327. * Minimum scale of emitting particles on Y axis.
  71328. */
  71329. minScaleY: number;
  71330. /**
  71331. * Maximum scale of emitting particles on Y axis.
  71332. */
  71333. maxScaleY: number;
  71334. /**
  71335. * Gets or sets the minimal initial rotation in radians.
  71336. */
  71337. minInitialRotation: number;
  71338. /**
  71339. * Gets or sets the maximal initial rotation in radians.
  71340. */
  71341. maxInitialRotation: number;
  71342. /**
  71343. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71344. */
  71345. minAngularSpeed: number;
  71346. /**
  71347. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71348. */
  71349. maxAngularSpeed: number;
  71350. /**
  71351. * The texture used to render each particle. (this can be a spritesheet)
  71352. */
  71353. particleTexture: Nullable<Texture>;
  71354. /**
  71355. * The layer mask we are rendering the particles through.
  71356. */
  71357. layerMask: number;
  71358. /**
  71359. * This can help using your own shader to render the particle system.
  71360. * The according effect will be created
  71361. */
  71362. customShader: any;
  71363. /**
  71364. * By default particle system starts as soon as they are created. This prevents the
  71365. * automatic start to happen and let you decide when to start emitting particles.
  71366. */
  71367. preventAutoStart: boolean;
  71368. private _noiseTexture;
  71369. /**
  71370. * Gets or sets a texture used to add random noise to particle positions
  71371. */
  71372. noiseTexture: Nullable<ProceduralTexture>;
  71373. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71374. noiseStrength: Vector3;
  71375. /**
  71376. * Callback triggered when the particle animation is ending.
  71377. */
  71378. onAnimationEnd: Nullable<() => void>;
  71379. /**
  71380. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71381. */
  71382. blendMode: number;
  71383. /**
  71384. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71385. * to override the particles.
  71386. */
  71387. forceDepthWrite: boolean;
  71388. /** 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 */
  71389. preWarmCycles: number;
  71390. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71391. preWarmStepOffset: number;
  71392. /**
  71393. * 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)
  71394. */
  71395. spriteCellChangeSpeed: number;
  71396. /**
  71397. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71398. */
  71399. startSpriteCellID: number;
  71400. /**
  71401. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71402. */
  71403. endSpriteCellID: number;
  71404. /**
  71405. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71406. */
  71407. spriteCellWidth: number;
  71408. /**
  71409. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71410. */
  71411. spriteCellHeight: number;
  71412. /**
  71413. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71414. */
  71415. spriteRandomStartCell: boolean;
  71416. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71417. translationPivot: Vector2;
  71418. /** @hidden */
  71419. protected _isAnimationSheetEnabled: boolean;
  71420. /**
  71421. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71422. */
  71423. beginAnimationOnStart: boolean;
  71424. /**
  71425. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71426. */
  71427. beginAnimationFrom: number;
  71428. /**
  71429. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71430. */
  71431. beginAnimationTo: number;
  71432. /**
  71433. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71434. */
  71435. beginAnimationLoop: boolean;
  71436. /**
  71437. * Gets or sets a world offset applied to all particles
  71438. */
  71439. worldOffset: Vector3;
  71440. /**
  71441. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71442. */
  71443. isAnimationSheetEnabled: boolean;
  71444. /**
  71445. * Get hosting scene
  71446. * @returns the scene
  71447. */
  71448. getScene(): Scene;
  71449. /**
  71450. * You can use gravity if you want to give an orientation to your particles.
  71451. */
  71452. gravity: Vector3;
  71453. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71454. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71455. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71456. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71457. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71458. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71459. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71460. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71461. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71462. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71463. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71464. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71465. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71466. /**
  71467. * Defines the delay in milliseconds before starting the system (0 by default)
  71468. */
  71469. startDelay: number;
  71470. /**
  71471. * Gets the current list of drag gradients.
  71472. * You must use addDragGradient and removeDragGradient to udpate this list
  71473. * @returns the list of drag gradients
  71474. */
  71475. getDragGradients(): Nullable<Array<FactorGradient>>;
  71476. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71477. limitVelocityDamping: number;
  71478. /**
  71479. * Gets the current list of limit velocity gradients.
  71480. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71481. * @returns the list of limit velocity gradients
  71482. */
  71483. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71484. /**
  71485. * Gets the current list of color gradients.
  71486. * You must use addColorGradient and removeColorGradient to udpate this list
  71487. * @returns the list of color gradients
  71488. */
  71489. getColorGradients(): Nullable<Array<ColorGradient>>;
  71490. /**
  71491. * Gets the current list of size gradients.
  71492. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71493. * @returns the list of size gradients
  71494. */
  71495. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71496. /**
  71497. * Gets the current list of color remap gradients.
  71498. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71499. * @returns the list of color remap gradients
  71500. */
  71501. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71502. /**
  71503. * Gets the current list of alpha remap gradients.
  71504. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71505. * @returns the list of alpha remap gradients
  71506. */
  71507. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71508. /**
  71509. * Gets the current list of life time gradients.
  71510. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71511. * @returns the list of life time gradients
  71512. */
  71513. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71514. /**
  71515. * Gets the current list of angular speed gradients.
  71516. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71517. * @returns the list of angular speed gradients
  71518. */
  71519. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71520. /**
  71521. * Gets the current list of velocity gradients.
  71522. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71523. * @returns the list of velocity gradients
  71524. */
  71525. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71526. /**
  71527. * Gets the current list of start size gradients.
  71528. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71529. * @returns the list of start size gradients
  71530. */
  71531. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71532. /**
  71533. * Gets the current list of emit rate gradients.
  71534. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71535. * @returns the list of emit rate gradients
  71536. */
  71537. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  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. direction1: Vector3;
  71543. /**
  71544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71545. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71546. */
  71547. direction2: Vector3;
  71548. /**
  71549. * 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.
  71550. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71551. */
  71552. minEmitBox: Vector3;
  71553. /**
  71554. * 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.
  71555. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71556. */
  71557. maxEmitBox: Vector3;
  71558. /**
  71559. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71560. */
  71561. color1: Color4;
  71562. /**
  71563. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71564. */
  71565. color2: Color4;
  71566. /**
  71567. * Color the particle will have at the end of its lifetime
  71568. */
  71569. colorDead: Color4;
  71570. /**
  71571. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71572. */
  71573. textureMask: Color4;
  71574. /**
  71575. * The particle emitter type defines the emitter used by the particle system.
  71576. * It can be for example box, sphere, or cone...
  71577. */
  71578. particleEmitterType: IParticleEmitterType;
  71579. /** @hidden */
  71580. _isSubEmitter: boolean;
  71581. /**
  71582. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71583. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71584. */
  71585. billboardMode: number;
  71586. protected _isBillboardBased: boolean;
  71587. /**
  71588. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71589. */
  71590. isBillboardBased: boolean;
  71591. /**
  71592. * The scene the particle system belongs to.
  71593. */
  71594. protected _scene: Scene;
  71595. /**
  71596. * Local cache of defines for image processing.
  71597. */
  71598. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71599. /**
  71600. * Default configuration related to image processing available in the standard Material.
  71601. */
  71602. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71603. /**
  71604. * Gets the image processing configuration used either in this material.
  71605. */
  71606. /**
  71607. * Sets the Default image processing configuration used either in the this material.
  71608. *
  71609. * If sets to null, the scene one is in use.
  71610. */
  71611. imageProcessingConfiguration: ImageProcessingConfiguration;
  71612. /**
  71613. * Attaches a new image processing configuration to the Standard Material.
  71614. * @param configuration
  71615. */
  71616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71617. /** @hidden */
  71618. protected _reset(): void;
  71619. /** @hidden */
  71620. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71621. /**
  71622. * Instantiates a particle system.
  71623. * 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.
  71624. * @param name The name of the particle system
  71625. */
  71626. constructor(name: string);
  71627. /**
  71628. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71631. * @returns the emitter
  71632. */
  71633. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71634. /**
  71635. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71636. * @param radius The radius of the hemisphere to emit from
  71637. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71638. * @returns the emitter
  71639. */
  71640. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71641. /**
  71642. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71643. * @param radius The radius of the sphere to emit from
  71644. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71645. * @returns the emitter
  71646. */
  71647. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71648. /**
  71649. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71650. * @param radius The radius of the sphere to emit from
  71651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71653. * @returns the emitter
  71654. */
  71655. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71656. /**
  71657. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71658. * @param radius The radius of the emission cylinder
  71659. * @param height The height of the emission cylinder
  71660. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71661. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71662. * @returns the emitter
  71663. */
  71664. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71665. /**
  71666. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71667. * @param radius The radius of the cylinder to emit from
  71668. * @param height The height of the emission cylinder
  71669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71672. * @returns the emitter
  71673. */
  71674. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71675. /**
  71676. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71677. * @param radius The radius of the cone to emit from
  71678. * @param angle The base angle of the cone
  71679. * @returns the emitter
  71680. */
  71681. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71682. /**
  71683. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71686. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71687. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71688. * @returns the emitter
  71689. */
  71690. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71691. }
  71692. }
  71693. declare module BABYLON {
  71694. /**
  71695. * Type of sub emitter
  71696. */
  71697. export enum SubEmitterType {
  71698. /**
  71699. * Attached to the particle over it's lifetime
  71700. */
  71701. ATTACHED = 0,
  71702. /**
  71703. * Created when the particle dies
  71704. */
  71705. END = 1
  71706. }
  71707. /**
  71708. * Sub emitter class used to emit particles from an existing particle
  71709. */
  71710. export class SubEmitter {
  71711. /**
  71712. * the particle system to be used by the sub emitter
  71713. */
  71714. particleSystem: ParticleSystem;
  71715. /**
  71716. * Type of the submitter (Default: END)
  71717. */
  71718. type: SubEmitterType;
  71719. /**
  71720. * 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)
  71721. * Note: This only is supported when using an emitter of type Mesh
  71722. */
  71723. inheritDirection: boolean;
  71724. /**
  71725. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71726. */
  71727. inheritedVelocityAmount: number;
  71728. /**
  71729. * Creates a sub emitter
  71730. * @param particleSystem the particle system to be used by the sub emitter
  71731. */
  71732. constructor(
  71733. /**
  71734. * the particle system to be used by the sub emitter
  71735. */
  71736. particleSystem: ParticleSystem);
  71737. /**
  71738. * Clones the sub emitter
  71739. * @returns the cloned sub emitter
  71740. */
  71741. clone(): SubEmitter;
  71742. /**
  71743. * Serialize current object to a JSON object
  71744. * @returns the serialized object
  71745. */
  71746. serialize(): any;
  71747. /** @hidden */
  71748. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71749. /**
  71750. * Creates a new SubEmitter from a serialized JSON version
  71751. * @param serializationObject defines the JSON object to read from
  71752. * @param scene defines the hosting scene
  71753. * @param rootUrl defines the rootUrl for data loading
  71754. * @returns a new SubEmitter
  71755. */
  71756. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71757. /** Release associated resources */
  71758. dispose(): void;
  71759. }
  71760. }
  71761. declare module BABYLON {
  71762. /** @hidden */
  71763. export var clipPlaneFragmentDeclaration: {
  71764. name: string;
  71765. shader: string;
  71766. };
  71767. }
  71768. declare module BABYLON {
  71769. /** @hidden */
  71770. export var imageProcessingDeclaration: {
  71771. name: string;
  71772. shader: string;
  71773. };
  71774. }
  71775. declare module BABYLON {
  71776. /** @hidden */
  71777. export var imageProcessingFunctions: {
  71778. name: string;
  71779. shader: string;
  71780. };
  71781. }
  71782. declare module BABYLON {
  71783. /** @hidden */
  71784. export var clipPlaneFragment: {
  71785. name: string;
  71786. shader: string;
  71787. };
  71788. }
  71789. declare module BABYLON {
  71790. /** @hidden */
  71791. export var particlesPixelShader: {
  71792. name: string;
  71793. shader: string;
  71794. };
  71795. }
  71796. declare module BABYLON {
  71797. /** @hidden */
  71798. export var clipPlaneVertexDeclaration: {
  71799. name: string;
  71800. shader: string;
  71801. };
  71802. }
  71803. declare module BABYLON {
  71804. /** @hidden */
  71805. export var clipPlaneVertex: {
  71806. name: string;
  71807. shader: string;
  71808. };
  71809. }
  71810. declare module BABYLON {
  71811. /** @hidden */
  71812. export var particlesVertexShader: {
  71813. name: string;
  71814. shader: string;
  71815. };
  71816. }
  71817. declare module BABYLON {
  71818. /**
  71819. * This represents a particle system in Babylon.
  71820. * 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.
  71821. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71822. * @example https://doc.babylonjs.com/babylon101/particles
  71823. */
  71824. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71825. /**
  71826. * Billboard mode will only apply to Y axis
  71827. */
  71828. static readonly BILLBOARDMODE_Y: number;
  71829. /**
  71830. * Billboard mode will apply to all axes
  71831. */
  71832. static readonly BILLBOARDMODE_ALL: number;
  71833. /**
  71834. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71835. */
  71836. static readonly BILLBOARDMODE_STRETCHED: number;
  71837. /**
  71838. * This function can be defined to provide custom update for active particles.
  71839. * This function will be called instead of regular update (age, position, color, etc.).
  71840. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71841. */
  71842. updateFunction: (particles: Particle[]) => void;
  71843. private _emitterWorldMatrix;
  71844. /**
  71845. * This function can be defined to specify initial direction for every new particle.
  71846. * It by default use the emitterType defined function
  71847. */
  71848. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71849. /**
  71850. * This function can be defined to specify initial position for every new particle.
  71851. * It by default use the emitterType defined function
  71852. */
  71853. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71854. /**
  71855. * @hidden
  71856. */
  71857. _inheritedVelocityOffset: Vector3;
  71858. /**
  71859. * An event triggered when the system is disposed
  71860. */
  71861. onDisposeObservable: Observable<ParticleSystem>;
  71862. private _onDisposeObserver;
  71863. /**
  71864. * Sets a callback that will be triggered when the system is disposed
  71865. */
  71866. onDispose: () => void;
  71867. private _particles;
  71868. private _epsilon;
  71869. private _capacity;
  71870. private _stockParticles;
  71871. private _newPartsExcess;
  71872. private _vertexData;
  71873. private _vertexBuffer;
  71874. private _vertexBuffers;
  71875. private _spriteBuffer;
  71876. private _indexBuffer;
  71877. private _effect;
  71878. private _customEffect;
  71879. private _cachedDefines;
  71880. private _scaledColorStep;
  71881. private _colorDiff;
  71882. private _scaledDirection;
  71883. private _scaledGravity;
  71884. private _currentRenderId;
  71885. private _alive;
  71886. private _useInstancing;
  71887. private _started;
  71888. private _stopped;
  71889. private _actualFrame;
  71890. private _scaledUpdateSpeed;
  71891. private _vertexBufferSize;
  71892. /** @hidden */
  71893. _currentEmitRateGradient: Nullable<FactorGradient>;
  71894. /** @hidden */
  71895. _currentEmitRate1: number;
  71896. /** @hidden */
  71897. _currentEmitRate2: number;
  71898. /** @hidden */
  71899. _currentStartSizeGradient: Nullable<FactorGradient>;
  71900. /** @hidden */
  71901. _currentStartSize1: number;
  71902. /** @hidden */
  71903. _currentStartSize2: number;
  71904. private readonly _rawTextureWidth;
  71905. private _rampGradientsTexture;
  71906. private _useRampGradients;
  71907. /** Gets or sets a boolean indicating that ramp gradients must be used
  71908. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71909. */
  71910. useRampGradients: boolean;
  71911. /**
  71912. * 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.
  71913. * 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: [])
  71914. */
  71915. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71916. private _subEmitters;
  71917. /**
  71918. * @hidden
  71919. * If the particle systems emitter should be disposed when the particle system is disposed
  71920. */
  71921. _disposeEmitterOnDispose: boolean;
  71922. /**
  71923. * The current active Sub-systems, this property is used by the root particle system only.
  71924. */
  71925. activeSubSystems: Array<ParticleSystem>;
  71926. private _rootParticleSystem;
  71927. /**
  71928. * Gets the current list of active particles
  71929. */
  71930. readonly particles: Particle[];
  71931. /**
  71932. * Returns the string "ParticleSystem"
  71933. * @returns a string containing the class name
  71934. */
  71935. getClassName(): string;
  71936. /**
  71937. * Instantiates a particle system.
  71938. * 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.
  71939. * @param name The name of the particle system
  71940. * @param capacity The max number of particles alive at the same time
  71941. * @param scene The scene the particle system belongs to
  71942. * @param customEffect a custom effect used to change the way particles are rendered by default
  71943. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71944. * @param epsilon Offset used to render the particles
  71945. */
  71946. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71947. private _addFactorGradient;
  71948. private _removeFactorGradient;
  71949. /**
  71950. * Adds a new life time gradient
  71951. * @param gradient defines the gradient to use (between 0 and 1)
  71952. * @param factor defines the life time factor to affect to the specified gradient
  71953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71954. * @returns the current particle system
  71955. */
  71956. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71957. /**
  71958. * Remove a specific life time gradient
  71959. * @param gradient defines the gradient to remove
  71960. * @returns the current particle system
  71961. */
  71962. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71963. /**
  71964. * Adds a new size gradient
  71965. * @param gradient defines the gradient to use (between 0 and 1)
  71966. * @param factor defines the size factor to affect to the specified gradient
  71967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71968. * @returns the current particle system
  71969. */
  71970. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71971. /**
  71972. * Remove a specific size gradient
  71973. * @param gradient defines the gradient to remove
  71974. * @returns the current particle system
  71975. */
  71976. removeSizeGradient(gradient: number): IParticleSystem;
  71977. /**
  71978. * Adds a new color remap gradient
  71979. * @param gradient defines the gradient to use (between 0 and 1)
  71980. * @param min defines the color remap minimal range
  71981. * @param max defines the color remap maximal range
  71982. * @returns the current particle system
  71983. */
  71984. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71985. /**
  71986. * Remove a specific color remap gradient
  71987. * @param gradient defines the gradient to remove
  71988. * @returns the current particle system
  71989. */
  71990. removeColorRemapGradient(gradient: number): IParticleSystem;
  71991. /**
  71992. * Adds a new alpha remap gradient
  71993. * @param gradient defines the gradient to use (between 0 and 1)
  71994. * @param min defines the alpha remap minimal range
  71995. * @param max defines the alpha remap maximal range
  71996. * @returns the current particle system
  71997. */
  71998. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71999. /**
  72000. * Remove a specific alpha remap gradient
  72001. * @param gradient defines the gradient to remove
  72002. * @returns the current particle system
  72003. */
  72004. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72005. /**
  72006. * Adds a new angular speed gradient
  72007. * @param gradient defines the gradient to use (between 0 and 1)
  72008. * @param factor defines the angular speed to affect to the specified gradient
  72009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72010. * @returns the current particle system
  72011. */
  72012. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72013. /**
  72014. * Remove a specific angular speed gradient
  72015. * @param gradient defines the gradient to remove
  72016. * @returns the current particle system
  72017. */
  72018. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72019. /**
  72020. * Adds a new velocity gradient
  72021. * @param gradient defines the gradient to use (between 0 and 1)
  72022. * @param factor defines the velocity to affect to the specified gradient
  72023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72024. * @returns the current particle system
  72025. */
  72026. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72027. /**
  72028. * Remove a specific velocity gradient
  72029. * @param gradient defines the gradient to remove
  72030. * @returns the current particle system
  72031. */
  72032. removeVelocityGradient(gradient: number): IParticleSystem;
  72033. /**
  72034. * Adds a new limit velocity gradient
  72035. * @param gradient defines the gradient to use (between 0 and 1)
  72036. * @param factor defines the limit velocity value to affect to the specified gradient
  72037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72038. * @returns the current particle system
  72039. */
  72040. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72041. /**
  72042. * Remove a specific limit velocity gradient
  72043. * @param gradient defines the gradient to remove
  72044. * @returns the current particle system
  72045. */
  72046. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72047. /**
  72048. * Adds a new drag gradient
  72049. * @param gradient defines the gradient to use (between 0 and 1)
  72050. * @param factor defines the drag value to affect to the specified gradient
  72051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72052. * @returns the current particle system
  72053. */
  72054. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72055. /**
  72056. * Remove a specific drag gradient
  72057. * @param gradient defines the gradient to remove
  72058. * @returns the current particle system
  72059. */
  72060. removeDragGradient(gradient: number): IParticleSystem;
  72061. /**
  72062. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72063. * @param gradient defines the gradient to use (between 0 and 1)
  72064. * @param factor defines the emit rate value to affect to the specified gradient
  72065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72066. * @returns the current particle system
  72067. */
  72068. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72069. /**
  72070. * Remove a specific emit rate gradient
  72071. * @param gradient defines the gradient to remove
  72072. * @returns the current particle system
  72073. */
  72074. removeEmitRateGradient(gradient: number): IParticleSystem;
  72075. /**
  72076. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72077. * @param gradient defines the gradient to use (between 0 and 1)
  72078. * @param factor defines the start size value to affect to the specified gradient
  72079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72080. * @returns the current particle system
  72081. */
  72082. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72083. /**
  72084. * Remove a specific start size gradient
  72085. * @param gradient defines the gradient to remove
  72086. * @returns the current particle system
  72087. */
  72088. removeStartSizeGradient(gradient: number): IParticleSystem;
  72089. private _createRampGradientTexture;
  72090. /**
  72091. * Gets the current list of ramp gradients.
  72092. * You must use addRampGradient and removeRampGradient to udpate this list
  72093. * @returns the list of ramp gradients
  72094. */
  72095. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72096. /**
  72097. * Adds a new ramp gradient used to remap particle colors
  72098. * @param gradient defines the gradient to use (between 0 and 1)
  72099. * @param color defines the color to affect to the specified gradient
  72100. * @returns the current particle system
  72101. */
  72102. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72103. /**
  72104. * Remove a specific ramp gradient
  72105. * @param gradient defines the gradient to remove
  72106. * @returns the current particle system
  72107. */
  72108. removeRampGradient(gradient: number): ParticleSystem;
  72109. /**
  72110. * Adds a new color gradient
  72111. * @param gradient defines the gradient to use (between 0 and 1)
  72112. * @param color1 defines the color to affect to the specified gradient
  72113. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72114. * @returns this particle system
  72115. */
  72116. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72117. /**
  72118. * Remove a specific color gradient
  72119. * @param gradient defines the gradient to remove
  72120. * @returns this particle system
  72121. */
  72122. removeColorGradient(gradient: number): IParticleSystem;
  72123. private _fetchR;
  72124. protected _reset(): void;
  72125. private _resetEffect;
  72126. private _createVertexBuffers;
  72127. private _createIndexBuffer;
  72128. /**
  72129. * Gets the maximum number of particles active at the same time.
  72130. * @returns The max number of active particles.
  72131. */
  72132. getCapacity(): number;
  72133. /**
  72134. * Gets whether there are still active particles in the system.
  72135. * @returns True if it is alive, otherwise false.
  72136. */
  72137. isAlive(): boolean;
  72138. /**
  72139. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72140. * @returns True if it has been started, otherwise false.
  72141. */
  72142. isStarted(): boolean;
  72143. private _prepareSubEmitterInternalArray;
  72144. /**
  72145. * Starts the particle system and begins to emit
  72146. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72147. */
  72148. start(delay?: number): void;
  72149. /**
  72150. * Stops the particle system.
  72151. * @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.
  72152. */
  72153. stop(stopSubEmitters?: boolean): void;
  72154. /**
  72155. * Remove all active particles
  72156. */
  72157. reset(): void;
  72158. /**
  72159. * @hidden (for internal use only)
  72160. */
  72161. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72162. /**
  72163. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72164. * Its lifetime will start back at 0.
  72165. */
  72166. recycleParticle: (particle: Particle) => void;
  72167. private _stopSubEmitters;
  72168. private _createParticle;
  72169. private _removeFromRoot;
  72170. private _emitFromParticle;
  72171. private _update;
  72172. /** @hidden */
  72173. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72174. /** @hidden */
  72175. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72176. /** @hidden */
  72177. private _getEffect;
  72178. /**
  72179. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72180. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72181. */
  72182. animate(preWarmOnly?: boolean): void;
  72183. private _appendParticleVertices;
  72184. /**
  72185. * Rebuilds the particle system.
  72186. */
  72187. rebuild(): void;
  72188. /**
  72189. * Is this system ready to be used/rendered
  72190. * @return true if the system is ready
  72191. */
  72192. isReady(): boolean;
  72193. private _render;
  72194. /**
  72195. * Renders the particle system in its current state.
  72196. * @returns the current number of particles
  72197. */
  72198. render(): number;
  72199. /**
  72200. * Disposes the particle system and free the associated resources
  72201. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72202. */
  72203. dispose(disposeTexture?: boolean): void;
  72204. /**
  72205. * Clones the particle system.
  72206. * @param name The name of the cloned object
  72207. * @param newEmitter The new emitter to use
  72208. * @returns the cloned particle system
  72209. */
  72210. clone(name: string, newEmitter: any): ParticleSystem;
  72211. /**
  72212. * Serializes the particle system to a JSON object.
  72213. * @returns the JSON object
  72214. */
  72215. serialize(): any;
  72216. /** @hidden */
  72217. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72218. /** @hidden */
  72219. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72220. /**
  72221. * Parses a JSON object to create a particle system.
  72222. * @param parsedParticleSystem The JSON object to parse
  72223. * @param scene The scene to create the particle system in
  72224. * @param rootUrl The root url to use to load external dependencies like texture
  72225. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72226. * @returns the Parsed particle system
  72227. */
  72228. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72229. }
  72230. }
  72231. declare module BABYLON {
  72232. /**
  72233. * A particle represents one of the element emitted by a particle system.
  72234. * This is mainly define by its coordinates, direction, velocity and age.
  72235. */
  72236. export class Particle {
  72237. /**
  72238. * The particle system the particle belongs to.
  72239. */
  72240. particleSystem: ParticleSystem;
  72241. private static _Count;
  72242. /**
  72243. * Unique ID of the particle
  72244. */
  72245. id: number;
  72246. /**
  72247. * The world position of the particle in the scene.
  72248. */
  72249. position: Vector3;
  72250. /**
  72251. * The world direction of the particle in the scene.
  72252. */
  72253. direction: Vector3;
  72254. /**
  72255. * The color of the particle.
  72256. */
  72257. color: Color4;
  72258. /**
  72259. * The color change of the particle per step.
  72260. */
  72261. colorStep: Color4;
  72262. /**
  72263. * Defines how long will the life of the particle be.
  72264. */
  72265. lifeTime: number;
  72266. /**
  72267. * The current age of the particle.
  72268. */
  72269. age: number;
  72270. /**
  72271. * The current size of the particle.
  72272. */
  72273. size: number;
  72274. /**
  72275. * The current scale of the particle.
  72276. */
  72277. scale: Vector2;
  72278. /**
  72279. * The current angle of the particle.
  72280. */
  72281. angle: number;
  72282. /**
  72283. * Defines how fast is the angle changing.
  72284. */
  72285. angularSpeed: number;
  72286. /**
  72287. * Defines the cell index used by the particle to be rendered from a sprite.
  72288. */
  72289. cellIndex: number;
  72290. /**
  72291. * The information required to support color remapping
  72292. */
  72293. remapData: Vector4;
  72294. /** @hidden */
  72295. _randomCellOffset?: number;
  72296. /** @hidden */
  72297. _initialDirection: Nullable<Vector3>;
  72298. /** @hidden */
  72299. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72300. /** @hidden */
  72301. _initialStartSpriteCellID: number;
  72302. /** @hidden */
  72303. _initialEndSpriteCellID: number;
  72304. /** @hidden */
  72305. _currentColorGradient: Nullable<ColorGradient>;
  72306. /** @hidden */
  72307. _currentColor1: Color4;
  72308. /** @hidden */
  72309. _currentColor2: Color4;
  72310. /** @hidden */
  72311. _currentSizeGradient: Nullable<FactorGradient>;
  72312. /** @hidden */
  72313. _currentSize1: number;
  72314. /** @hidden */
  72315. _currentSize2: number;
  72316. /** @hidden */
  72317. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72318. /** @hidden */
  72319. _currentAngularSpeed1: number;
  72320. /** @hidden */
  72321. _currentAngularSpeed2: number;
  72322. /** @hidden */
  72323. _currentVelocityGradient: Nullable<FactorGradient>;
  72324. /** @hidden */
  72325. _currentVelocity1: number;
  72326. /** @hidden */
  72327. _currentVelocity2: number;
  72328. /** @hidden */
  72329. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72330. /** @hidden */
  72331. _currentLimitVelocity1: number;
  72332. /** @hidden */
  72333. _currentLimitVelocity2: number;
  72334. /** @hidden */
  72335. _currentDragGradient: Nullable<FactorGradient>;
  72336. /** @hidden */
  72337. _currentDrag1: number;
  72338. /** @hidden */
  72339. _currentDrag2: number;
  72340. /** @hidden */
  72341. _randomNoiseCoordinates1: Vector3;
  72342. /** @hidden */
  72343. _randomNoiseCoordinates2: Vector3;
  72344. /**
  72345. * Creates a new instance Particle
  72346. * @param particleSystem the particle system the particle belongs to
  72347. */
  72348. constructor(
  72349. /**
  72350. * The particle system the particle belongs to.
  72351. */
  72352. particleSystem: ParticleSystem);
  72353. private updateCellInfoFromSystem;
  72354. /**
  72355. * Defines how the sprite cell index is updated for the particle
  72356. */
  72357. updateCellIndex(): void;
  72358. /** @hidden */
  72359. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72360. /** @hidden */
  72361. _inheritParticleInfoToSubEmitters(): void;
  72362. /** @hidden */
  72363. _reset(): void;
  72364. /**
  72365. * Copy the properties of particle to another one.
  72366. * @param other the particle to copy the information to.
  72367. */
  72368. copyTo(other: Particle): void;
  72369. }
  72370. }
  72371. declare module BABYLON {
  72372. /**
  72373. * Particle emitter represents a volume emitting particles.
  72374. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72375. */
  72376. export interface IParticleEmitterType {
  72377. /**
  72378. * Called by the particle System when the direction is computed for the created particle.
  72379. * @param worldMatrix is the world matrix of the particle system
  72380. * @param directionToUpdate is the direction vector to update with the result
  72381. * @param particle is the particle we are computed the direction for
  72382. */
  72383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72384. /**
  72385. * Called by the particle System when the position is computed for the created particle.
  72386. * @param worldMatrix is the world matrix of the particle system
  72387. * @param positionToUpdate is the position vector to update with the result
  72388. * @param particle is the particle we are computed the position for
  72389. */
  72390. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72391. /**
  72392. * Clones the current emitter and returns a copy of it
  72393. * @returns the new emitter
  72394. */
  72395. clone(): IParticleEmitterType;
  72396. /**
  72397. * Called by the GPUParticleSystem to setup the update shader
  72398. * @param effect defines the update shader
  72399. */
  72400. applyToShader(effect: Effect): void;
  72401. /**
  72402. * Returns a string to use to update the GPU particles update shader
  72403. * @returns the effect defines string
  72404. */
  72405. getEffectDefines(): string;
  72406. /**
  72407. * Returns a string representing the class name
  72408. * @returns a string containing the class name
  72409. */
  72410. getClassName(): string;
  72411. /**
  72412. * Serializes the particle system to a JSON object.
  72413. * @returns the JSON object
  72414. */
  72415. serialize(): any;
  72416. /**
  72417. * Parse properties from a JSON object
  72418. * @param serializationObject defines the JSON object
  72419. */
  72420. parse(serializationObject: any): void;
  72421. }
  72422. }
  72423. declare module BABYLON {
  72424. /**
  72425. * Particle emitter emitting particles from the inside of a box.
  72426. * It emits the particles randomly between 2 given directions.
  72427. */
  72428. export class BoxParticleEmitter implements IParticleEmitterType {
  72429. /**
  72430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72431. */
  72432. direction1: Vector3;
  72433. /**
  72434. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72435. */
  72436. direction2: Vector3;
  72437. /**
  72438. * 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.
  72439. */
  72440. minEmitBox: Vector3;
  72441. /**
  72442. * 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.
  72443. */
  72444. maxEmitBox: Vector3;
  72445. /**
  72446. * Creates a new instance BoxParticleEmitter
  72447. */
  72448. constructor();
  72449. /**
  72450. * Called by the particle System when the direction is computed for the created particle.
  72451. * @param worldMatrix is the world matrix of the particle system
  72452. * @param directionToUpdate is the direction vector to update with the result
  72453. * @param particle is the particle we are computed the direction for
  72454. */
  72455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72456. /**
  72457. * Called by the particle System when the position is computed for the created particle.
  72458. * @param worldMatrix is the world matrix of the particle system
  72459. * @param positionToUpdate is the position vector to update with the result
  72460. * @param particle is the particle we are computed the position for
  72461. */
  72462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72463. /**
  72464. * Clones the current emitter and returns a copy of it
  72465. * @returns the new emitter
  72466. */
  72467. clone(): BoxParticleEmitter;
  72468. /**
  72469. * Called by the GPUParticleSystem to setup the update shader
  72470. * @param effect defines the update shader
  72471. */
  72472. applyToShader(effect: Effect): void;
  72473. /**
  72474. * Returns a string to use to update the GPU particles update shader
  72475. * @returns a string containng the defines string
  72476. */
  72477. getEffectDefines(): string;
  72478. /**
  72479. * Returns the string "BoxParticleEmitter"
  72480. * @returns a string containing the class name
  72481. */
  72482. getClassName(): string;
  72483. /**
  72484. * Serializes the particle system to a JSON object.
  72485. * @returns the JSON object
  72486. */
  72487. serialize(): any;
  72488. /**
  72489. * Parse properties from a JSON object
  72490. * @param serializationObject defines the JSON object
  72491. */
  72492. parse(serializationObject: any): void;
  72493. }
  72494. }
  72495. declare module BABYLON {
  72496. /**
  72497. * Particle emitter emitting particles from the inside of a cone.
  72498. * It emits the particles alongside the cone volume from the base to the particle.
  72499. * The emission direction might be randomized.
  72500. */
  72501. export class ConeParticleEmitter implements IParticleEmitterType {
  72502. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72503. directionRandomizer: number;
  72504. private _radius;
  72505. private _angle;
  72506. private _height;
  72507. /**
  72508. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72509. */
  72510. radiusRange: number;
  72511. /**
  72512. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72513. */
  72514. heightRange: number;
  72515. /**
  72516. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72517. */
  72518. emitFromSpawnPointOnly: boolean;
  72519. /**
  72520. * Gets or sets the radius of the emission cone
  72521. */
  72522. radius: number;
  72523. /**
  72524. * Gets or sets the angle of the emission cone
  72525. */
  72526. angle: number;
  72527. private _buildHeight;
  72528. /**
  72529. * Creates a new instance ConeParticleEmitter
  72530. * @param radius the radius of the emission cone (1 by default)
  72531. * @param angle the cone base angle (PI by default)
  72532. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72533. */
  72534. constructor(radius?: number, angle?: number,
  72535. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72536. directionRandomizer?: number);
  72537. /**
  72538. * Called by the particle System when the direction is computed for the created particle.
  72539. * @param worldMatrix is the world matrix of the particle system
  72540. * @param directionToUpdate is the direction vector to update with the result
  72541. * @param particle is the particle we are computed the direction for
  72542. */
  72543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72544. /**
  72545. * Called by the particle System when the position is computed for the created particle.
  72546. * @param worldMatrix is the world matrix of the particle system
  72547. * @param positionToUpdate is the position vector to update with the result
  72548. * @param particle is the particle we are computed the position for
  72549. */
  72550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72551. /**
  72552. * Clones the current emitter and returns a copy of it
  72553. * @returns the new emitter
  72554. */
  72555. clone(): ConeParticleEmitter;
  72556. /**
  72557. * Called by the GPUParticleSystem to setup the update shader
  72558. * @param effect defines the update shader
  72559. */
  72560. applyToShader(effect: Effect): void;
  72561. /**
  72562. * Returns a string to use to update the GPU particles update shader
  72563. * @returns a string containng the defines string
  72564. */
  72565. getEffectDefines(): string;
  72566. /**
  72567. * Returns the string "ConeParticleEmitter"
  72568. * @returns a string containing the class name
  72569. */
  72570. getClassName(): string;
  72571. /**
  72572. * Serializes the particle system to a JSON object.
  72573. * @returns the JSON object
  72574. */
  72575. serialize(): any;
  72576. /**
  72577. * Parse properties from a JSON object
  72578. * @param serializationObject defines the JSON object
  72579. */
  72580. parse(serializationObject: any): void;
  72581. }
  72582. }
  72583. declare module BABYLON {
  72584. /**
  72585. * Particle emitter emitting particles from the inside of a cylinder.
  72586. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72587. */
  72588. export class CylinderParticleEmitter implements IParticleEmitterType {
  72589. /**
  72590. * The radius of the emission cylinder.
  72591. */
  72592. radius: number;
  72593. /**
  72594. * The height of the emission cylinder.
  72595. */
  72596. height: number;
  72597. /**
  72598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72599. */
  72600. radiusRange: number;
  72601. /**
  72602. * How much to randomize the particle direction [0-1].
  72603. */
  72604. directionRandomizer: number;
  72605. /**
  72606. * Creates a new instance CylinderParticleEmitter
  72607. * @param radius the radius of the emission cylinder (1 by default)
  72608. * @param height the height of the emission cylinder (1 by default)
  72609. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72610. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72611. */
  72612. constructor(
  72613. /**
  72614. * The radius of the emission cylinder.
  72615. */
  72616. radius?: number,
  72617. /**
  72618. * The height of the emission cylinder.
  72619. */
  72620. height?: number,
  72621. /**
  72622. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72623. */
  72624. radiusRange?: number,
  72625. /**
  72626. * How much to randomize the particle direction [0-1].
  72627. */
  72628. directionRandomizer?: number);
  72629. /**
  72630. * Called by the particle System when the direction is computed for the created particle.
  72631. * @param worldMatrix is the world matrix of the particle system
  72632. * @param directionToUpdate is the direction vector to update with the result
  72633. * @param particle is the particle we are computed the direction for
  72634. */
  72635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72636. /**
  72637. * Called by the particle System when the position is computed for the created particle.
  72638. * @param worldMatrix is the world matrix of the particle system
  72639. * @param positionToUpdate is the position vector to update with the result
  72640. * @param particle is the particle we are computed the position for
  72641. */
  72642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72643. /**
  72644. * Clones the current emitter and returns a copy of it
  72645. * @returns the new emitter
  72646. */
  72647. clone(): CylinderParticleEmitter;
  72648. /**
  72649. * Called by the GPUParticleSystem to setup the update shader
  72650. * @param effect defines the update shader
  72651. */
  72652. applyToShader(effect: Effect): void;
  72653. /**
  72654. * Returns a string to use to update the GPU particles update shader
  72655. * @returns a string containng the defines string
  72656. */
  72657. getEffectDefines(): string;
  72658. /**
  72659. * Returns the string "CylinderParticleEmitter"
  72660. * @returns a string containing the class name
  72661. */
  72662. getClassName(): string;
  72663. /**
  72664. * Serializes the particle system to a JSON object.
  72665. * @returns the JSON object
  72666. */
  72667. serialize(): any;
  72668. /**
  72669. * Parse properties from a JSON object
  72670. * @param serializationObject defines the JSON object
  72671. */
  72672. parse(serializationObject: any): void;
  72673. }
  72674. /**
  72675. * Particle emitter emitting particles from the inside of a cylinder.
  72676. * It emits the particles randomly between two vectors.
  72677. */
  72678. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72679. /**
  72680. * The min limit of the emission direction.
  72681. */
  72682. direction1: Vector3;
  72683. /**
  72684. * The max limit of the emission direction.
  72685. */
  72686. direction2: Vector3;
  72687. /**
  72688. * Creates a new instance CylinderDirectedParticleEmitter
  72689. * @param radius the radius of the emission cylinder (1 by default)
  72690. * @param height the height of the emission cylinder (1 by default)
  72691. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72692. * @param direction1 the min limit of the emission direction (up vector by default)
  72693. * @param direction2 the max limit of the emission direction (up vector by default)
  72694. */
  72695. constructor(radius?: number, height?: number, radiusRange?: number,
  72696. /**
  72697. * The min limit of the emission direction.
  72698. */
  72699. direction1?: Vector3,
  72700. /**
  72701. * The max limit of the emission direction.
  72702. */
  72703. direction2?: Vector3);
  72704. /**
  72705. * Called by the particle System when the direction is computed for the created particle.
  72706. * @param worldMatrix is the world matrix of the particle system
  72707. * @param directionToUpdate is the direction vector to update with the result
  72708. * @param particle is the particle we are computed the direction for
  72709. */
  72710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72711. /**
  72712. * Clones the current emitter and returns a copy of it
  72713. * @returns the new emitter
  72714. */
  72715. clone(): CylinderDirectedParticleEmitter;
  72716. /**
  72717. * Called by the GPUParticleSystem to setup the update shader
  72718. * @param effect defines the update shader
  72719. */
  72720. applyToShader(effect: Effect): void;
  72721. /**
  72722. * Returns a string to use to update the GPU particles update shader
  72723. * @returns a string containng the defines string
  72724. */
  72725. getEffectDefines(): string;
  72726. /**
  72727. * Returns the string "CylinderDirectedParticleEmitter"
  72728. * @returns a string containing the class name
  72729. */
  72730. getClassName(): string;
  72731. /**
  72732. * Serializes the particle system to a JSON object.
  72733. * @returns the JSON object
  72734. */
  72735. serialize(): any;
  72736. /**
  72737. * Parse properties from a JSON object
  72738. * @param serializationObject defines the JSON object
  72739. */
  72740. parse(serializationObject: any): void;
  72741. }
  72742. }
  72743. declare module BABYLON {
  72744. /**
  72745. * Particle emitter emitting particles from the inside of a hemisphere.
  72746. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72747. */
  72748. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72749. /**
  72750. * The radius of the emission hemisphere.
  72751. */
  72752. radius: number;
  72753. /**
  72754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72755. */
  72756. radiusRange: number;
  72757. /**
  72758. * How much to randomize the particle direction [0-1].
  72759. */
  72760. directionRandomizer: number;
  72761. /**
  72762. * Creates a new instance HemisphericParticleEmitter
  72763. * @param radius the radius of the emission hemisphere (1 by default)
  72764. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72765. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72766. */
  72767. constructor(
  72768. /**
  72769. * The radius of the emission hemisphere.
  72770. */
  72771. radius?: number,
  72772. /**
  72773. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72774. */
  72775. radiusRange?: number,
  72776. /**
  72777. * How much to randomize the particle direction [0-1].
  72778. */
  72779. directionRandomizer?: number);
  72780. /**
  72781. * Called by the particle System when the direction is computed for the created particle.
  72782. * @param worldMatrix is the world matrix of the particle system
  72783. * @param directionToUpdate is the direction vector to update with the result
  72784. * @param particle is the particle we are computed the direction for
  72785. */
  72786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72787. /**
  72788. * Called by the particle System when the position is computed for the created particle.
  72789. * @param worldMatrix is the world matrix of the particle system
  72790. * @param positionToUpdate is the position vector to update with the result
  72791. * @param particle is the particle we are computed the position for
  72792. */
  72793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72794. /**
  72795. * Clones the current emitter and returns a copy of it
  72796. * @returns the new emitter
  72797. */
  72798. clone(): HemisphericParticleEmitter;
  72799. /**
  72800. * Called by the GPUParticleSystem to setup the update shader
  72801. * @param effect defines the update shader
  72802. */
  72803. applyToShader(effect: Effect): void;
  72804. /**
  72805. * Returns a string to use to update the GPU particles update shader
  72806. * @returns a string containng the defines string
  72807. */
  72808. getEffectDefines(): string;
  72809. /**
  72810. * Returns the string "HemisphericParticleEmitter"
  72811. * @returns a string containing the class name
  72812. */
  72813. getClassName(): string;
  72814. /**
  72815. * Serializes the particle system to a JSON object.
  72816. * @returns the JSON object
  72817. */
  72818. serialize(): any;
  72819. /**
  72820. * Parse properties from a JSON object
  72821. * @param serializationObject defines the JSON object
  72822. */
  72823. parse(serializationObject: any): void;
  72824. }
  72825. }
  72826. declare module BABYLON {
  72827. /**
  72828. * Particle emitter emitting particles from a point.
  72829. * It emits the particles randomly between 2 given directions.
  72830. */
  72831. export class PointParticleEmitter implements IParticleEmitterType {
  72832. /**
  72833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72834. */
  72835. direction1: Vector3;
  72836. /**
  72837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72838. */
  72839. direction2: Vector3;
  72840. /**
  72841. * Creates a new instance PointParticleEmitter
  72842. */
  72843. constructor();
  72844. /**
  72845. * Called by the particle System when the direction is computed for the created particle.
  72846. * @param worldMatrix is the world matrix of the particle system
  72847. * @param directionToUpdate is the direction vector to update with the result
  72848. * @param particle is the particle we are computed the direction for
  72849. */
  72850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72851. /**
  72852. * Called by the particle System when the position is computed for the created particle.
  72853. * @param worldMatrix is the world matrix of the particle system
  72854. * @param positionToUpdate is the position vector to update with the result
  72855. * @param particle is the particle we are computed the position for
  72856. */
  72857. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72858. /**
  72859. * Clones the current emitter and returns a copy of it
  72860. * @returns the new emitter
  72861. */
  72862. clone(): PointParticleEmitter;
  72863. /**
  72864. * Called by the GPUParticleSystem to setup the update shader
  72865. * @param effect defines the update shader
  72866. */
  72867. applyToShader(effect: Effect): void;
  72868. /**
  72869. * Returns a string to use to update the GPU particles update shader
  72870. * @returns a string containng the defines string
  72871. */
  72872. getEffectDefines(): string;
  72873. /**
  72874. * Returns the string "PointParticleEmitter"
  72875. * @returns a string containing the class name
  72876. */
  72877. getClassName(): string;
  72878. /**
  72879. * Serializes the particle system to a JSON object.
  72880. * @returns the JSON object
  72881. */
  72882. serialize(): any;
  72883. /**
  72884. * Parse properties from a JSON object
  72885. * @param serializationObject defines the JSON object
  72886. */
  72887. parse(serializationObject: any): void;
  72888. }
  72889. }
  72890. declare module BABYLON {
  72891. /**
  72892. * Particle emitter emitting particles from the inside of a sphere.
  72893. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72894. */
  72895. export class SphereParticleEmitter implements IParticleEmitterType {
  72896. /**
  72897. * The radius of the emission sphere.
  72898. */
  72899. radius: number;
  72900. /**
  72901. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72902. */
  72903. radiusRange: number;
  72904. /**
  72905. * How much to randomize the particle direction [0-1].
  72906. */
  72907. directionRandomizer: number;
  72908. /**
  72909. * Creates a new instance SphereParticleEmitter
  72910. * @param radius the radius of the emission sphere (1 by default)
  72911. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72912. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72913. */
  72914. constructor(
  72915. /**
  72916. * The radius of the emission sphere.
  72917. */
  72918. radius?: number,
  72919. /**
  72920. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72921. */
  72922. radiusRange?: number,
  72923. /**
  72924. * How much to randomize the particle direction [0-1].
  72925. */
  72926. directionRandomizer?: number);
  72927. /**
  72928. * Called by the particle System when the direction is computed for the created particle.
  72929. * @param worldMatrix is the world matrix of the particle system
  72930. * @param directionToUpdate is the direction vector to update with the result
  72931. * @param particle is the particle we are computed the direction for
  72932. */
  72933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72934. /**
  72935. * Called by the particle System when the position is computed for the created particle.
  72936. * @param worldMatrix is the world matrix of the particle system
  72937. * @param positionToUpdate is the position vector to update with the result
  72938. * @param particle is the particle we are computed the position for
  72939. */
  72940. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72941. /**
  72942. * Clones the current emitter and returns a copy of it
  72943. * @returns the new emitter
  72944. */
  72945. clone(): SphereParticleEmitter;
  72946. /**
  72947. * Called by the GPUParticleSystem to setup the update shader
  72948. * @param effect defines the update shader
  72949. */
  72950. applyToShader(effect: Effect): void;
  72951. /**
  72952. * Returns a string to use to update the GPU particles update shader
  72953. * @returns a string containng the defines string
  72954. */
  72955. getEffectDefines(): string;
  72956. /**
  72957. * Returns the string "SphereParticleEmitter"
  72958. * @returns a string containing the class name
  72959. */
  72960. getClassName(): string;
  72961. /**
  72962. * Serializes the particle system to a JSON object.
  72963. * @returns the JSON object
  72964. */
  72965. serialize(): any;
  72966. /**
  72967. * Parse properties from a JSON object
  72968. * @param serializationObject defines the JSON object
  72969. */
  72970. parse(serializationObject: any): void;
  72971. }
  72972. /**
  72973. * Particle emitter emitting particles from the inside of a sphere.
  72974. * It emits the particles randomly between two vectors.
  72975. */
  72976. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72977. /**
  72978. * The min limit of the emission direction.
  72979. */
  72980. direction1: Vector3;
  72981. /**
  72982. * The max limit of the emission direction.
  72983. */
  72984. direction2: Vector3;
  72985. /**
  72986. * Creates a new instance SphereDirectedParticleEmitter
  72987. * @param radius the radius of the emission sphere (1 by default)
  72988. * @param direction1 the min limit of the emission direction (up vector by default)
  72989. * @param direction2 the max limit of the emission direction (up vector by default)
  72990. */
  72991. constructor(radius?: number,
  72992. /**
  72993. * The min limit of the emission direction.
  72994. */
  72995. direction1?: Vector3,
  72996. /**
  72997. * The max limit of the emission direction.
  72998. */
  72999. direction2?: Vector3);
  73000. /**
  73001. * Called by the particle System when the direction is computed for the created particle.
  73002. * @param worldMatrix is the world matrix of the particle system
  73003. * @param directionToUpdate is the direction vector to update with the result
  73004. * @param particle is the particle we are computed the direction for
  73005. */
  73006. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73007. /**
  73008. * Clones the current emitter and returns a copy of it
  73009. * @returns the new emitter
  73010. */
  73011. clone(): SphereDirectedParticleEmitter;
  73012. /**
  73013. * Called by the GPUParticleSystem to setup the update shader
  73014. * @param effect defines the update shader
  73015. */
  73016. applyToShader(effect: Effect): void;
  73017. /**
  73018. * Returns a string to use to update the GPU particles update shader
  73019. * @returns a string containng the defines string
  73020. */
  73021. getEffectDefines(): string;
  73022. /**
  73023. * Returns the string "SphereDirectedParticleEmitter"
  73024. * @returns a string containing the class name
  73025. */
  73026. getClassName(): string;
  73027. /**
  73028. * Serializes the particle system to a JSON object.
  73029. * @returns the JSON object
  73030. */
  73031. serialize(): any;
  73032. /**
  73033. * Parse properties from a JSON object
  73034. * @param serializationObject defines the JSON object
  73035. */
  73036. parse(serializationObject: any): void;
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /**
  73041. * Interface representing a particle system in Babylon.js.
  73042. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73043. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73044. */
  73045. export interface IParticleSystem {
  73046. /**
  73047. * List of animations used by the particle system.
  73048. */
  73049. animations: Animation[];
  73050. /**
  73051. * The id of the Particle system.
  73052. */
  73053. id: string;
  73054. /**
  73055. * The name of the Particle system.
  73056. */
  73057. name: string;
  73058. /**
  73059. * The emitter represents the Mesh or position we are attaching the particle system to.
  73060. */
  73061. emitter: Nullable<AbstractMesh | Vector3>;
  73062. /**
  73063. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73064. */
  73065. isBillboardBased: boolean;
  73066. /**
  73067. * The rendering group used by the Particle system to chose when to render.
  73068. */
  73069. renderingGroupId: number;
  73070. /**
  73071. * The layer mask we are rendering the particles through.
  73072. */
  73073. layerMask: number;
  73074. /**
  73075. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73076. */
  73077. updateSpeed: number;
  73078. /**
  73079. * The amount of time the particle system is running (depends of the overall update speed).
  73080. */
  73081. targetStopDuration: number;
  73082. /**
  73083. * The texture used to render each particle. (this can be a spritesheet)
  73084. */
  73085. particleTexture: Nullable<Texture>;
  73086. /**
  73087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73088. */
  73089. blendMode: number;
  73090. /**
  73091. * Minimum life time of emitting particles.
  73092. */
  73093. minLifeTime: number;
  73094. /**
  73095. * Maximum life time of emitting particles.
  73096. */
  73097. maxLifeTime: number;
  73098. /**
  73099. * Minimum Size of emitting particles.
  73100. */
  73101. minSize: number;
  73102. /**
  73103. * Maximum Size of emitting particles.
  73104. */
  73105. maxSize: number;
  73106. /**
  73107. * Minimum scale of emitting particles on X axis.
  73108. */
  73109. minScaleX: number;
  73110. /**
  73111. * Maximum scale of emitting particles on X axis.
  73112. */
  73113. maxScaleX: number;
  73114. /**
  73115. * Minimum scale of emitting particles on Y axis.
  73116. */
  73117. minScaleY: number;
  73118. /**
  73119. * Maximum scale of emitting particles on Y axis.
  73120. */
  73121. maxScaleY: number;
  73122. /**
  73123. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73124. */
  73125. color1: Color4;
  73126. /**
  73127. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73128. */
  73129. color2: Color4;
  73130. /**
  73131. * Color the particle will have at the end of its lifetime.
  73132. */
  73133. colorDead: Color4;
  73134. /**
  73135. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73136. */
  73137. emitRate: number;
  73138. /**
  73139. * You can use gravity if you want to give an orientation to your particles.
  73140. */
  73141. gravity: Vector3;
  73142. /**
  73143. * Minimum power of emitting particles.
  73144. */
  73145. minEmitPower: number;
  73146. /**
  73147. * Maximum power of emitting particles.
  73148. */
  73149. maxEmitPower: number;
  73150. /**
  73151. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73152. */
  73153. minAngularSpeed: number;
  73154. /**
  73155. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73156. */
  73157. maxAngularSpeed: number;
  73158. /**
  73159. * Gets or sets the minimal initial rotation in radians.
  73160. */
  73161. minInitialRotation: number;
  73162. /**
  73163. * Gets or sets the maximal initial rotation in radians.
  73164. */
  73165. maxInitialRotation: number;
  73166. /**
  73167. * The particle emitter type defines the emitter used by the particle system.
  73168. * It can be for example box, sphere, or cone...
  73169. */
  73170. particleEmitterType: Nullable<IParticleEmitterType>;
  73171. /**
  73172. * Defines the delay in milliseconds before starting the system (0 by default)
  73173. */
  73174. startDelay: number;
  73175. /**
  73176. * 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
  73177. */
  73178. preWarmCycles: number;
  73179. /**
  73180. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73181. */
  73182. preWarmStepOffset: number;
  73183. /**
  73184. * 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)
  73185. */
  73186. spriteCellChangeSpeed: number;
  73187. /**
  73188. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73189. */
  73190. startSpriteCellID: number;
  73191. /**
  73192. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73193. */
  73194. endSpriteCellID: number;
  73195. /**
  73196. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73197. */
  73198. spriteCellWidth: number;
  73199. /**
  73200. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73201. */
  73202. spriteCellHeight: number;
  73203. /**
  73204. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73205. */
  73206. spriteRandomStartCell: boolean;
  73207. /**
  73208. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73209. */
  73210. isAnimationSheetEnabled: boolean;
  73211. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73212. translationPivot: Vector2;
  73213. /**
  73214. * Gets or sets a texture used to add random noise to particle positions
  73215. */
  73216. noiseTexture: Nullable<BaseTexture>;
  73217. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73218. noiseStrength: Vector3;
  73219. /**
  73220. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73221. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73222. */
  73223. billboardMode: number;
  73224. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73225. limitVelocityDamping: number;
  73226. /**
  73227. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73228. */
  73229. beginAnimationOnStart: boolean;
  73230. /**
  73231. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73232. */
  73233. beginAnimationFrom: number;
  73234. /**
  73235. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73236. */
  73237. beginAnimationTo: number;
  73238. /**
  73239. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73240. */
  73241. beginAnimationLoop: boolean;
  73242. /**
  73243. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73244. */
  73245. disposeOnStop: boolean;
  73246. /**
  73247. * Gets the maximum number of particles active at the same time.
  73248. * @returns The max number of active particles.
  73249. */
  73250. getCapacity(): number;
  73251. /**
  73252. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73253. * @returns True if it has been started, otherwise false.
  73254. */
  73255. isStarted(): boolean;
  73256. /**
  73257. * Animates the particle system for this frame.
  73258. */
  73259. animate(): void;
  73260. /**
  73261. * Renders the particle system in its current state.
  73262. * @returns the current number of particles
  73263. */
  73264. render(): number;
  73265. /**
  73266. * Dispose the particle system and frees its associated resources.
  73267. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73268. */
  73269. dispose(disposeTexture?: boolean): void;
  73270. /**
  73271. * Clones the particle system.
  73272. * @param name The name of the cloned object
  73273. * @param newEmitter The new emitter to use
  73274. * @returns the cloned particle system
  73275. */
  73276. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73277. /**
  73278. * Serializes the particle system to a JSON object.
  73279. * @returns the JSON object
  73280. */
  73281. serialize(): any;
  73282. /**
  73283. * Rebuild the particle system
  73284. */
  73285. rebuild(): void;
  73286. /**
  73287. * Starts the particle system and begins to emit
  73288. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73289. */
  73290. start(delay?: number): void;
  73291. /**
  73292. * Stops the particle system.
  73293. */
  73294. stop(): void;
  73295. /**
  73296. * Remove all active particles
  73297. */
  73298. reset(): void;
  73299. /**
  73300. * Is this system ready to be used/rendered
  73301. * @return true if the system is ready
  73302. */
  73303. isReady(): boolean;
  73304. /**
  73305. * Adds a new color gradient
  73306. * @param gradient defines the gradient to use (between 0 and 1)
  73307. * @param color1 defines the color to affect to the specified gradient
  73308. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73309. * @returns the current particle system
  73310. */
  73311. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73312. /**
  73313. * Remove a specific color gradient
  73314. * @param gradient defines the gradient to remove
  73315. * @returns the current particle system
  73316. */
  73317. removeColorGradient(gradient: number): IParticleSystem;
  73318. /**
  73319. * Adds a new size gradient
  73320. * @param gradient defines the gradient to use (between 0 and 1)
  73321. * @param factor defines the size factor to affect to the specified gradient
  73322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73323. * @returns the current particle system
  73324. */
  73325. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73326. /**
  73327. * Remove a specific size gradient
  73328. * @param gradient defines the gradient to remove
  73329. * @returns the current particle system
  73330. */
  73331. removeSizeGradient(gradient: number): IParticleSystem;
  73332. /**
  73333. * Gets the current list of color gradients.
  73334. * You must use addColorGradient and removeColorGradient to udpate this list
  73335. * @returns the list of color gradients
  73336. */
  73337. getColorGradients(): Nullable<Array<ColorGradient>>;
  73338. /**
  73339. * Gets the current list of size gradients.
  73340. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73341. * @returns the list of size gradients
  73342. */
  73343. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73344. /**
  73345. * Gets the current list of angular speed gradients.
  73346. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73347. * @returns the list of angular speed gradients
  73348. */
  73349. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73350. /**
  73351. * Adds a new angular speed gradient
  73352. * @param gradient defines the gradient to use (between 0 and 1)
  73353. * @param factor defines the angular speed to affect to the specified gradient
  73354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73355. * @returns the current particle system
  73356. */
  73357. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73358. /**
  73359. * Remove a specific angular speed gradient
  73360. * @param gradient defines the gradient to remove
  73361. * @returns the current particle system
  73362. */
  73363. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73364. /**
  73365. * Gets the current list of velocity gradients.
  73366. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73367. * @returns the list of velocity gradients
  73368. */
  73369. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73370. /**
  73371. * Adds a new velocity gradient
  73372. * @param gradient defines the gradient to use (between 0 and 1)
  73373. * @param factor defines the velocity to affect to the specified gradient
  73374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73375. * @returns the current particle system
  73376. */
  73377. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73378. /**
  73379. * Remove a specific velocity gradient
  73380. * @param gradient defines the gradient to remove
  73381. * @returns the current particle system
  73382. */
  73383. removeVelocityGradient(gradient: number): IParticleSystem;
  73384. /**
  73385. * Gets the current list of limit velocity gradients.
  73386. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73387. * @returns the list of limit velocity gradients
  73388. */
  73389. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73390. /**
  73391. * Adds a new limit velocity gradient
  73392. * @param gradient defines the gradient to use (between 0 and 1)
  73393. * @param factor defines the limit velocity to affect to the specified gradient
  73394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73395. * @returns the current particle system
  73396. */
  73397. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73398. /**
  73399. * Remove a specific limit velocity gradient
  73400. * @param gradient defines the gradient to remove
  73401. * @returns the current particle system
  73402. */
  73403. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73404. /**
  73405. * Adds a new drag gradient
  73406. * @param gradient defines the gradient to use (between 0 and 1)
  73407. * @param factor defines the drag to affect to the specified gradient
  73408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73409. * @returns the current particle system
  73410. */
  73411. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73412. /**
  73413. * Remove a specific drag gradient
  73414. * @param gradient defines the gradient to remove
  73415. * @returns the current particle system
  73416. */
  73417. removeDragGradient(gradient: number): IParticleSystem;
  73418. /**
  73419. * Gets the current list of drag gradients.
  73420. * You must use addDragGradient and removeDragGradient to udpate this list
  73421. * @returns the list of drag gradients
  73422. */
  73423. getDragGradients(): Nullable<Array<FactorGradient>>;
  73424. /**
  73425. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73426. * @param gradient defines the gradient to use (between 0 and 1)
  73427. * @param factor defines the emit rate to affect to the specified gradient
  73428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73429. * @returns the current particle system
  73430. */
  73431. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73432. /**
  73433. * Remove a specific emit rate gradient
  73434. * @param gradient defines the gradient to remove
  73435. * @returns the current particle system
  73436. */
  73437. removeEmitRateGradient(gradient: number): IParticleSystem;
  73438. /**
  73439. * Gets the current list of emit rate gradients.
  73440. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73441. * @returns the list of emit rate gradients
  73442. */
  73443. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73444. /**
  73445. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73446. * @param gradient defines the gradient to use (between 0 and 1)
  73447. * @param factor defines the start size to affect to the specified gradient
  73448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73449. * @returns the current particle system
  73450. */
  73451. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73452. /**
  73453. * Remove a specific start size gradient
  73454. * @param gradient defines the gradient to remove
  73455. * @returns the current particle system
  73456. */
  73457. removeStartSizeGradient(gradient: number): IParticleSystem;
  73458. /**
  73459. * Gets the current list of start size gradients.
  73460. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73461. * @returns the list of start size gradients
  73462. */
  73463. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73464. /**
  73465. * Adds a new life time gradient
  73466. * @param gradient defines the gradient to use (between 0 and 1)
  73467. * @param factor defines the life time factor to affect to the specified gradient
  73468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73469. * @returns the current particle system
  73470. */
  73471. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73472. /**
  73473. * Remove a specific life time gradient
  73474. * @param gradient defines the gradient to remove
  73475. * @returns the current particle system
  73476. */
  73477. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73478. /**
  73479. * Gets the current list of life time gradients.
  73480. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73481. * @returns the list of life time gradients
  73482. */
  73483. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73484. /**
  73485. * Gets the current list of color gradients.
  73486. * You must use addColorGradient and removeColorGradient to udpate this list
  73487. * @returns the list of color gradients
  73488. */
  73489. getColorGradients(): Nullable<Array<ColorGradient>>;
  73490. /**
  73491. * Adds a new ramp gradient used to remap particle colors
  73492. * @param gradient defines the gradient to use (between 0 and 1)
  73493. * @param color defines the color to affect to the specified gradient
  73494. * @returns the current particle system
  73495. */
  73496. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73497. /**
  73498. * Gets the current list of ramp gradients.
  73499. * You must use addRampGradient and removeRampGradient to udpate this list
  73500. * @returns the list of ramp gradients
  73501. */
  73502. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73503. /** Gets or sets a boolean indicating that ramp gradients must be used
  73504. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73505. */
  73506. useRampGradients: boolean;
  73507. /**
  73508. * Adds a new color remap gradient
  73509. * @param gradient defines the gradient to use (between 0 and 1)
  73510. * @param min defines the color remap minimal range
  73511. * @param max defines the color remap maximal range
  73512. * @returns the current particle system
  73513. */
  73514. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73515. /**
  73516. * Gets the current list of color remap gradients.
  73517. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73518. * @returns the list of color remap gradients
  73519. */
  73520. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73521. /**
  73522. * Adds a new alpha remap gradient
  73523. * @param gradient defines the gradient to use (between 0 and 1)
  73524. * @param min defines the alpha remap minimal range
  73525. * @param max defines the alpha remap maximal range
  73526. * @returns the current particle system
  73527. */
  73528. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73529. /**
  73530. * Gets the current list of alpha remap gradients.
  73531. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73532. * @returns the list of alpha remap gradients
  73533. */
  73534. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73535. /**
  73536. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73537. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73538. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73539. * @returns the emitter
  73540. */
  73541. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73542. /**
  73543. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73544. * @param radius The radius of the hemisphere to emit from
  73545. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73546. * @returns the emitter
  73547. */
  73548. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73549. /**
  73550. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73551. * @param radius The radius of the sphere to emit from
  73552. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73553. * @returns the emitter
  73554. */
  73555. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73556. /**
  73557. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73558. * @param radius The radius of the sphere to emit from
  73559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73561. * @returns the emitter
  73562. */
  73563. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73564. /**
  73565. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73566. * @param radius The radius of the emission cylinder
  73567. * @param height The height of the emission cylinder
  73568. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73569. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73570. * @returns the emitter
  73571. */
  73572. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73573. /**
  73574. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73575. * @param radius The radius of the cylinder to emit from
  73576. * @param height The height of the emission cylinder
  73577. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73580. * @returns the emitter
  73581. */
  73582. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73583. /**
  73584. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73585. * @param radius The radius of the cone to emit from
  73586. * @param angle The base angle of the cone
  73587. * @returns the emitter
  73588. */
  73589. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73590. /**
  73591. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73592. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73593. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73594. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73595. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73596. * @returns the emitter
  73597. */
  73598. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73599. /**
  73600. * Get hosting scene
  73601. * @returns the scene
  73602. */
  73603. getScene(): Scene;
  73604. }
  73605. }
  73606. declare module BABYLON {
  73607. /**
  73608. * Creates an instance based on a source mesh.
  73609. */
  73610. export class InstancedMesh extends AbstractMesh {
  73611. private _sourceMesh;
  73612. private _currentLOD;
  73613. /** @hidden */
  73614. _indexInSourceMeshInstanceArray: number;
  73615. constructor(name: string, source: Mesh);
  73616. /**
  73617. * Returns the string "InstancedMesh".
  73618. */
  73619. getClassName(): string;
  73620. /**
  73621. * If the source mesh receives shadows
  73622. */
  73623. readonly receiveShadows: boolean;
  73624. /**
  73625. * The material of the source mesh
  73626. */
  73627. readonly material: Nullable<Material>;
  73628. /**
  73629. * Visibility of the source mesh
  73630. */
  73631. readonly visibility: number;
  73632. /**
  73633. * Skeleton of the source mesh
  73634. */
  73635. readonly skeleton: Nullable<Skeleton>;
  73636. /**
  73637. * Rendering ground id of the source mesh
  73638. */
  73639. renderingGroupId: number;
  73640. /**
  73641. * Returns the total number of vertices (integer).
  73642. */
  73643. getTotalVertices(): number;
  73644. /**
  73645. * Returns a positive integer : the total number of indices in this mesh geometry.
  73646. * @returns the numner of indices or zero if the mesh has no geometry.
  73647. */
  73648. getTotalIndices(): number;
  73649. /**
  73650. * The source mesh of the instance
  73651. */
  73652. readonly sourceMesh: Mesh;
  73653. /**
  73654. * Is this node ready to be used/rendered
  73655. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73656. * @return {boolean} is it ready
  73657. */
  73658. isReady(completeCheck?: boolean): boolean;
  73659. /**
  73660. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73661. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73662. * @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.
  73663. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73664. */
  73665. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73666. /**
  73667. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73668. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73669. * The `data` are either a numeric array either a Float32Array.
  73670. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73671. * 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).
  73672. * Note that a new underlying VertexBuffer object is created each call.
  73673. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73674. *
  73675. * Possible `kind` values :
  73676. * - VertexBuffer.PositionKind
  73677. * - VertexBuffer.UVKind
  73678. * - VertexBuffer.UV2Kind
  73679. * - VertexBuffer.UV3Kind
  73680. * - VertexBuffer.UV4Kind
  73681. * - VertexBuffer.UV5Kind
  73682. * - VertexBuffer.UV6Kind
  73683. * - VertexBuffer.ColorKind
  73684. * - VertexBuffer.MatricesIndicesKind
  73685. * - VertexBuffer.MatricesIndicesExtraKind
  73686. * - VertexBuffer.MatricesWeightsKind
  73687. * - VertexBuffer.MatricesWeightsExtraKind
  73688. *
  73689. * Returns the Mesh.
  73690. */
  73691. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73692. /**
  73693. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73694. * If the mesh has no geometry, it is simply returned as it is.
  73695. * The `data` are either a numeric array either a Float32Array.
  73696. * No new underlying VertexBuffer object is created.
  73697. * 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.
  73698. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73699. *
  73700. * Possible `kind` values :
  73701. * - VertexBuffer.PositionKind
  73702. * - VertexBuffer.UVKind
  73703. * - VertexBuffer.UV2Kind
  73704. * - VertexBuffer.UV3Kind
  73705. * - VertexBuffer.UV4Kind
  73706. * - VertexBuffer.UV5Kind
  73707. * - VertexBuffer.UV6Kind
  73708. * - VertexBuffer.ColorKind
  73709. * - VertexBuffer.MatricesIndicesKind
  73710. * - VertexBuffer.MatricesIndicesExtraKind
  73711. * - VertexBuffer.MatricesWeightsKind
  73712. * - VertexBuffer.MatricesWeightsExtraKind
  73713. *
  73714. * Returns the Mesh.
  73715. */
  73716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73717. /**
  73718. * Sets the mesh indices.
  73719. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73720. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73721. * This method creates a new index buffer each call.
  73722. * Returns the Mesh.
  73723. */
  73724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73725. /**
  73726. * Boolean : True if the mesh owns the requested kind of data.
  73727. */
  73728. isVerticesDataPresent(kind: string): boolean;
  73729. /**
  73730. * Returns an array of indices (IndicesArray).
  73731. */
  73732. getIndices(): Nullable<IndicesArray>;
  73733. readonly _positions: Nullable<Vector3[]>;
  73734. /**
  73735. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73736. * This means the mesh underlying bounding box and sphere are recomputed.
  73737. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73738. * @returns the current mesh
  73739. */
  73740. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73741. /** @hidden */
  73742. _preActivate(): InstancedMesh;
  73743. /** @hidden */
  73744. _activate(renderId: number): InstancedMesh;
  73745. /**
  73746. * Returns the current associated LOD AbstractMesh.
  73747. */
  73748. getLOD(camera: Camera): AbstractMesh;
  73749. /** @hidden */
  73750. _syncSubMeshes(): InstancedMesh;
  73751. /** @hidden */
  73752. _generatePointsArray(): boolean;
  73753. /**
  73754. * Creates a new InstancedMesh from the current mesh.
  73755. * - name (string) : the cloned mesh name
  73756. * - newParent (optional Node) : the optional Node to parent the clone to.
  73757. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73758. *
  73759. * Returns the clone.
  73760. */
  73761. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73762. /**
  73763. * Disposes the InstancedMesh.
  73764. * Returns nothing.
  73765. */
  73766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73767. }
  73768. }
  73769. declare module BABYLON {
  73770. /**
  73771. * Defines the options associated with the creation of a shader material.
  73772. */
  73773. export interface IShaderMaterialOptions {
  73774. /**
  73775. * Does the material work in alpha blend mode
  73776. */
  73777. needAlphaBlending: boolean;
  73778. /**
  73779. * Does the material work in alpha test mode
  73780. */
  73781. needAlphaTesting: boolean;
  73782. /**
  73783. * The list of attribute names used in the shader
  73784. */
  73785. attributes: string[];
  73786. /**
  73787. * The list of unifrom names used in the shader
  73788. */
  73789. uniforms: string[];
  73790. /**
  73791. * The list of UBO names used in the shader
  73792. */
  73793. uniformBuffers: string[];
  73794. /**
  73795. * The list of sampler names used in the shader
  73796. */
  73797. samplers: string[];
  73798. /**
  73799. * The list of defines used in the shader
  73800. */
  73801. defines: string[];
  73802. }
  73803. /**
  73804. * 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.
  73805. *
  73806. * This returned material effects how the mesh will look based on the code in the shaders.
  73807. *
  73808. * @see http://doc.babylonjs.com/how_to/shader_material
  73809. */
  73810. export class ShaderMaterial extends Material {
  73811. private _shaderPath;
  73812. private _options;
  73813. private _textures;
  73814. private _textureArrays;
  73815. private _floats;
  73816. private _ints;
  73817. private _floatsArrays;
  73818. private _colors3;
  73819. private _colors3Arrays;
  73820. private _colors4;
  73821. private _vectors2;
  73822. private _vectors3;
  73823. private _vectors4;
  73824. private _matrices;
  73825. private _matrices3x3;
  73826. private _matrices2x2;
  73827. private _vectors2Arrays;
  73828. private _vectors3Arrays;
  73829. private _cachedWorldViewMatrix;
  73830. private _renderId;
  73831. /**
  73832. * Instantiate a new shader material.
  73833. * 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.
  73834. * This returned material effects how the mesh will look based on the code in the shaders.
  73835. * @see http://doc.babylonjs.com/how_to/shader_material
  73836. * @param name Define the name of the material in the scene
  73837. * @param scene Define the scene the material belongs to
  73838. * @param shaderPath Defines the route to the shader code in one of three ways:
  73839. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73840. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73841. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73842. * @param options Define the options used to create the shader
  73843. */
  73844. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73845. /**
  73846. * Gets the current class name of the material e.g. "ShaderMaterial"
  73847. * Mainly use in serialization.
  73848. * @returns the class name
  73849. */
  73850. getClassName(): string;
  73851. /**
  73852. * Specifies if the material will require alpha blending
  73853. * @returns a boolean specifying if alpha blending is needed
  73854. */
  73855. needAlphaBlending(): boolean;
  73856. /**
  73857. * Specifies if this material should be rendered in alpha test mode
  73858. * @returns a boolean specifying if an alpha test is needed.
  73859. */
  73860. needAlphaTesting(): boolean;
  73861. private _checkUniform;
  73862. /**
  73863. * Set a texture in the shader.
  73864. * @param name Define the name of the uniform samplers as defined in the shader
  73865. * @param texture Define the texture to bind to this sampler
  73866. * @return the material itself allowing "fluent" like uniform updates
  73867. */
  73868. setTexture(name: string, texture: Texture): ShaderMaterial;
  73869. /**
  73870. * Set a texture array in the shader.
  73871. * @param name Define the name of the uniform sampler array as defined in the shader
  73872. * @param textures Define the list of textures to bind to this sampler
  73873. * @return the material itself allowing "fluent" like uniform updates
  73874. */
  73875. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73876. /**
  73877. * Set a float in the shader.
  73878. * @param name Define the name of the uniform as defined in the shader
  73879. * @param value Define the value to give to the uniform
  73880. * @return the material itself allowing "fluent" like uniform updates
  73881. */
  73882. setFloat(name: string, value: number): ShaderMaterial;
  73883. /**
  73884. * Set a int in the shader.
  73885. * @param name Define the name of the uniform as defined in the shader
  73886. * @param value Define the value to give to the uniform
  73887. * @return the material itself allowing "fluent" like uniform updates
  73888. */
  73889. setInt(name: string, value: number): ShaderMaterial;
  73890. /**
  73891. * Set an array of floats in the shader.
  73892. * @param name Define the name of the uniform as defined in the shader
  73893. * @param value Define the value to give to the uniform
  73894. * @return the material itself allowing "fluent" like uniform updates
  73895. */
  73896. setFloats(name: string, value: number[]): ShaderMaterial;
  73897. /**
  73898. * Set a vec3 in the shader from a Color3.
  73899. * @param name Define the name of the uniform as defined in the shader
  73900. * @param value Define the value to give to the uniform
  73901. * @return the material itself allowing "fluent" like uniform updates
  73902. */
  73903. setColor3(name: string, value: Color3): ShaderMaterial;
  73904. /**
  73905. * Set a vec3 array in the shader from a Color3 array.
  73906. * @param name Define the name of the uniform as defined in the shader
  73907. * @param value Define the value to give to the uniform
  73908. * @return the material itself allowing "fluent" like uniform updates
  73909. */
  73910. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73911. /**
  73912. * Set a vec4 in the shader from a Color4.
  73913. * @param name Define the name of the uniform as defined in the shader
  73914. * @param value Define the value to give to the uniform
  73915. * @return the material itself allowing "fluent" like uniform updates
  73916. */
  73917. setColor4(name: string, value: Color4): ShaderMaterial;
  73918. /**
  73919. * Set a vec2 in the shader from a Vector2.
  73920. * @param name Define the name of the uniform as defined in the shader
  73921. * @param value Define the value to give to the uniform
  73922. * @return the material itself allowing "fluent" like uniform updates
  73923. */
  73924. setVector2(name: string, value: Vector2): ShaderMaterial;
  73925. /**
  73926. * Set a vec3 in the shader from a Vector3.
  73927. * @param name Define the name of the uniform as defined in the shader
  73928. * @param value Define the value to give to the uniform
  73929. * @return the material itself allowing "fluent" like uniform updates
  73930. */
  73931. setVector3(name: string, value: Vector3): ShaderMaterial;
  73932. /**
  73933. * Set a vec4 in the shader from a Vector4.
  73934. * @param name Define the name of the uniform as defined in the shader
  73935. * @param value Define the value to give to the uniform
  73936. * @return the material itself allowing "fluent" like uniform updates
  73937. */
  73938. setVector4(name: string, value: Vector4): ShaderMaterial;
  73939. /**
  73940. * Set a mat4 in the shader from a Matrix.
  73941. * @param name Define the name of the uniform as defined in the shader
  73942. * @param value Define the value to give to the uniform
  73943. * @return the material itself allowing "fluent" like uniform updates
  73944. */
  73945. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73946. /**
  73947. * Set a mat3 in the shader from a Float32Array.
  73948. * @param name Define the name of the uniform as defined in the shader
  73949. * @param value Define the value to give to the uniform
  73950. * @return the material itself allowing "fluent" like uniform updates
  73951. */
  73952. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73953. /**
  73954. * Set a mat2 in the shader from a Float32Array.
  73955. * @param name Define the name of the uniform as defined in the shader
  73956. * @param value Define the value to give to the uniform
  73957. * @return the material itself allowing "fluent" like uniform updates
  73958. */
  73959. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73960. /**
  73961. * Set a vec2 array in the shader from a number array.
  73962. * @param name Define the name of the uniform as defined in the shader
  73963. * @param value Define the value to give to the uniform
  73964. * @return the material itself allowing "fluent" like uniform updates
  73965. */
  73966. setArray2(name: string, value: number[]): ShaderMaterial;
  73967. /**
  73968. * Set a vec3 array in the shader from a number array.
  73969. * @param name Define the name of the uniform as defined in the shader
  73970. * @param value Define the value to give to the uniform
  73971. * @return the material itself allowing "fluent" like uniform updates
  73972. */
  73973. setArray3(name: string, value: number[]): ShaderMaterial;
  73974. private _checkCache;
  73975. /**
  73976. * Checks if the material is ready to render the requested mesh
  73977. * @param mesh Define the mesh to render
  73978. * @param useInstances Define whether or not the material is used with instances
  73979. * @returns true if ready, otherwise false
  73980. */
  73981. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73982. /**
  73983. * Binds the world matrix to the material
  73984. * @param world defines the world transformation matrix
  73985. */
  73986. bindOnlyWorldMatrix(world: Matrix): void;
  73987. /**
  73988. * Binds the material to the mesh
  73989. * @param world defines the world transformation matrix
  73990. * @param mesh defines the mesh to bind the material to
  73991. */
  73992. bind(world: Matrix, mesh?: Mesh): void;
  73993. /**
  73994. * Gets the active textures from the material
  73995. * @returns an array of textures
  73996. */
  73997. getActiveTextures(): BaseTexture[];
  73998. /**
  73999. * Specifies if the material uses a texture
  74000. * @param texture defines the texture to check against the material
  74001. * @returns a boolean specifying if the material uses the texture
  74002. */
  74003. hasTexture(texture: BaseTexture): boolean;
  74004. /**
  74005. * Makes a duplicate of the material, and gives it a new name
  74006. * @param name defines the new name for the duplicated material
  74007. * @returns the cloned material
  74008. */
  74009. clone(name: string): ShaderMaterial;
  74010. /**
  74011. * Disposes the material
  74012. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74013. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74014. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74015. */
  74016. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74017. /**
  74018. * Serializes this material in a JSON representation
  74019. * @returns the serialized material object
  74020. */
  74021. serialize(): any;
  74022. /**
  74023. * Creates a shader material from parsed shader material data
  74024. * @param source defines the JSON represnetation of the material
  74025. * @param scene defines the hosting scene
  74026. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74027. * @returns a new material
  74028. */
  74029. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74030. }
  74031. }
  74032. declare module BABYLON {
  74033. /** @hidden */
  74034. export var colorPixelShader: {
  74035. name: string;
  74036. shader: string;
  74037. };
  74038. }
  74039. declare module BABYLON {
  74040. /** @hidden */
  74041. export var colorVertexShader: {
  74042. name: string;
  74043. shader: string;
  74044. };
  74045. }
  74046. declare module BABYLON {
  74047. /**
  74048. * Line mesh
  74049. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74050. */
  74051. export class LinesMesh extends Mesh {
  74052. /**
  74053. * If vertex color should be applied to the mesh
  74054. */
  74055. useVertexColor?: boolean | undefined;
  74056. /**
  74057. * If vertex alpha should be applied to the mesh
  74058. */
  74059. useVertexAlpha?: boolean | undefined;
  74060. /**
  74061. * Color of the line (Default: White)
  74062. */
  74063. color: Color3;
  74064. /**
  74065. * Alpha of the line (Default: 1)
  74066. */
  74067. alpha: number;
  74068. /**
  74069. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74070. * This margin is expressed in world space coordinates, so its value may vary.
  74071. * Default value is 0.1
  74072. */
  74073. intersectionThreshold: number;
  74074. private _colorShader;
  74075. /**
  74076. * Creates a new LinesMesh
  74077. * @param name defines the name
  74078. * @param scene defines the hosting scene
  74079. * @param parent defines the parent mesh if any
  74080. * @param source defines the optional source LinesMesh used to clone data from
  74081. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74082. * When false, achieved by calling a clone(), also passing False.
  74083. * This will make creation of children, recursive.
  74084. * @param useVertexColor defines if this LinesMesh supports vertex color
  74085. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74086. */
  74087. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74088. /**
  74089. * If vertex color should be applied to the mesh
  74090. */
  74091. useVertexColor?: boolean | undefined,
  74092. /**
  74093. * If vertex alpha should be applied to the mesh
  74094. */
  74095. useVertexAlpha?: boolean | undefined);
  74096. /**
  74097. * Returns the string "LineMesh"
  74098. */
  74099. getClassName(): string;
  74100. /**
  74101. * @hidden
  74102. */
  74103. /**
  74104. * @hidden
  74105. */
  74106. material: Material;
  74107. /**
  74108. * @hidden
  74109. */
  74110. readonly checkCollisions: boolean;
  74111. /** @hidden */
  74112. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74113. /** @hidden */
  74114. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74115. /**
  74116. * Disposes of the line mesh
  74117. * @param doNotRecurse If children should be disposed
  74118. */
  74119. dispose(doNotRecurse?: boolean): void;
  74120. /**
  74121. * Returns a new LineMesh object cloned from the current one.
  74122. */
  74123. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74124. /**
  74125. * Creates a new InstancedLinesMesh object from the mesh model.
  74126. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74127. * @param name defines the name of the new instance
  74128. * @returns a new InstancedLinesMesh
  74129. */
  74130. createInstance(name: string): InstancedLinesMesh;
  74131. }
  74132. /**
  74133. * Creates an instance based on a source LinesMesh
  74134. */
  74135. export class InstancedLinesMesh extends InstancedMesh {
  74136. /**
  74137. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74138. * This margin is expressed in world space coordinates, so its value may vary.
  74139. * Initilized with the intersectionThreshold value of the source LinesMesh
  74140. */
  74141. intersectionThreshold: number;
  74142. constructor(name: string, source: LinesMesh);
  74143. /**
  74144. * Returns the string "InstancedLinesMesh".
  74145. */
  74146. getClassName(): string;
  74147. }
  74148. }
  74149. declare module BABYLON {
  74150. /** @hidden */
  74151. export var linePixelShader: {
  74152. name: string;
  74153. shader: string;
  74154. };
  74155. }
  74156. declare module BABYLON {
  74157. /** @hidden */
  74158. export var lineVertexShader: {
  74159. name: string;
  74160. shader: string;
  74161. };
  74162. }
  74163. declare module BABYLON {
  74164. interface AbstractMesh {
  74165. /**
  74166. * Disables the mesh edge rendering mode
  74167. * @returns the currentAbstractMesh
  74168. */
  74169. disableEdgesRendering(): AbstractMesh;
  74170. /**
  74171. * Enables the edge rendering mode on the mesh.
  74172. * This mode makes the mesh edges visible
  74173. * @param epsilon defines the maximal distance between two angles to detect a face
  74174. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74175. * @returns the currentAbstractMesh
  74176. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74177. */
  74178. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74179. /**
  74180. * Gets the edgesRenderer associated with the mesh
  74181. */
  74182. edgesRenderer: Nullable<EdgesRenderer>;
  74183. }
  74184. interface LinesMesh {
  74185. /**
  74186. * Enables the edge rendering mode on the mesh.
  74187. * This mode makes the mesh edges visible
  74188. * @param epsilon defines the maximal distance between two angles to detect a face
  74189. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74190. * @returns the currentAbstractMesh
  74191. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74192. */
  74193. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74194. }
  74195. interface InstancedLinesMesh {
  74196. /**
  74197. * Enables the edge rendering mode on the mesh.
  74198. * This mode makes the mesh edges visible
  74199. * @param epsilon defines the maximal distance between two angles to detect a face
  74200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74201. * @returns the current InstancedLinesMesh
  74202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74203. */
  74204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74205. }
  74206. /**
  74207. * Defines the minimum contract an Edges renderer should follow.
  74208. */
  74209. export interface IEdgesRenderer extends IDisposable {
  74210. /**
  74211. * Gets or sets a boolean indicating if the edgesRenderer is active
  74212. */
  74213. isEnabled: boolean;
  74214. /**
  74215. * Renders the edges of the attached mesh,
  74216. */
  74217. render(): void;
  74218. /**
  74219. * Checks wether or not the edges renderer is ready to render.
  74220. * @return true if ready, otherwise false.
  74221. */
  74222. isReady(): boolean;
  74223. }
  74224. /**
  74225. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74226. */
  74227. export class EdgesRenderer implements IEdgesRenderer {
  74228. /**
  74229. * Define the size of the edges with an orthographic camera
  74230. */
  74231. edgesWidthScalerForOrthographic: number;
  74232. /**
  74233. * Define the size of the edges with a perspective camera
  74234. */
  74235. edgesWidthScalerForPerspective: number;
  74236. protected _source: AbstractMesh;
  74237. protected _linesPositions: number[];
  74238. protected _linesNormals: number[];
  74239. protected _linesIndices: number[];
  74240. protected _epsilon: number;
  74241. protected _indicesCount: number;
  74242. protected _lineShader: ShaderMaterial;
  74243. protected _ib: WebGLBuffer;
  74244. protected _buffers: {
  74245. [key: string]: Nullable<VertexBuffer>;
  74246. };
  74247. protected _checkVerticesInsteadOfIndices: boolean;
  74248. private _meshRebuildObserver;
  74249. private _meshDisposeObserver;
  74250. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74251. isEnabled: boolean;
  74252. /**
  74253. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74254. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74255. * @param source Mesh used to create edges
  74256. * @param epsilon sum of angles in adjacency to check for edge
  74257. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74258. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74259. */
  74260. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74261. protected _prepareRessources(): void;
  74262. /** @hidden */
  74263. _rebuild(): void;
  74264. /**
  74265. * Releases the required resources for the edges renderer
  74266. */
  74267. dispose(): void;
  74268. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74269. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74270. /**
  74271. * Checks if the pair of p0 and p1 is en edge
  74272. * @param faceIndex
  74273. * @param edge
  74274. * @param faceNormals
  74275. * @param p0
  74276. * @param p1
  74277. * @private
  74278. */
  74279. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74280. /**
  74281. * push line into the position, normal and index buffer
  74282. * @protected
  74283. */
  74284. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74285. /**
  74286. * Generates lines edges from adjacencjes
  74287. * @private
  74288. */
  74289. _generateEdgesLines(): void;
  74290. /**
  74291. * Checks wether or not the edges renderer is ready to render.
  74292. * @return true if ready, otherwise false.
  74293. */
  74294. isReady(): boolean;
  74295. /**
  74296. * Renders the edges of the attached mesh,
  74297. */
  74298. render(): void;
  74299. }
  74300. /**
  74301. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74302. */
  74303. export class LineEdgesRenderer extends EdgesRenderer {
  74304. /**
  74305. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74306. * @param source LineMesh used to generate edges
  74307. * @param epsilon not important (specified angle for edge detection)
  74308. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74309. */
  74310. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74311. /**
  74312. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74313. */
  74314. _generateEdgesLines(): void;
  74315. }
  74316. }
  74317. declare module BABYLON {
  74318. /**
  74319. * This represents the object necessary to create a rendering group.
  74320. * This is exclusively used and created by the rendering manager.
  74321. * To modify the behavior, you use the available helpers in your scene or meshes.
  74322. * @hidden
  74323. */
  74324. export class RenderingGroup {
  74325. index: number;
  74326. private _scene;
  74327. private _opaqueSubMeshes;
  74328. private _transparentSubMeshes;
  74329. private _alphaTestSubMeshes;
  74330. private _depthOnlySubMeshes;
  74331. private _particleSystems;
  74332. private _spriteManagers;
  74333. private _opaqueSortCompareFn;
  74334. private _alphaTestSortCompareFn;
  74335. private _transparentSortCompareFn;
  74336. private _renderOpaque;
  74337. private _renderAlphaTest;
  74338. private _renderTransparent;
  74339. private _edgesRenderers;
  74340. onBeforeTransparentRendering: () => void;
  74341. /**
  74342. * Set the opaque sort comparison function.
  74343. * If null the sub meshes will be render in the order they were created
  74344. */
  74345. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74346. /**
  74347. * Set the alpha test sort comparison function.
  74348. * If null the sub meshes will be render in the order they were created
  74349. */
  74350. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74351. /**
  74352. * Set the transparent sort comparison function.
  74353. * If null the sub meshes will be render in the order they were created
  74354. */
  74355. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74356. /**
  74357. * Creates a new rendering group.
  74358. * @param index The rendering group index
  74359. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74360. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74361. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74362. */
  74363. 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>);
  74364. /**
  74365. * Render all the sub meshes contained in the group.
  74366. * @param customRenderFunction Used to override the default render behaviour of the group.
  74367. * @returns true if rendered some submeshes.
  74368. */
  74369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74370. /**
  74371. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74372. * @param subMeshes The submeshes to render
  74373. */
  74374. private renderOpaqueSorted;
  74375. /**
  74376. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74377. * @param subMeshes The submeshes to render
  74378. */
  74379. private renderAlphaTestSorted;
  74380. /**
  74381. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74382. * @param subMeshes The submeshes to render
  74383. */
  74384. private renderTransparentSorted;
  74385. /**
  74386. * Renders the submeshes in a specified order.
  74387. * @param subMeshes The submeshes to sort before render
  74388. * @param sortCompareFn The comparison function use to sort
  74389. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74390. * @param transparent Specifies to activate blending if true
  74391. */
  74392. private static renderSorted;
  74393. /**
  74394. * Renders the submeshes in the order they were dispatched (no sort applied).
  74395. * @param subMeshes The submeshes to render
  74396. */
  74397. private static renderUnsorted;
  74398. /**
  74399. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74400. * are rendered back to front if in the same alpha index.
  74401. *
  74402. * @param a The first submesh
  74403. * @param b The second submesh
  74404. * @returns The result of the comparison
  74405. */
  74406. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74407. /**
  74408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74409. * are rendered back to front.
  74410. *
  74411. * @param a The first submesh
  74412. * @param b The second submesh
  74413. * @returns The result of the comparison
  74414. */
  74415. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74416. /**
  74417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74418. * are rendered front to back (prevent overdraw).
  74419. *
  74420. * @param a The first submesh
  74421. * @param b The second submesh
  74422. * @returns The result of the comparison
  74423. */
  74424. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74425. /**
  74426. * Resets the different lists of submeshes to prepare a new frame.
  74427. */
  74428. prepare(): void;
  74429. dispose(): void;
  74430. /**
  74431. * Inserts the submesh in its correct queue depending on its material.
  74432. * @param subMesh The submesh to dispatch
  74433. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74434. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74435. */
  74436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74437. dispatchSprites(spriteManager: ISpriteManager): void;
  74438. dispatchParticles(particleSystem: IParticleSystem): void;
  74439. private _renderParticles;
  74440. private _renderSprites;
  74441. }
  74442. }
  74443. declare module BABYLON {
  74444. /**
  74445. * Interface describing the different options available in the rendering manager
  74446. * regarding Auto Clear between groups.
  74447. */
  74448. export interface IRenderingManagerAutoClearSetup {
  74449. /**
  74450. * Defines whether or not autoclear is enable.
  74451. */
  74452. autoClear: boolean;
  74453. /**
  74454. * Defines whether or not to autoclear the depth buffer.
  74455. */
  74456. depth: boolean;
  74457. /**
  74458. * Defines whether or not to autoclear the stencil buffer.
  74459. */
  74460. stencil: boolean;
  74461. }
  74462. /**
  74463. * This class is used by the onRenderingGroupObservable
  74464. */
  74465. export class RenderingGroupInfo {
  74466. /**
  74467. * The Scene that being rendered
  74468. */
  74469. scene: Scene;
  74470. /**
  74471. * The camera currently used for the rendering pass
  74472. */
  74473. camera: Nullable<Camera>;
  74474. /**
  74475. * The ID of the renderingGroup being processed
  74476. */
  74477. renderingGroupId: number;
  74478. }
  74479. /**
  74480. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74481. * It is enable to manage the different groups as well as the different necessary sort functions.
  74482. * This should not be used directly aside of the few static configurations
  74483. */
  74484. export class RenderingManager {
  74485. /**
  74486. * The max id used for rendering groups (not included)
  74487. */
  74488. static MAX_RENDERINGGROUPS: number;
  74489. /**
  74490. * The min id used for rendering groups (included)
  74491. */
  74492. static MIN_RENDERINGGROUPS: number;
  74493. /**
  74494. * Used to globally prevent autoclearing scenes.
  74495. */
  74496. static AUTOCLEAR: boolean;
  74497. /**
  74498. * @hidden
  74499. */
  74500. _useSceneAutoClearSetup: boolean;
  74501. private _scene;
  74502. private _renderingGroups;
  74503. private _depthStencilBufferAlreadyCleaned;
  74504. private _autoClearDepthStencil;
  74505. private _customOpaqueSortCompareFn;
  74506. private _customAlphaTestSortCompareFn;
  74507. private _customTransparentSortCompareFn;
  74508. private _renderingGroupInfo;
  74509. /**
  74510. * Instantiates a new rendering group for a particular scene
  74511. * @param scene Defines the scene the groups belongs to
  74512. */
  74513. constructor(scene: Scene);
  74514. private _clearDepthStencilBuffer;
  74515. /**
  74516. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74517. * @hidden
  74518. */
  74519. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74520. /**
  74521. * Resets the different information of the group to prepare a new frame
  74522. * @hidden
  74523. */
  74524. reset(): void;
  74525. /**
  74526. * Dispose and release the group and its associated resources.
  74527. * @hidden
  74528. */
  74529. dispose(): void;
  74530. /**
  74531. * Clear the info related to rendering groups preventing retention points during dispose.
  74532. */
  74533. freeRenderingGroups(): void;
  74534. private _prepareRenderingGroup;
  74535. /**
  74536. * Add a sprite manager to the rendering manager in order to render it this frame.
  74537. * @param spriteManager Define the sprite manager to render
  74538. */
  74539. dispatchSprites(spriteManager: ISpriteManager): void;
  74540. /**
  74541. * Add a particle system to the rendering manager in order to render it this frame.
  74542. * @param particleSystem Define the particle system to render
  74543. */
  74544. dispatchParticles(particleSystem: IParticleSystem): void;
  74545. /**
  74546. * Add a submesh to the manager in order to render it this frame
  74547. * @param subMesh The submesh to dispatch
  74548. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74549. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74550. */
  74551. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74552. /**
  74553. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74554. * This allowed control for front to back rendering or reversly depending of the special needs.
  74555. *
  74556. * @param renderingGroupId The rendering group id corresponding to its index
  74557. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74558. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74559. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74560. */
  74561. 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;
  74562. /**
  74563. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74564. *
  74565. * @param renderingGroupId The rendering group id corresponding to its index
  74566. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74567. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74568. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74569. */
  74570. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74571. /**
  74572. * Gets the current auto clear configuration for one rendering group of the rendering
  74573. * manager.
  74574. * @param index the rendering group index to get the information for
  74575. * @returns The auto clear setup for the requested rendering group
  74576. */
  74577. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74578. }
  74579. }
  74580. declare module BABYLON {
  74581. /**
  74582. * This Helps creating a texture that will be created from a camera in your scene.
  74583. * It is basically a dynamic texture that could be used to create special effects for instance.
  74584. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74585. */
  74586. export class RenderTargetTexture extends Texture {
  74587. isCube: boolean;
  74588. /**
  74589. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74590. */
  74591. static readonly REFRESHRATE_RENDER_ONCE: number;
  74592. /**
  74593. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74594. */
  74595. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74596. /**
  74597. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74598. * the central point of your effect and can save a lot of performances.
  74599. */
  74600. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74601. /**
  74602. * Use this predicate to dynamically define the list of mesh you want to render.
  74603. * If set, the renderList property will be overwritten.
  74604. */
  74605. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74606. private _renderList;
  74607. /**
  74608. * Use this list to define the list of mesh you want to render.
  74609. */
  74610. renderList: Nullable<Array<AbstractMesh>>;
  74611. private _hookArray;
  74612. /**
  74613. * Define if particles should be rendered in your texture.
  74614. */
  74615. renderParticles: boolean;
  74616. /**
  74617. * Define if sprites should be rendered in your texture.
  74618. */
  74619. renderSprites: boolean;
  74620. /**
  74621. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74622. */
  74623. coordinatesMode: number;
  74624. /**
  74625. * Define the camera used to render the texture.
  74626. */
  74627. activeCamera: Nullable<Camera>;
  74628. /**
  74629. * Override the render function of the texture with your own one.
  74630. */
  74631. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74632. /**
  74633. * Define if camera post processes should be use while rendering the texture.
  74634. */
  74635. useCameraPostProcesses: boolean;
  74636. /**
  74637. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74638. */
  74639. ignoreCameraViewport: boolean;
  74640. private _postProcessManager;
  74641. private _postProcesses;
  74642. private _resizeObserver;
  74643. /**
  74644. * An event triggered when the texture is unbind.
  74645. */
  74646. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74647. /**
  74648. * An event triggered when the texture is unbind.
  74649. */
  74650. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74651. private _onAfterUnbindObserver;
  74652. /**
  74653. * Set a after unbind callback in the texture.
  74654. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74655. */
  74656. onAfterUnbind: () => void;
  74657. /**
  74658. * An event triggered before rendering the texture
  74659. */
  74660. onBeforeRenderObservable: Observable<number>;
  74661. private _onBeforeRenderObserver;
  74662. /**
  74663. * Set a before render callback in the texture.
  74664. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74665. */
  74666. onBeforeRender: (faceIndex: number) => void;
  74667. /**
  74668. * An event triggered after rendering the texture
  74669. */
  74670. onAfterRenderObservable: Observable<number>;
  74671. private _onAfterRenderObserver;
  74672. /**
  74673. * Set a after render callback in the texture.
  74674. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74675. */
  74676. onAfterRender: (faceIndex: number) => void;
  74677. /**
  74678. * An event triggered after the texture clear
  74679. */
  74680. onClearObservable: Observable<Engine>;
  74681. private _onClearObserver;
  74682. /**
  74683. * Set a clear callback in the texture.
  74684. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74685. */
  74686. onClear: (Engine: Engine) => void;
  74687. /**
  74688. * Define the clear color of the Render Target if it should be different from the scene.
  74689. */
  74690. clearColor: Color4;
  74691. protected _size: number | {
  74692. width: number;
  74693. height: number;
  74694. };
  74695. protected _initialSizeParameter: number | {
  74696. width: number;
  74697. height: number;
  74698. } | {
  74699. ratio: number;
  74700. };
  74701. protected _sizeRatio: Nullable<number>;
  74702. /** @hidden */
  74703. _generateMipMaps: boolean;
  74704. protected _renderingManager: RenderingManager;
  74705. /** @hidden */
  74706. _waitingRenderList: string[];
  74707. protected _doNotChangeAspectRatio: boolean;
  74708. protected _currentRefreshId: number;
  74709. protected _refreshRate: number;
  74710. protected _textureMatrix: Matrix;
  74711. protected _samples: number;
  74712. protected _renderTargetOptions: RenderTargetCreationOptions;
  74713. /**
  74714. * Gets render target creation options that were used.
  74715. */
  74716. readonly renderTargetOptions: RenderTargetCreationOptions;
  74717. protected _engine: Engine;
  74718. protected _onRatioRescale(): void;
  74719. /**
  74720. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74721. * It must define where the camera used to render the texture is set
  74722. */
  74723. boundingBoxPosition: Vector3;
  74724. private _boundingBoxSize;
  74725. /**
  74726. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74727. * When defined, the cubemap will switch to local mode
  74728. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74729. * @example https://www.babylonjs-playground.com/#RNASML
  74730. */
  74731. boundingBoxSize: Vector3;
  74732. /**
  74733. * In case the RTT has been created with a depth texture, get the associated
  74734. * depth texture.
  74735. * Otherwise, return null.
  74736. */
  74737. depthStencilTexture: Nullable<InternalTexture>;
  74738. /**
  74739. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74740. * or used a shadow, depth texture...
  74741. * @param name The friendly name of the texture
  74742. * @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)
  74743. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74744. * @param generateMipMaps True if mip maps need to be generated after render.
  74745. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74746. * @param type The type of the buffer in the RTT (int, half float, float...)
  74747. * @param isCube True if a cube texture needs to be created
  74748. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74749. * @param generateDepthBuffer True to generate a depth buffer
  74750. * @param generateStencilBuffer True to generate a stencil buffer
  74751. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74752. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74753. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74754. */
  74755. constructor(name: string, size: number | {
  74756. width: number;
  74757. height: number;
  74758. } | {
  74759. ratio: number;
  74760. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74761. /**
  74762. * Creates a depth stencil texture.
  74763. * This is only available in WebGL 2 or with the depth texture extension available.
  74764. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74765. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74766. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74767. */
  74768. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74769. private _processSizeParameter;
  74770. /**
  74771. * Define the number of samples to use in case of MSAA.
  74772. * It defaults to one meaning no MSAA has been enabled.
  74773. */
  74774. samples: number;
  74775. /**
  74776. * Resets the refresh counter of the texture and start bak from scratch.
  74777. * Could be useful to regenerate the texture if it is setup to render only once.
  74778. */
  74779. resetRefreshCounter(): void;
  74780. /**
  74781. * Define the refresh rate of the texture or the rendering frequency.
  74782. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74783. */
  74784. refreshRate: number;
  74785. /**
  74786. * Adds a post process to the render target rendering passes.
  74787. * @param postProcess define the post process to add
  74788. */
  74789. addPostProcess(postProcess: PostProcess): void;
  74790. /**
  74791. * Clear all the post processes attached to the render target
  74792. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74793. */
  74794. clearPostProcesses(dispose?: boolean): void;
  74795. /**
  74796. * Remove one of the post process from the list of attached post processes to the texture
  74797. * @param postProcess define the post process to remove from the list
  74798. */
  74799. removePostProcess(postProcess: PostProcess): void;
  74800. /** @hidden */
  74801. _shouldRender(): boolean;
  74802. /**
  74803. * Gets the actual render size of the texture.
  74804. * @returns the width of the render size
  74805. */
  74806. getRenderSize(): number;
  74807. /**
  74808. * Gets the actual render width of the texture.
  74809. * @returns the width of the render size
  74810. */
  74811. getRenderWidth(): number;
  74812. /**
  74813. * Gets the actual render height of the texture.
  74814. * @returns the height of the render size
  74815. */
  74816. getRenderHeight(): number;
  74817. /**
  74818. * Get if the texture can be rescaled or not.
  74819. */
  74820. readonly canRescale: boolean;
  74821. /**
  74822. * Resize the texture using a ratio.
  74823. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74824. */
  74825. scale(ratio: number): void;
  74826. /**
  74827. * Get the texture reflection matrix used to rotate/transform the reflection.
  74828. * @returns the reflection matrix
  74829. */
  74830. getReflectionTextureMatrix(): Matrix;
  74831. /**
  74832. * Resize the texture to a new desired size.
  74833. * Be carrefull as it will recreate all the data in the new texture.
  74834. * @param size Define the new size. It can be:
  74835. * - a number for squared texture,
  74836. * - an object containing { width: number, height: number }
  74837. * - or an object containing a ratio { ratio: number }
  74838. */
  74839. resize(size: number | {
  74840. width: number;
  74841. height: number;
  74842. } | {
  74843. ratio: number;
  74844. }): void;
  74845. /**
  74846. * Renders all the objects from the render list into the texture.
  74847. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74848. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74849. */
  74850. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74851. private _bestReflectionRenderTargetDimension;
  74852. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74853. private renderToTarget;
  74854. /**
  74855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74856. * This allowed control for front to back rendering or reversly depending of the special needs.
  74857. *
  74858. * @param renderingGroupId The rendering group id corresponding to its index
  74859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74862. */
  74863. 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;
  74864. /**
  74865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74866. *
  74867. * @param renderingGroupId The rendering group id corresponding to its index
  74868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74869. */
  74870. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74871. /**
  74872. * Clones the texture.
  74873. * @returns the cloned texture
  74874. */
  74875. clone(): RenderTargetTexture;
  74876. /**
  74877. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74878. * @returns The JSON representation of the texture
  74879. */
  74880. serialize(): any;
  74881. /**
  74882. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74883. */
  74884. disposeFramebufferObjects(): void;
  74885. /**
  74886. * Dispose the texture and release its associated resources.
  74887. */
  74888. dispose(): void;
  74889. /** @hidden */
  74890. _rebuild(): void;
  74891. /**
  74892. * Clear the info related to rendering groups preventing retention point in material dispose.
  74893. */
  74894. freeRenderingGroups(): void;
  74895. }
  74896. }
  74897. declare module BABYLON {
  74898. /**
  74899. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74900. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74901. * You can then easily use it as a reflectionTexture on a flat surface.
  74902. * In case the surface is not a plane, please consider relying on reflection probes.
  74903. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74904. */
  74905. export class MirrorTexture extends RenderTargetTexture {
  74906. private scene;
  74907. /**
  74908. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74909. * 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.
  74910. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74911. */
  74912. mirrorPlane: Plane;
  74913. /**
  74914. * Define the blur ratio used to blur the reflection if needed.
  74915. */
  74916. blurRatio: number;
  74917. /**
  74918. * Define the adaptive blur kernel used to blur the reflection if needed.
  74919. * This will autocompute the closest best match for the `blurKernel`
  74920. */
  74921. adaptiveBlurKernel: number;
  74922. /**
  74923. * Define the blur kernel used to blur the reflection if needed.
  74924. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74925. */
  74926. blurKernel: number;
  74927. /**
  74928. * Define the blur kernel on the X 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. blurKernelX: number;
  74932. /**
  74933. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74934. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74935. */
  74936. blurKernelY: number;
  74937. private _autoComputeBlurKernel;
  74938. protected _onRatioRescale(): void;
  74939. private _updateGammaSpace;
  74940. private _imageProcessingConfigChangeObserver;
  74941. private _transformMatrix;
  74942. private _mirrorMatrix;
  74943. private _savedViewMatrix;
  74944. private _blurX;
  74945. private _blurY;
  74946. private _adaptiveBlurKernel;
  74947. private _blurKernelX;
  74948. private _blurKernelY;
  74949. private _blurRatio;
  74950. /**
  74951. * Instantiates a Mirror Texture.
  74952. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74953. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74954. * You can then easily use it as a reflectionTexture on a flat surface.
  74955. * In case the surface is not a plane, please consider relying on reflection probes.
  74956. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74957. * @param name
  74958. * @param size
  74959. * @param scene
  74960. * @param generateMipMaps
  74961. * @param type
  74962. * @param samplingMode
  74963. * @param generateDepthBuffer
  74964. */
  74965. constructor(name: string, size: number | {
  74966. width: number;
  74967. height: number;
  74968. } | {
  74969. ratio: number;
  74970. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74971. private _preparePostProcesses;
  74972. /**
  74973. * Clone the mirror texture.
  74974. * @returns the cloned texture
  74975. */
  74976. clone(): MirrorTexture;
  74977. /**
  74978. * Serialize the texture to a JSON representation you could use in Parse later on
  74979. * @returns the serialized JSON representation
  74980. */
  74981. serialize(): any;
  74982. /**
  74983. * Dispose the texture and release its associated resources.
  74984. */
  74985. dispose(): void;
  74986. }
  74987. }
  74988. declare module BABYLON {
  74989. /**
  74990. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74991. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74992. */
  74993. export class Texture extends BaseTexture {
  74994. /** @hidden */
  74995. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74996. /** @hidden */
  74997. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74998. /** @hidden */
  74999. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75000. /** nearest is mag = nearest and min = nearest and mip = linear */
  75001. static readonly NEAREST_SAMPLINGMODE: number;
  75002. /** nearest is mag = nearest and min = nearest and mip = linear */
  75003. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75004. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75005. static readonly BILINEAR_SAMPLINGMODE: number;
  75006. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75007. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75008. /** Trilinear is mag = linear and min = linear and mip = linear */
  75009. static readonly TRILINEAR_SAMPLINGMODE: number;
  75010. /** Trilinear is mag = linear and min = linear and mip = linear */
  75011. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75012. /** mag = nearest and min = nearest and mip = nearest */
  75013. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75014. /** mag = nearest and min = linear and mip = nearest */
  75015. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75016. /** mag = nearest and min = linear and mip = linear */
  75017. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75018. /** mag = nearest and min = linear and mip = none */
  75019. static readonly NEAREST_LINEAR: number;
  75020. /** mag = nearest and min = nearest and mip = none */
  75021. static readonly NEAREST_NEAREST: number;
  75022. /** mag = linear and min = nearest and mip = nearest */
  75023. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75024. /** mag = linear and min = nearest and mip = linear */
  75025. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75026. /** mag = linear and min = linear and mip = none */
  75027. static readonly LINEAR_LINEAR: number;
  75028. /** mag = linear and min = nearest and mip = none */
  75029. static readonly LINEAR_NEAREST: number;
  75030. /** Explicit coordinates mode */
  75031. static readonly EXPLICIT_MODE: number;
  75032. /** Spherical coordinates mode */
  75033. static readonly SPHERICAL_MODE: number;
  75034. /** Planar coordinates mode */
  75035. static readonly PLANAR_MODE: number;
  75036. /** Cubic coordinates mode */
  75037. static readonly CUBIC_MODE: number;
  75038. /** Projection coordinates mode */
  75039. static readonly PROJECTION_MODE: number;
  75040. /** Inverse Cubic coordinates mode */
  75041. static readonly SKYBOX_MODE: number;
  75042. /** Inverse Cubic coordinates mode */
  75043. static readonly INVCUBIC_MODE: number;
  75044. /** Equirectangular coordinates mode */
  75045. static readonly EQUIRECTANGULAR_MODE: number;
  75046. /** Equirectangular Fixed coordinates mode */
  75047. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75048. /** Equirectangular Fixed Mirrored coordinates mode */
  75049. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75050. /** Texture is not repeating outside of 0..1 UVs */
  75051. static readonly CLAMP_ADDRESSMODE: number;
  75052. /** Texture is repeating outside of 0..1 UVs */
  75053. static readonly WRAP_ADDRESSMODE: number;
  75054. /** Texture is repeating and mirrored */
  75055. static readonly MIRROR_ADDRESSMODE: number;
  75056. /**
  75057. * 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
  75058. */
  75059. static UseSerializedUrlIfAny: boolean;
  75060. /**
  75061. * Define the url of the texture.
  75062. */
  75063. url: Nullable<string>;
  75064. /**
  75065. * Define an offset on the texture to offset the u coordinates of the UVs
  75066. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75067. */
  75068. uOffset: number;
  75069. /**
  75070. * Define an offset on the texture to offset the v coordinates of the UVs
  75071. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75072. */
  75073. vOffset: number;
  75074. /**
  75075. * Define an offset on the texture to scale the u coordinates of the UVs
  75076. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75077. */
  75078. uScale: number;
  75079. /**
  75080. * Define an offset on the texture to scale the v coordinates of the UVs
  75081. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75082. */
  75083. vScale: number;
  75084. /**
  75085. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75086. * @see http://doc.babylonjs.com/how_to/more_materials
  75087. */
  75088. uAng: number;
  75089. /**
  75090. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75091. * @see http://doc.babylonjs.com/how_to/more_materials
  75092. */
  75093. vAng: number;
  75094. /**
  75095. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75096. * @see http://doc.babylonjs.com/how_to/more_materials
  75097. */
  75098. wAng: number;
  75099. /**
  75100. * Defines the center of rotation (U)
  75101. */
  75102. uRotationCenter: number;
  75103. /**
  75104. * Defines the center of rotation (V)
  75105. */
  75106. vRotationCenter: number;
  75107. /**
  75108. * Defines the center of rotation (W)
  75109. */
  75110. wRotationCenter: number;
  75111. /**
  75112. * Are mip maps generated for this texture or not.
  75113. */
  75114. readonly noMipmap: boolean;
  75115. private _noMipmap;
  75116. /** @hidden */
  75117. _invertY: boolean;
  75118. private _rowGenerationMatrix;
  75119. private _cachedTextureMatrix;
  75120. private _projectionModeMatrix;
  75121. private _t0;
  75122. private _t1;
  75123. private _t2;
  75124. private _cachedUOffset;
  75125. private _cachedVOffset;
  75126. private _cachedUScale;
  75127. private _cachedVScale;
  75128. private _cachedUAng;
  75129. private _cachedVAng;
  75130. private _cachedWAng;
  75131. private _cachedProjectionMatrixId;
  75132. private _cachedCoordinatesMode;
  75133. /** @hidden */
  75134. protected _initialSamplingMode: number;
  75135. /** @hidden */
  75136. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75137. private _deleteBuffer;
  75138. protected _format: Nullable<number>;
  75139. private _delayedOnLoad;
  75140. private _delayedOnError;
  75141. /**
  75142. * Observable triggered once the texture has been loaded.
  75143. */
  75144. onLoadObservable: Observable<Texture>;
  75145. protected _isBlocking: boolean;
  75146. /**
  75147. * Is the texture preventing material to render while loading.
  75148. * If false, a default texture will be used instead of the loading one during the preparation step.
  75149. */
  75150. isBlocking: boolean;
  75151. /**
  75152. * Get the current sampling mode associated with the texture.
  75153. */
  75154. readonly samplingMode: number;
  75155. /**
  75156. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75157. */
  75158. readonly invertY: boolean;
  75159. /**
  75160. * Instantiates a new texture.
  75161. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75162. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75163. * @param url define the url of the picture to load as a texture
  75164. * @param scene define the scene the texture will belong to
  75165. * @param noMipmap define if the texture will require mip maps or not
  75166. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75167. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75168. * @param onLoad define a callback triggered when the texture has been loaded
  75169. * @param onError define a callback triggered when an error occurred during the loading session
  75170. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75171. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75172. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75173. */
  75174. 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);
  75175. /**
  75176. * Update the url (and optional buffer) of this texture if url was null during construction.
  75177. * @param url the url of the texture
  75178. * @param buffer the buffer of the texture (defaults to null)
  75179. * @param onLoad callback called when the texture is loaded (defaults to null)
  75180. */
  75181. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75182. /**
  75183. * Finish the loading sequence of a texture flagged as delayed load.
  75184. * @hidden
  75185. */
  75186. delayLoad(): void;
  75187. private _prepareRowForTextureGeneration;
  75188. /**
  75189. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75190. * @returns the transform matrix of the texture.
  75191. */
  75192. getTextureMatrix(): Matrix;
  75193. /**
  75194. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75195. * @returns The reflection texture transform
  75196. */
  75197. getReflectionTextureMatrix(): Matrix;
  75198. /**
  75199. * Clones the texture.
  75200. * @returns the cloned texture
  75201. */
  75202. clone(): Texture;
  75203. /**
  75204. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75205. * @returns The JSON representation of the texture
  75206. */
  75207. serialize(): any;
  75208. /**
  75209. * Get the current class name of the texture useful for serialization or dynamic coding.
  75210. * @returns "Texture"
  75211. */
  75212. getClassName(): string;
  75213. /**
  75214. * Dispose the texture and release its associated resources.
  75215. */
  75216. dispose(): void;
  75217. /**
  75218. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75219. * @param parsedTexture Define the JSON representation of the texture
  75220. * @param scene Define the scene the parsed texture should be instantiated in
  75221. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75222. * @returns The parsed texture if successful
  75223. */
  75224. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75225. /**
  75226. * Creates a texture from its base 64 representation.
  75227. * @param data Define the base64 payload without the data: prefix
  75228. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75229. * @param scene Define the scene the texture should belong to
  75230. * @param noMipmap Forces the texture to not create mip map information if true
  75231. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75232. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75233. * @param onLoad define a callback triggered when the texture has been loaded
  75234. * @param onError define a callback triggered when an error occurred during the loading session
  75235. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75236. * @returns the created texture
  75237. */
  75238. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75239. /**
  75240. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75241. * @param data Define the base64 payload without the data: prefix
  75242. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75243. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75244. * @param scene Define the scene the texture should belong to
  75245. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75246. * @param noMipmap Forces the texture to not create mip map information if true
  75247. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75248. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75249. * @param onLoad define a callback triggered when the texture has been loaded
  75250. * @param onError define a callback triggered when an error occurred during the loading session
  75251. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75252. * @returns the created texture
  75253. */
  75254. 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;
  75255. }
  75256. }
  75257. declare module BABYLON {
  75258. /**
  75259. * Raw texture can help creating a texture directly from an array of data.
  75260. * This can be super useful if you either get the data from an uncompressed source or
  75261. * if you wish to create your texture pixel by pixel.
  75262. */
  75263. export class RawTexture extends Texture {
  75264. /**
  75265. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75266. */
  75267. format: number;
  75268. private _engine;
  75269. /**
  75270. * Instantiates a new RawTexture.
  75271. * Raw texture can help creating a texture directly from an array of data.
  75272. * This can be super useful if you either get the data from an uncompressed source or
  75273. * if you wish to create your texture pixel by pixel.
  75274. * @param data define the array of data to use to create the texture
  75275. * @param width define the width of the texture
  75276. * @param height define the height of the texture
  75277. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75278. * @param scene define the scene the texture belongs to
  75279. * @param generateMipMaps define whether mip maps should be generated or not
  75280. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75281. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75282. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75283. */
  75284. constructor(data: ArrayBufferView, width: number, height: number,
  75285. /**
  75286. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75287. */
  75288. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75289. /**
  75290. * Updates the texture underlying data.
  75291. * @param data Define the new data of the texture
  75292. */
  75293. update(data: ArrayBufferView): void;
  75294. /**
  75295. * Creates a luminance texture from some data.
  75296. * @param data Define the texture data
  75297. * @param width Define the width of the texture
  75298. * @param height Define the height of the texture
  75299. * @param scene Define the scene the texture belongs to
  75300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75303. * @returns the luminance texture
  75304. */
  75305. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75306. /**
  75307. * Creates a luminance alpha texture from some data.
  75308. * @param data Define the texture data
  75309. * @param width Define the width of the texture
  75310. * @param height Define the height of the texture
  75311. * @param scene Define the scene the texture belongs to
  75312. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75315. * @returns the luminance alpha texture
  75316. */
  75317. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75318. /**
  75319. * Creates an alpha texture from some data.
  75320. * @param data Define the texture data
  75321. * @param width Define the width of the texture
  75322. * @param height Define the height of the texture
  75323. * @param scene Define the scene the texture belongs to
  75324. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75325. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75326. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75327. * @returns the alpha texture
  75328. */
  75329. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75330. /**
  75331. * Creates a RGB texture from some data.
  75332. * @param data Define the texture data
  75333. * @param width Define the width of the texture
  75334. * @param height Define the height of the texture
  75335. * @param scene Define the scene the texture belongs to
  75336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75339. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75340. * @returns the RGB alpha texture
  75341. */
  75342. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75343. /**
  75344. * Creates a RGBA texture from some data.
  75345. * @param data Define the texture data
  75346. * @param width Define the width of the texture
  75347. * @param height Define the height of the texture
  75348. * @param scene Define the scene the texture belongs to
  75349. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75350. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75351. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75352. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75353. * @returns the RGBA texture
  75354. */
  75355. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75356. /**
  75357. * Creates a R texture from some data.
  75358. * @param data Define the texture data
  75359. * @param width Define the width of the texture
  75360. * @param height Define the height of the texture
  75361. * @param scene Define the scene the texture belongs to
  75362. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75363. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75364. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75365. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75366. * @returns the R texture
  75367. */
  75368. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75369. }
  75370. }
  75371. declare module BABYLON {
  75372. /**
  75373. * Defines a runtime animation
  75374. */
  75375. export class RuntimeAnimation {
  75376. private _events;
  75377. /**
  75378. * The current frame of the runtime animation
  75379. */
  75380. private _currentFrame;
  75381. /**
  75382. * The animation used by the runtime animation
  75383. */
  75384. private _animation;
  75385. /**
  75386. * The target of the runtime animation
  75387. */
  75388. private _target;
  75389. /**
  75390. * The initiating animatable
  75391. */
  75392. private _host;
  75393. /**
  75394. * The original value of the runtime animation
  75395. */
  75396. private _originalValue;
  75397. /**
  75398. * The original blend value of the runtime animation
  75399. */
  75400. private _originalBlendValue;
  75401. /**
  75402. * The offsets cache of the runtime animation
  75403. */
  75404. private _offsetsCache;
  75405. /**
  75406. * The high limits cache of the runtime animation
  75407. */
  75408. private _highLimitsCache;
  75409. /**
  75410. * Specifies if the runtime animation has been stopped
  75411. */
  75412. private _stopped;
  75413. /**
  75414. * The blending factor of the runtime animation
  75415. */
  75416. private _blendingFactor;
  75417. /**
  75418. * The BabylonJS scene
  75419. */
  75420. private _scene;
  75421. /**
  75422. * The current value of the runtime animation
  75423. */
  75424. private _currentValue;
  75425. /** @hidden */
  75426. _workValue: any;
  75427. /**
  75428. * The active target of the runtime animation
  75429. */
  75430. private _activeTarget;
  75431. /**
  75432. * The target path of the runtime animation
  75433. */
  75434. private _targetPath;
  75435. /**
  75436. * The weight of the runtime animation
  75437. */
  75438. private _weight;
  75439. /**
  75440. * The ratio offset of the runtime animation
  75441. */
  75442. private _ratioOffset;
  75443. /**
  75444. * The previous delay of the runtime animation
  75445. */
  75446. private _previousDelay;
  75447. /**
  75448. * The previous ratio of the runtime animation
  75449. */
  75450. private _previousRatio;
  75451. /**
  75452. * Gets the current frame of the runtime animation
  75453. */
  75454. readonly currentFrame: number;
  75455. /**
  75456. * Gets the weight of the runtime animation
  75457. */
  75458. readonly weight: number;
  75459. /**
  75460. * Gets the current value of the runtime animation
  75461. */
  75462. readonly currentValue: any;
  75463. /**
  75464. * Gets the target path of the runtime animation
  75465. */
  75466. readonly targetPath: string;
  75467. /**
  75468. * Gets the actual target of the runtime animation
  75469. */
  75470. readonly target: any;
  75471. /**
  75472. * Create a new RuntimeAnimation object
  75473. * @param target defines the target of the animation
  75474. * @param animation defines the source animation object
  75475. * @param scene defines the hosting scene
  75476. * @param host defines the initiating Animatable
  75477. */
  75478. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75479. /**
  75480. * Gets the animation from the runtime animation
  75481. */
  75482. readonly animation: Animation;
  75483. /**
  75484. * Resets the runtime animation to the beginning
  75485. * @param restoreOriginal defines whether to restore the target property to the original value
  75486. */
  75487. reset(restoreOriginal?: boolean): void;
  75488. /**
  75489. * Specifies if the runtime animation is stopped
  75490. * @returns Boolean specifying if the runtime animation is stopped
  75491. */
  75492. isStopped(): boolean;
  75493. /**
  75494. * Disposes of the runtime animation
  75495. */
  75496. dispose(): void;
  75497. /**
  75498. * Interpolates the animation from the current frame
  75499. * @param currentFrame The frame to interpolate the animation to
  75500. * @param repeatCount The number of times that the animation should loop
  75501. * @param loopMode The type of looping mode to use
  75502. * @param offsetValue Animation offset value
  75503. * @param highLimitValue The high limit value
  75504. * @returns The interpolated value
  75505. */
  75506. private _interpolate;
  75507. /**
  75508. * Apply the interpolated value to the target
  75509. * @param currentValue defines the value computed by the animation
  75510. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75511. */
  75512. setValue(currentValue: any, weight?: number): void;
  75513. private _setValue;
  75514. /**
  75515. * Gets the loop pmode of the runtime animation
  75516. * @returns Loop Mode
  75517. */
  75518. private _getCorrectLoopMode;
  75519. /**
  75520. * Move the current animation to a given frame
  75521. * @param frame defines the frame to move to
  75522. */
  75523. goToFrame(frame: number): void;
  75524. /**
  75525. * @hidden Internal use only
  75526. */
  75527. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75528. /**
  75529. * Execute the current animation
  75530. * @param delay defines the delay to add to the current frame
  75531. * @param from defines the lower bound of the animation range
  75532. * @param to defines the upper bound of the animation range
  75533. * @param loop defines if the current animation must loop
  75534. * @param speedRatio defines the current speed ratio
  75535. * @param weight defines the weight of the animation (default is -1 so no weight)
  75536. * @param onLoop optional callback called when animation loops
  75537. * @returns a boolean indicating if the animation is running
  75538. */
  75539. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75540. }
  75541. }
  75542. declare module BABYLON {
  75543. /**
  75544. * Class used to store an actual running animation
  75545. */
  75546. export class Animatable {
  75547. /** defines the target object */
  75548. target: any;
  75549. /** defines the starting frame number (default is 0) */
  75550. fromFrame: number;
  75551. /** defines the ending frame number (default is 100) */
  75552. toFrame: number;
  75553. /** defines if the animation must loop (default is false) */
  75554. loopAnimation: boolean;
  75555. /** defines a callback to call when animation ends if it is not looping */
  75556. onAnimationEnd?: (() => void) | null | undefined;
  75557. /** defines a callback to call when animation loops */
  75558. onAnimationLoop?: (() => void) | null | undefined;
  75559. private _localDelayOffset;
  75560. private _pausedDelay;
  75561. private _runtimeAnimations;
  75562. private _paused;
  75563. private _scene;
  75564. private _speedRatio;
  75565. private _weight;
  75566. private _syncRoot;
  75567. /**
  75568. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75569. * This will only apply for non looping animation (default is true)
  75570. */
  75571. disposeOnEnd: boolean;
  75572. /**
  75573. * Gets a boolean indicating if the animation has started
  75574. */
  75575. animationStarted: boolean;
  75576. /**
  75577. * Observer raised when the animation ends
  75578. */
  75579. onAnimationEndObservable: Observable<Animatable>;
  75580. /**
  75581. * Observer raised when the animation loops
  75582. */
  75583. onAnimationLoopObservable: Observable<Animatable>;
  75584. /**
  75585. * Gets the root Animatable used to synchronize and normalize animations
  75586. */
  75587. readonly syncRoot: Animatable;
  75588. /**
  75589. * Gets the current frame of the first RuntimeAnimation
  75590. * Used to synchronize Animatables
  75591. */
  75592. readonly masterFrame: number;
  75593. /**
  75594. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75595. */
  75596. weight: number;
  75597. /**
  75598. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75599. */
  75600. speedRatio: number;
  75601. /**
  75602. * Creates a new Animatable
  75603. * @param scene defines the hosting scene
  75604. * @param target defines the target object
  75605. * @param fromFrame defines the starting frame number (default is 0)
  75606. * @param toFrame defines the ending frame number (default is 100)
  75607. * @param loopAnimation defines if the animation must loop (default is false)
  75608. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75609. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75610. * @param animations defines a group of animation to add to the new Animatable
  75611. * @param onAnimationLoop defines a callback to call when animation loops
  75612. */
  75613. constructor(scene: Scene,
  75614. /** defines the target object */
  75615. target: any,
  75616. /** defines the starting frame number (default is 0) */
  75617. fromFrame?: number,
  75618. /** defines the ending frame number (default is 100) */
  75619. toFrame?: number,
  75620. /** defines if the animation must loop (default is false) */
  75621. loopAnimation?: boolean, speedRatio?: number,
  75622. /** defines a callback to call when animation ends if it is not looping */
  75623. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75624. /** defines a callback to call when animation loops */
  75625. onAnimationLoop?: (() => void) | null | undefined);
  75626. /**
  75627. * Synchronize and normalize current Animatable with a source Animatable
  75628. * This is useful when using animation weights and when animations are not of the same length
  75629. * @param root defines the root Animatable to synchronize with
  75630. * @returns the current Animatable
  75631. */
  75632. syncWith(root: Animatable): Animatable;
  75633. /**
  75634. * Gets the list of runtime animations
  75635. * @returns an array of RuntimeAnimation
  75636. */
  75637. getAnimations(): RuntimeAnimation[];
  75638. /**
  75639. * Adds more animations to the current animatable
  75640. * @param target defines the target of the animations
  75641. * @param animations defines the new animations to add
  75642. */
  75643. appendAnimations(target: any, animations: Animation[]): void;
  75644. /**
  75645. * Gets the source animation for a specific property
  75646. * @param property defines the propertyu to look for
  75647. * @returns null or the source animation for the given property
  75648. */
  75649. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75650. /**
  75651. * Gets the runtime animation for a specific property
  75652. * @param property defines the propertyu to look for
  75653. * @returns null or the runtime animation for the given property
  75654. */
  75655. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75656. /**
  75657. * Resets the animatable to its original state
  75658. */
  75659. reset(): void;
  75660. /**
  75661. * Allows the animatable to blend with current running animations
  75662. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75663. * @param blendingSpeed defines the blending speed to use
  75664. */
  75665. enableBlending(blendingSpeed: number): void;
  75666. /**
  75667. * Disable animation blending
  75668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75669. */
  75670. disableBlending(): void;
  75671. /**
  75672. * Jump directly to a given frame
  75673. * @param frame defines the frame to jump to
  75674. */
  75675. goToFrame(frame: number): void;
  75676. /**
  75677. * Pause the animation
  75678. */
  75679. pause(): void;
  75680. /**
  75681. * Restart the animation
  75682. */
  75683. restart(): void;
  75684. private _raiseOnAnimationEnd;
  75685. /**
  75686. * Stop and delete the current animation
  75687. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75688. * @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)
  75689. */
  75690. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75691. /**
  75692. * Wait asynchronously for the animation to end
  75693. * @returns a promise which will be fullfilled when the animation ends
  75694. */
  75695. waitAsync(): Promise<Animatable>;
  75696. /** @hidden */
  75697. _animate(delay: number): boolean;
  75698. }
  75699. interface Scene {
  75700. /** @hidden */
  75701. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75702. /** @hidden */
  75703. _processLateAnimationBindingsForMatrices(holder: {
  75704. totalWeight: number;
  75705. animations: RuntimeAnimation[];
  75706. originalValue: Matrix;
  75707. }): any;
  75708. /** @hidden */
  75709. _processLateAnimationBindingsForQuaternions(holder: {
  75710. totalWeight: number;
  75711. animations: RuntimeAnimation[];
  75712. originalValue: Quaternion;
  75713. }, refQuaternion: Quaternion): Quaternion;
  75714. /** @hidden */
  75715. _processLateAnimationBindings(): void;
  75716. /**
  75717. * Will start the animation sequence of a given target
  75718. * @param target defines the target
  75719. * @param from defines from which frame should animation start
  75720. * @param to defines until which frame should animation run.
  75721. * @param weight defines the weight to apply to the animation (1.0 by default)
  75722. * @param loop defines if the animation loops
  75723. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75724. * @param onAnimationEnd defines the function to be executed when the animation ends
  75725. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75726. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75727. * @param onAnimationLoop defines the callback to call when an animation loops
  75728. * @returns the animatable object created for this animation
  75729. */
  75730. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75731. /**
  75732. * Will start the animation sequence of a given target
  75733. * @param target defines the target
  75734. * @param from defines from which frame should animation start
  75735. * @param to defines until which frame should animation run.
  75736. * @param loop defines if the animation loops
  75737. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75738. * @param onAnimationEnd defines the function to be executed when the animation ends
  75739. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75740. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75741. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75742. * @param onAnimationLoop defines the callback to call when an animation loops
  75743. * @returns the animatable object created for this animation
  75744. */
  75745. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75746. /**
  75747. * Will start the animation sequence of a given target and its hierarchy
  75748. * @param target defines the target
  75749. * @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.
  75750. * @param from defines from which frame should animation start
  75751. * @param to defines until which frame should animation run.
  75752. * @param loop defines if the animation loops
  75753. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75754. * @param onAnimationEnd defines the function to be executed when the animation ends
  75755. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75756. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75757. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75758. * @param onAnimationLoop defines the callback to call when an animation loops
  75759. * @returns the list of created animatables
  75760. */
  75761. 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[];
  75762. /**
  75763. * Begin a new animation on a given node
  75764. * @param target defines the target where the animation will take place
  75765. * @param animations defines the list of animations to start
  75766. * @param from defines the initial value
  75767. * @param to defines the final value
  75768. * @param loop defines if you want animation to loop (off by default)
  75769. * @param speedRatio defines the speed ratio to apply to all animations
  75770. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75771. * @param onAnimationLoop defines the callback to call when an animation loops
  75772. * @returns the list of created animatables
  75773. */
  75774. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75775. /**
  75776. * Begin a new animation on a given node and its hierarchy
  75777. * @param target defines the root node where the animation will take place
  75778. * @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.
  75779. * @param animations defines the list of animations to start
  75780. * @param from defines the initial value
  75781. * @param to defines the final value
  75782. * @param loop defines if you want animation to loop (off by default)
  75783. * @param speedRatio defines the speed ratio to apply to all animations
  75784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75785. * @param onAnimationLoop defines the callback to call when an animation loops
  75786. * @returns the list of animatables created for all nodes
  75787. */
  75788. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75789. /**
  75790. * Gets the animatable associated with a specific target
  75791. * @param target defines the target of the animatable
  75792. * @returns the required animatable if found
  75793. */
  75794. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75795. /**
  75796. * Gets all animatables associated with a given target
  75797. * @param target defines the target to look animatables for
  75798. * @returns an array of Animatables
  75799. */
  75800. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75801. /**
  75802. * Will stop the animation of the given target
  75803. * @param target - the target
  75804. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75805. * @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)
  75806. */
  75807. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75808. /**
  75809. * Stops and removes all animations that have been applied to the scene
  75810. */
  75811. stopAllAnimations(): void;
  75812. }
  75813. interface Bone {
  75814. /**
  75815. * Copy an animation range from another bone
  75816. * @param source defines the source bone
  75817. * @param rangeName defines the range name to copy
  75818. * @param frameOffset defines the frame offset
  75819. * @param rescaleAsRequired defines if rescaling must be applied if required
  75820. * @param skelDimensionsRatio defines the scaling ratio
  75821. * @returns true if operation was successful
  75822. */
  75823. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75824. }
  75825. }
  75826. declare module BABYLON {
  75827. /**
  75828. * Class used to handle skinning animations
  75829. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75830. */
  75831. export class Skeleton implements IAnimatable {
  75832. /** defines the skeleton name */
  75833. name: string;
  75834. /** defines the skeleton Id */
  75835. id: string;
  75836. /**
  75837. * Defines the list of child bones
  75838. */
  75839. bones: Bone[];
  75840. /**
  75841. * Defines an estimate of the dimension of the skeleton at rest
  75842. */
  75843. dimensionsAtRest: Vector3;
  75844. /**
  75845. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75846. */
  75847. needInitialSkinMatrix: boolean;
  75848. /**
  75849. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75850. */
  75851. overrideMesh: Nullable<AbstractMesh>;
  75852. /**
  75853. * Gets the list of animations attached to this skeleton
  75854. */
  75855. animations: Array<Animation>;
  75856. private _scene;
  75857. private _isDirty;
  75858. private _transformMatrices;
  75859. private _transformMatrixTexture;
  75860. private _meshesWithPoseMatrix;
  75861. private _animatables;
  75862. private _identity;
  75863. private _synchronizedWithMesh;
  75864. private _ranges;
  75865. private _lastAbsoluteTransformsUpdateId;
  75866. private _canUseTextureForBones;
  75867. /** @hidden */
  75868. _numBonesWithLinkedTransformNode: number;
  75869. /**
  75870. * Specifies if the skeleton should be serialized
  75871. */
  75872. doNotSerialize: boolean;
  75873. /**
  75874. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75875. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75876. */
  75877. useTextureToStoreBoneMatrices: boolean;
  75878. private _animationPropertiesOverride;
  75879. /**
  75880. * Gets or sets the animation properties override
  75881. */
  75882. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75883. /**
  75884. * An observable triggered before computing the skeleton's matrices
  75885. */
  75886. onBeforeComputeObservable: Observable<Skeleton>;
  75887. /**
  75888. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75889. */
  75890. readonly isUsingTextureForMatrices: boolean;
  75891. /**
  75892. * Creates a new skeleton
  75893. * @param name defines the skeleton name
  75894. * @param id defines the skeleton Id
  75895. * @param scene defines the hosting scene
  75896. */
  75897. constructor(
  75898. /** defines the skeleton name */
  75899. name: string,
  75900. /** defines the skeleton Id */
  75901. id: string, scene: Scene);
  75902. /**
  75903. * Gets the current object class name.
  75904. * @return the class name
  75905. */
  75906. getClassName(): string;
  75907. /**
  75908. * Returns an array containing the root bones
  75909. * @returns an array containing the root bones
  75910. */
  75911. getChildren(): Array<Bone>;
  75912. /**
  75913. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75914. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75915. * @returns a Float32Array containing matrices data
  75916. */
  75917. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75918. /**
  75919. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75920. * @returns a raw texture containing the data
  75921. */
  75922. getTransformMatrixTexture(): Nullable<RawTexture>;
  75923. /**
  75924. * Gets the current hosting scene
  75925. * @returns a scene object
  75926. */
  75927. getScene(): Scene;
  75928. /**
  75929. * Gets a string representing the current skeleton data
  75930. * @param fullDetails defines a boolean indicating if we want a verbose version
  75931. * @returns a string representing the current skeleton data
  75932. */
  75933. toString(fullDetails?: boolean): string;
  75934. /**
  75935. * Get bone's index searching by name
  75936. * @param name defines bone's name to search for
  75937. * @return the indice of the bone. Returns -1 if not found
  75938. */
  75939. getBoneIndexByName(name: string): number;
  75940. /**
  75941. * Creater a new animation range
  75942. * @param name defines the name of the range
  75943. * @param from defines the start key
  75944. * @param to defines the end key
  75945. */
  75946. createAnimationRange(name: string, from: number, to: number): void;
  75947. /**
  75948. * Delete a specific animation range
  75949. * @param name defines the name of the range
  75950. * @param deleteFrames defines if frames must be removed as well
  75951. */
  75952. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75953. /**
  75954. * Gets a specific animation range
  75955. * @param name defines the name of the range to look for
  75956. * @returns the requested animation range or null if not found
  75957. */
  75958. getAnimationRange(name: string): Nullable<AnimationRange>;
  75959. /**
  75960. * Gets the list of all animation ranges defined on this skeleton
  75961. * @returns an array
  75962. */
  75963. getAnimationRanges(): Nullable<AnimationRange>[];
  75964. /**
  75965. * Copy animation range from a source skeleton.
  75966. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75967. * @param source defines the source skeleton
  75968. * @param name defines the name of the range to copy
  75969. * @param rescaleAsRequired defines if rescaling must be applied if required
  75970. * @returns true if operation was successful
  75971. */
  75972. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75973. /**
  75974. * Forces the skeleton to go to rest pose
  75975. */
  75976. returnToRest(): void;
  75977. private _getHighestAnimationFrame;
  75978. /**
  75979. * Begin a specific animation range
  75980. * @param name defines the name of the range to start
  75981. * @param loop defines if looping must be turned on (false by default)
  75982. * @param speedRatio defines the speed ratio to apply (1 by default)
  75983. * @param onAnimationEnd defines a callback which will be called when animation will end
  75984. * @returns a new animatable
  75985. */
  75986. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75987. /** @hidden */
  75988. _markAsDirty(): void;
  75989. /** @hidden */
  75990. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75991. /** @hidden */
  75992. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75993. private _computeTransformMatrices;
  75994. /**
  75995. * Build all resources required to render a skeleton
  75996. */
  75997. prepare(): void;
  75998. /**
  75999. * Gets the list of animatables currently running for this skeleton
  76000. * @returns an array of animatables
  76001. */
  76002. getAnimatables(): IAnimatable[];
  76003. /**
  76004. * Clone the current skeleton
  76005. * @param name defines the name of the new skeleton
  76006. * @param id defines the id of the enw skeleton
  76007. * @returns the new skeleton
  76008. */
  76009. clone(name: string, id: string): Skeleton;
  76010. /**
  76011. * Enable animation blending for this skeleton
  76012. * @param blendingSpeed defines the blending speed to apply
  76013. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76014. */
  76015. enableBlending(blendingSpeed?: number): void;
  76016. /**
  76017. * Releases all resources associated with the current skeleton
  76018. */
  76019. dispose(): void;
  76020. /**
  76021. * Serialize the skeleton in a JSON object
  76022. * @returns a JSON object
  76023. */
  76024. serialize(): any;
  76025. /**
  76026. * Creates a new skeleton from serialized data
  76027. * @param parsedSkeleton defines the serialized data
  76028. * @param scene defines the hosting scene
  76029. * @returns a new skeleton
  76030. */
  76031. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76032. /**
  76033. * Compute all node absolute transforms
  76034. * @param forceUpdate defines if computation must be done even if cache is up to date
  76035. */
  76036. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76037. /**
  76038. * Gets the root pose matrix
  76039. * @returns a matrix
  76040. */
  76041. getPoseMatrix(): Nullable<Matrix>;
  76042. /**
  76043. * Sorts bones per internal index
  76044. */
  76045. sortBones(): void;
  76046. private _sortBones;
  76047. }
  76048. }
  76049. declare module BABYLON {
  76050. /**
  76051. * Defines a target to use with MorphTargetManager
  76052. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76053. */
  76054. export class MorphTarget implements IAnimatable {
  76055. /** defines the name of the target */
  76056. name: string;
  76057. /**
  76058. * Gets or sets the list of animations
  76059. */
  76060. animations: Animation[];
  76061. private _scene;
  76062. private _positions;
  76063. private _normals;
  76064. private _tangents;
  76065. private _influence;
  76066. /**
  76067. * Observable raised when the influence changes
  76068. */
  76069. onInfluenceChanged: Observable<boolean>;
  76070. /** @hidden */
  76071. _onDataLayoutChanged: Observable<void>;
  76072. /**
  76073. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76074. */
  76075. influence: number;
  76076. /**
  76077. * Gets or sets the id of the morph Target
  76078. */
  76079. id: string;
  76080. private _animationPropertiesOverride;
  76081. /**
  76082. * Gets or sets the animation properties override
  76083. */
  76084. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76085. /**
  76086. * Creates a new MorphTarget
  76087. * @param name defines the name of the target
  76088. * @param influence defines the influence to use
  76089. * @param scene defines the scene the morphtarget belongs to
  76090. */
  76091. constructor(
  76092. /** defines the name of the target */
  76093. name: string, influence?: number, scene?: Nullable<Scene>);
  76094. /**
  76095. * Gets a boolean defining if the target contains position data
  76096. */
  76097. readonly hasPositions: boolean;
  76098. /**
  76099. * Gets a boolean defining if the target contains normal data
  76100. */
  76101. readonly hasNormals: boolean;
  76102. /**
  76103. * Gets a boolean defining if the target contains tangent data
  76104. */
  76105. readonly hasTangents: boolean;
  76106. /**
  76107. * Affects position data to this target
  76108. * @param data defines the position data to use
  76109. */
  76110. setPositions(data: Nullable<FloatArray>): void;
  76111. /**
  76112. * Gets the position data stored in this target
  76113. * @returns a FloatArray containing the position data (or null if not present)
  76114. */
  76115. getPositions(): Nullable<FloatArray>;
  76116. /**
  76117. * Affects normal data to this target
  76118. * @param data defines the normal data to use
  76119. */
  76120. setNormals(data: Nullable<FloatArray>): void;
  76121. /**
  76122. * Gets the normal data stored in this target
  76123. * @returns a FloatArray containing the normal data (or null if not present)
  76124. */
  76125. getNormals(): Nullable<FloatArray>;
  76126. /**
  76127. * Affects tangent data to this target
  76128. * @param data defines the tangent data to use
  76129. */
  76130. setTangents(data: Nullable<FloatArray>): void;
  76131. /**
  76132. * Gets the tangent data stored in this target
  76133. * @returns a FloatArray containing the tangent data (or null if not present)
  76134. */
  76135. getTangents(): Nullable<FloatArray>;
  76136. /**
  76137. * Serializes the current target into a Serialization object
  76138. * @returns the serialized object
  76139. */
  76140. serialize(): any;
  76141. /**
  76142. * Returns the string "MorphTarget"
  76143. * @returns "MorphTarget"
  76144. */
  76145. getClassName(): string;
  76146. /**
  76147. * Creates a new target from serialized data
  76148. * @param serializationObject defines the serialized data to use
  76149. * @returns a new MorphTarget
  76150. */
  76151. static Parse(serializationObject: any): MorphTarget;
  76152. /**
  76153. * Creates a MorphTarget from mesh data
  76154. * @param mesh defines the source mesh
  76155. * @param name defines the name to use for the new target
  76156. * @param influence defines the influence to attach to the target
  76157. * @returns a new MorphTarget
  76158. */
  76159. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76160. }
  76161. }
  76162. declare module BABYLON {
  76163. /**
  76164. * This class is used to deform meshes using morphing between different targets
  76165. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76166. */
  76167. export class MorphTargetManager {
  76168. private _targets;
  76169. private _targetInfluenceChangedObservers;
  76170. private _targetDataLayoutChangedObservers;
  76171. private _activeTargets;
  76172. private _scene;
  76173. private _influences;
  76174. private _supportsNormals;
  76175. private _supportsTangents;
  76176. private _vertexCount;
  76177. private _uniqueId;
  76178. private _tempInfluences;
  76179. /**
  76180. * Creates a new MorphTargetManager
  76181. * @param scene defines the current scene
  76182. */
  76183. constructor(scene?: Nullable<Scene>);
  76184. /**
  76185. * Gets the unique ID of this manager
  76186. */
  76187. readonly uniqueId: number;
  76188. /**
  76189. * Gets the number of vertices handled by this manager
  76190. */
  76191. readonly vertexCount: number;
  76192. /**
  76193. * Gets a boolean indicating if this manager supports morphing of normals
  76194. */
  76195. readonly supportsNormals: boolean;
  76196. /**
  76197. * Gets a boolean indicating if this manager supports morphing of tangents
  76198. */
  76199. readonly supportsTangents: boolean;
  76200. /**
  76201. * Gets the number of targets stored in this manager
  76202. */
  76203. readonly numTargets: number;
  76204. /**
  76205. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76206. */
  76207. readonly numInfluencers: number;
  76208. /**
  76209. * Gets the list of influences (one per target)
  76210. */
  76211. readonly influences: Float32Array;
  76212. /**
  76213. * Gets the active target at specified index. An active target is a target with an influence > 0
  76214. * @param index defines the index to check
  76215. * @returns the requested target
  76216. */
  76217. getActiveTarget(index: number): MorphTarget;
  76218. /**
  76219. * Gets the target at specified index
  76220. * @param index defines the index to check
  76221. * @returns the requested target
  76222. */
  76223. getTarget(index: number): MorphTarget;
  76224. /**
  76225. * Add a new target to this manager
  76226. * @param target defines the target to add
  76227. */
  76228. addTarget(target: MorphTarget): void;
  76229. /**
  76230. * Removes a target from the manager
  76231. * @param target defines the target to remove
  76232. */
  76233. removeTarget(target: MorphTarget): void;
  76234. /**
  76235. * Serializes the current manager into a Serialization object
  76236. * @returns the serialized object
  76237. */
  76238. serialize(): any;
  76239. private _syncActiveTargets;
  76240. /**
  76241. * Syncrhonize the targets with all the meshes using this morph target manager
  76242. */
  76243. synchronize(): void;
  76244. /**
  76245. * Creates a new MorphTargetManager from serialized data
  76246. * @param serializationObject defines the serialized data
  76247. * @param scene defines the hosting scene
  76248. * @returns the new MorphTargetManager
  76249. */
  76250. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76251. }
  76252. }
  76253. declare module BABYLON {
  76254. /**
  76255. * Mesh representing the gorund
  76256. */
  76257. export class GroundMesh extends Mesh {
  76258. /** If octree should be generated */
  76259. generateOctree: boolean;
  76260. private _heightQuads;
  76261. /** @hidden */
  76262. _subdivisionsX: number;
  76263. /** @hidden */
  76264. _subdivisionsY: number;
  76265. /** @hidden */
  76266. _width: number;
  76267. /** @hidden */
  76268. _height: number;
  76269. /** @hidden */
  76270. _minX: number;
  76271. /** @hidden */
  76272. _maxX: number;
  76273. /** @hidden */
  76274. _minZ: number;
  76275. /** @hidden */
  76276. _maxZ: number;
  76277. constructor(name: string, scene: Scene);
  76278. /**
  76279. * "GroundMesh"
  76280. * @returns "GroundMesh"
  76281. */
  76282. getClassName(): string;
  76283. /**
  76284. * The minimum of x and y subdivisions
  76285. */
  76286. readonly subdivisions: number;
  76287. /**
  76288. * X subdivisions
  76289. */
  76290. readonly subdivisionsX: number;
  76291. /**
  76292. * Y subdivisions
  76293. */
  76294. readonly subdivisionsY: number;
  76295. /**
  76296. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76297. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76298. * @param chunksCount the number of subdivisions for x and y
  76299. * @param octreeBlocksSize (Default: 32)
  76300. */
  76301. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76302. /**
  76303. * Returns a height (y) value in the Worl system :
  76304. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76305. * @param x x coordinate
  76306. * @param z z coordinate
  76307. * @returns the ground y position if (x, z) are outside the ground surface.
  76308. */
  76309. getHeightAtCoordinates(x: number, z: number): number;
  76310. /**
  76311. * Returns a normalized vector (Vector3) orthogonal to the ground
  76312. * at the ground coordinates (x, z) expressed in the World system.
  76313. * @param x x coordinate
  76314. * @param z z coordinate
  76315. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76316. */
  76317. getNormalAtCoordinates(x: number, z: number): Vector3;
  76318. /**
  76319. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76320. * at the ground coordinates (x, z) expressed in the World system.
  76321. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76322. * @param x x coordinate
  76323. * @param z z coordinate
  76324. * @param ref vector to store the result
  76325. * @returns the GroundMesh.
  76326. */
  76327. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76328. /**
  76329. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76330. * if the ground has been updated.
  76331. * This can be used in the render loop.
  76332. * @returns the GroundMesh.
  76333. */
  76334. updateCoordinateHeights(): GroundMesh;
  76335. private _getFacetAt;
  76336. private _initHeightQuads;
  76337. private _computeHeightQuads;
  76338. /**
  76339. * Serializes this ground mesh
  76340. * @param serializationObject object to write serialization to
  76341. */
  76342. serialize(serializationObject: any): void;
  76343. /**
  76344. * Parses a serialized ground mesh
  76345. * @param parsedMesh the serialized mesh
  76346. * @param scene the scene to create the ground mesh in
  76347. * @returns the created ground mesh
  76348. */
  76349. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76350. }
  76351. }
  76352. declare module BABYLON {
  76353. /**
  76354. * Interface for Physics-Joint data
  76355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76356. */
  76357. export interface PhysicsJointData {
  76358. /**
  76359. * The main pivot of the joint
  76360. */
  76361. mainPivot?: Vector3;
  76362. /**
  76363. * The connected pivot of the joint
  76364. */
  76365. connectedPivot?: Vector3;
  76366. /**
  76367. * The main axis of the joint
  76368. */
  76369. mainAxis?: Vector3;
  76370. /**
  76371. * The connected axis of the joint
  76372. */
  76373. connectedAxis?: Vector3;
  76374. /**
  76375. * The collision of the joint
  76376. */
  76377. collision?: boolean;
  76378. /**
  76379. * Native Oimo/Cannon/Energy data
  76380. */
  76381. nativeParams?: any;
  76382. }
  76383. /**
  76384. * This is a holder class for the physics joint created by the physics plugin
  76385. * It holds a set of functions to control the underlying joint
  76386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76387. */
  76388. export class PhysicsJoint {
  76389. /**
  76390. * The type of the physics joint
  76391. */
  76392. type: number;
  76393. /**
  76394. * The data for the physics joint
  76395. */
  76396. jointData: PhysicsJointData;
  76397. private _physicsJoint;
  76398. protected _physicsPlugin: IPhysicsEnginePlugin;
  76399. /**
  76400. * Initializes the physics joint
  76401. * @param type The type of the physics joint
  76402. * @param jointData The data for the physics joint
  76403. */
  76404. constructor(
  76405. /**
  76406. * The type of the physics joint
  76407. */
  76408. type: number,
  76409. /**
  76410. * The data for the physics joint
  76411. */
  76412. jointData: PhysicsJointData);
  76413. /**
  76414. * Gets the physics joint
  76415. */
  76416. /**
  76417. * Sets the physics joint
  76418. */
  76419. physicsJoint: any;
  76420. /**
  76421. * Sets the physics plugin
  76422. */
  76423. physicsPlugin: IPhysicsEnginePlugin;
  76424. /**
  76425. * Execute a function that is physics-plugin specific.
  76426. * @param {Function} func the function that will be executed.
  76427. * It accepts two parameters: the physics world and the physics joint
  76428. */
  76429. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76430. /**
  76431. * Distance-Joint type
  76432. */
  76433. static DistanceJoint: number;
  76434. /**
  76435. * Hinge-Joint type
  76436. */
  76437. static HingeJoint: number;
  76438. /**
  76439. * Ball-and-Socket joint type
  76440. */
  76441. static BallAndSocketJoint: number;
  76442. /**
  76443. * Wheel-Joint type
  76444. */
  76445. static WheelJoint: number;
  76446. /**
  76447. * Slider-Joint type
  76448. */
  76449. static SliderJoint: number;
  76450. /**
  76451. * Prismatic-Joint type
  76452. */
  76453. static PrismaticJoint: number;
  76454. /**
  76455. * Universal-Joint type
  76456. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76457. */
  76458. static UniversalJoint: number;
  76459. /**
  76460. * Hinge-Joint 2 type
  76461. */
  76462. static Hinge2Joint: number;
  76463. /**
  76464. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76465. */
  76466. static PointToPointJoint: number;
  76467. /**
  76468. * Spring-Joint type
  76469. */
  76470. static SpringJoint: number;
  76471. /**
  76472. * Lock-Joint type
  76473. */
  76474. static LockJoint: number;
  76475. }
  76476. /**
  76477. * A class representing a physics distance joint
  76478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76479. */
  76480. export class DistanceJoint extends PhysicsJoint {
  76481. /**
  76482. *
  76483. * @param jointData The data for the Distance-Joint
  76484. */
  76485. constructor(jointData: DistanceJointData);
  76486. /**
  76487. * Update the predefined distance.
  76488. * @param maxDistance The maximum preferred distance
  76489. * @param minDistance The minimum preferred distance
  76490. */
  76491. updateDistance(maxDistance: number, minDistance?: number): void;
  76492. }
  76493. /**
  76494. * Represents a Motor-Enabled Joint
  76495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76496. */
  76497. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76498. /**
  76499. * Initializes the Motor-Enabled Joint
  76500. * @param type The type of the joint
  76501. * @param jointData The physica joint data for the joint
  76502. */
  76503. constructor(type: number, jointData: PhysicsJointData);
  76504. /**
  76505. * Set the motor values.
  76506. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76507. * @param force the force to apply
  76508. * @param maxForce max force for this motor.
  76509. */
  76510. setMotor(force?: number, maxForce?: number): void;
  76511. /**
  76512. * Set the motor's limits.
  76513. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76514. * @param upperLimit The upper limit of the motor
  76515. * @param lowerLimit The lower limit of the motor
  76516. */
  76517. setLimit(upperLimit: number, lowerLimit?: number): void;
  76518. }
  76519. /**
  76520. * This class represents a single physics Hinge-Joint
  76521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76522. */
  76523. export class HingeJoint extends MotorEnabledJoint {
  76524. /**
  76525. * Initializes the Hinge-Joint
  76526. * @param jointData The joint data for the Hinge-Joint
  76527. */
  76528. constructor(jointData: PhysicsJointData);
  76529. /**
  76530. * Set the motor values.
  76531. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76532. * @param {number} force the force to apply
  76533. * @param {number} maxForce max force for this motor.
  76534. */
  76535. setMotor(force?: number, maxForce?: number): void;
  76536. /**
  76537. * Set the motor's limits.
  76538. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76539. * @param upperLimit The upper limit of the motor
  76540. * @param lowerLimit The lower limit of the motor
  76541. */
  76542. setLimit(upperLimit: number, lowerLimit?: number): void;
  76543. }
  76544. /**
  76545. * This class represents a dual hinge physics joint (same as wheel joint)
  76546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76547. */
  76548. export class Hinge2Joint extends MotorEnabledJoint {
  76549. /**
  76550. * Initializes the Hinge2-Joint
  76551. * @param jointData The joint data for the Hinge2-Joint
  76552. */
  76553. constructor(jointData: PhysicsJointData);
  76554. /**
  76555. * Set the motor values.
  76556. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76557. * @param {number} targetSpeed the speed the motor is to reach
  76558. * @param {number} maxForce max force for this motor.
  76559. * @param {motorIndex} the motor's index, 0 or 1.
  76560. */
  76561. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76562. /**
  76563. * Set the motor limits.
  76564. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76565. * @param {number} upperLimit the upper limit
  76566. * @param {number} lowerLimit lower limit
  76567. * @param {motorIndex} the motor's index, 0 or 1.
  76568. */
  76569. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76570. }
  76571. /**
  76572. * Interface for a motor enabled joint
  76573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76574. */
  76575. export interface IMotorEnabledJoint {
  76576. /**
  76577. * Physics joint
  76578. */
  76579. physicsJoint: any;
  76580. /**
  76581. * Sets the motor of the motor-enabled joint
  76582. * @param force The force of the motor
  76583. * @param maxForce The maximum force of the motor
  76584. * @param motorIndex The index of the motor
  76585. */
  76586. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76587. /**
  76588. * Sets the limit of the motor
  76589. * @param upperLimit The upper limit of the motor
  76590. * @param lowerLimit The lower limit of the motor
  76591. * @param motorIndex The index of the motor
  76592. */
  76593. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76594. }
  76595. /**
  76596. * Joint data for a Distance-Joint
  76597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76598. */
  76599. export interface DistanceJointData extends PhysicsJointData {
  76600. /**
  76601. * Max distance the 2 joint objects can be apart
  76602. */
  76603. maxDistance: number;
  76604. }
  76605. /**
  76606. * Joint data from a spring joint
  76607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76608. */
  76609. export interface SpringJointData extends PhysicsJointData {
  76610. /**
  76611. * Length of the spring
  76612. */
  76613. length: number;
  76614. /**
  76615. * Stiffness of the spring
  76616. */
  76617. stiffness: number;
  76618. /**
  76619. * Damping of the spring
  76620. */
  76621. damping: number;
  76622. /** this callback will be called when applying the force to the impostors. */
  76623. forceApplicationCallback: () => void;
  76624. }
  76625. }
  76626. declare module BABYLON {
  76627. /**
  76628. * Interface used to describe a physics joint
  76629. */
  76630. export interface PhysicsImpostorJoint {
  76631. /** Defines the main impostor to which the joint is linked */
  76632. mainImpostor: PhysicsImpostor;
  76633. /** Defines the impostor that is connected to the main impostor using this joint */
  76634. connectedImpostor: PhysicsImpostor;
  76635. /** Defines the joint itself */
  76636. joint: PhysicsJoint;
  76637. }
  76638. /** @hidden */
  76639. export interface IPhysicsEnginePlugin {
  76640. world: any;
  76641. name: string;
  76642. setGravity(gravity: Vector3): void;
  76643. setTimeStep(timeStep: number): void;
  76644. getTimeStep(): number;
  76645. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76646. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76649. removePhysicsBody(impostor: PhysicsImpostor): void;
  76650. generateJoint(joint: PhysicsImpostorJoint): void;
  76651. removeJoint(joint: PhysicsImpostorJoint): void;
  76652. isSupported(): boolean;
  76653. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76654. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76656. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76657. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76658. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76659. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76660. getBodyMass(impostor: PhysicsImpostor): number;
  76661. getBodyFriction(impostor: PhysicsImpostor): number;
  76662. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76663. getBodyRestitution(impostor: PhysicsImpostor): number;
  76664. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76665. sleepBody(impostor: PhysicsImpostor): void;
  76666. wakeUpBody(impostor: PhysicsImpostor): void;
  76667. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76668. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76669. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76670. getRadius(impostor: PhysicsImpostor): number;
  76671. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76672. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76673. dispose(): void;
  76674. }
  76675. /**
  76676. * Interface used to define a physics engine
  76677. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76678. */
  76679. export interface IPhysicsEngine {
  76680. /**
  76681. * Gets the gravity vector used by the simulation
  76682. */
  76683. gravity: Vector3;
  76684. /**
  76685. * Sets the gravity vector used by the simulation
  76686. * @param gravity defines the gravity vector to use
  76687. */
  76688. setGravity(gravity: Vector3): void;
  76689. /**
  76690. * Set the time step of the physics engine.
  76691. * Default is 1/60.
  76692. * To slow it down, enter 1/600 for example.
  76693. * To speed it up, 1/30
  76694. * @param newTimeStep the new timestep to apply to this world.
  76695. */
  76696. setTimeStep(newTimeStep: number): void;
  76697. /**
  76698. * Get the time step of the physics engine.
  76699. * @returns the current time step
  76700. */
  76701. getTimeStep(): number;
  76702. /**
  76703. * Release all resources
  76704. */
  76705. dispose(): void;
  76706. /**
  76707. * Gets the name of the current physics plugin
  76708. * @returns the name of the plugin
  76709. */
  76710. getPhysicsPluginName(): string;
  76711. /**
  76712. * Adding a new impostor for the impostor tracking.
  76713. * This will be done by the impostor itself.
  76714. * @param impostor the impostor to add
  76715. */
  76716. addImpostor(impostor: PhysicsImpostor): void;
  76717. /**
  76718. * Remove an impostor from the engine.
  76719. * This impostor and its mesh will not longer be updated by the physics engine.
  76720. * @param impostor the impostor to remove
  76721. */
  76722. removeImpostor(impostor: PhysicsImpostor): void;
  76723. /**
  76724. * Add a joint to the physics engine
  76725. * @param mainImpostor defines the main impostor to which the joint is added.
  76726. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76727. * @param joint defines the joint that will connect both impostors.
  76728. */
  76729. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76730. /**
  76731. * Removes a joint from the simulation
  76732. * @param mainImpostor defines the impostor used with the joint
  76733. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76734. * @param joint defines the joint to remove
  76735. */
  76736. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76737. /**
  76738. * Gets the current plugin used to run the simulation
  76739. * @returns current plugin
  76740. */
  76741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76742. /**
  76743. * Gets the list of physic impostors
  76744. * @returns an array of PhysicsImpostor
  76745. */
  76746. getImpostors(): Array<PhysicsImpostor>;
  76747. /**
  76748. * Gets the impostor for a physics enabled object
  76749. * @param object defines the object impersonated by the impostor
  76750. * @returns the PhysicsImpostor or null if not found
  76751. */
  76752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76753. /**
  76754. * Gets the impostor for a physics body object
  76755. * @param body defines physics body used by the impostor
  76756. * @returns the PhysicsImpostor or null if not found
  76757. */
  76758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76759. /**
  76760. * Called by the scene. No need to call it.
  76761. * @param delta defines the timespam between frames
  76762. */
  76763. _step(delta: number): void;
  76764. }
  76765. }
  76766. declare module BABYLON {
  76767. /**
  76768. * The interface for the physics imposter parameters
  76769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76770. */
  76771. export interface PhysicsImpostorParameters {
  76772. /**
  76773. * The mass of the physics imposter
  76774. */
  76775. mass: number;
  76776. /**
  76777. * The friction of the physics imposter
  76778. */
  76779. friction?: number;
  76780. /**
  76781. * The coefficient of restitution of the physics imposter
  76782. */
  76783. restitution?: number;
  76784. /**
  76785. * The native options of the physics imposter
  76786. */
  76787. nativeOptions?: any;
  76788. /**
  76789. * Specifies if the parent should be ignored
  76790. */
  76791. ignoreParent?: boolean;
  76792. /**
  76793. * Specifies if bi-directional transformations should be disabled
  76794. */
  76795. disableBidirectionalTransformation?: boolean;
  76796. }
  76797. /**
  76798. * Interface for a physics-enabled object
  76799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76800. */
  76801. export interface IPhysicsEnabledObject {
  76802. /**
  76803. * The position of the physics-enabled object
  76804. */
  76805. position: Vector3;
  76806. /**
  76807. * The rotation of the physics-enabled object
  76808. */
  76809. rotationQuaternion: Nullable<Quaternion>;
  76810. /**
  76811. * The scale of the physics-enabled object
  76812. */
  76813. scaling: Vector3;
  76814. /**
  76815. * The rotation of the physics-enabled object
  76816. */
  76817. rotation?: Vector3;
  76818. /**
  76819. * The parent of the physics-enabled object
  76820. */
  76821. parent?: any;
  76822. /**
  76823. * The bounding info of the physics-enabled object
  76824. * @returns The bounding info of the physics-enabled object
  76825. */
  76826. getBoundingInfo(): BoundingInfo;
  76827. /**
  76828. * Computes the world matrix
  76829. * @param force Specifies if the world matrix should be computed by force
  76830. * @returns A world matrix
  76831. */
  76832. computeWorldMatrix(force: boolean): Matrix;
  76833. /**
  76834. * Gets the world matrix
  76835. * @returns A world matrix
  76836. */
  76837. getWorldMatrix?(): Matrix;
  76838. /**
  76839. * Gets the child meshes
  76840. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76841. * @returns An array of abstract meshes
  76842. */
  76843. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76844. /**
  76845. * Gets the vertex data
  76846. * @param kind The type of vertex data
  76847. * @returns A nullable array of numbers, or a float32 array
  76848. */
  76849. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76850. /**
  76851. * Gets the indices from the mesh
  76852. * @returns A nullable array of index arrays
  76853. */
  76854. getIndices?(): Nullable<IndicesArray>;
  76855. /**
  76856. * Gets the scene from the mesh
  76857. * @returns the indices array or null
  76858. */
  76859. getScene?(): Scene;
  76860. /**
  76861. * Gets the absolute position from the mesh
  76862. * @returns the absolute position
  76863. */
  76864. getAbsolutePosition(): Vector3;
  76865. /**
  76866. * Gets the absolute pivot point from the mesh
  76867. * @returns the absolute pivot point
  76868. */
  76869. getAbsolutePivotPoint(): Vector3;
  76870. /**
  76871. * Rotates the mesh
  76872. * @param axis The axis of rotation
  76873. * @param amount The amount of rotation
  76874. * @param space The space of the rotation
  76875. * @returns The rotation transform node
  76876. */
  76877. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76878. /**
  76879. * Translates the mesh
  76880. * @param axis The axis of translation
  76881. * @param distance The distance of translation
  76882. * @param space The space of the translation
  76883. * @returns The transform node
  76884. */
  76885. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76886. /**
  76887. * Sets the absolute position of the mesh
  76888. * @param absolutePosition The absolute position of the mesh
  76889. * @returns The transform node
  76890. */
  76891. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76892. /**
  76893. * Gets the class name of the mesh
  76894. * @returns The class name
  76895. */
  76896. getClassName(): string;
  76897. }
  76898. /**
  76899. * Represents a physics imposter
  76900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76901. */
  76902. export class PhysicsImpostor {
  76903. /**
  76904. * The physics-enabled object used as the physics imposter
  76905. */
  76906. object: IPhysicsEnabledObject;
  76907. /**
  76908. * The type of the physics imposter
  76909. */
  76910. type: number;
  76911. private _options;
  76912. private _scene?;
  76913. /**
  76914. * The default object size of the imposter
  76915. */
  76916. static DEFAULT_OBJECT_SIZE: Vector3;
  76917. /**
  76918. * The identity quaternion of the imposter
  76919. */
  76920. static IDENTITY_QUATERNION: Quaternion;
  76921. /** @hidden */
  76922. _pluginData: any;
  76923. private _physicsEngine;
  76924. private _physicsBody;
  76925. private _bodyUpdateRequired;
  76926. private _onBeforePhysicsStepCallbacks;
  76927. private _onAfterPhysicsStepCallbacks;
  76928. /** @hidden */
  76929. _onPhysicsCollideCallbacks: Array<{
  76930. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76931. otherImpostors: Array<PhysicsImpostor>;
  76932. }>;
  76933. private _deltaPosition;
  76934. private _deltaRotation;
  76935. private _deltaRotationConjugated;
  76936. private _parent;
  76937. private _isDisposed;
  76938. private static _tmpVecs;
  76939. private static _tmpQuat;
  76940. /**
  76941. * Specifies if the physics imposter is disposed
  76942. */
  76943. readonly isDisposed: boolean;
  76944. /**
  76945. * Gets the mass of the physics imposter
  76946. */
  76947. mass: number;
  76948. /**
  76949. * Gets the coefficient of friction
  76950. */
  76951. /**
  76952. * Sets the coefficient of friction
  76953. */
  76954. friction: number;
  76955. /**
  76956. * Gets the coefficient of restitution
  76957. */
  76958. /**
  76959. * Sets the coefficient of restitution
  76960. */
  76961. restitution: number;
  76962. /**
  76963. * The unique id of the physics imposter
  76964. * set by the physics engine when adding this impostor to the array
  76965. */
  76966. uniqueId: number;
  76967. private _joints;
  76968. /**
  76969. * Initializes the physics imposter
  76970. * @param object The physics-enabled object used as the physics imposter
  76971. * @param type The type of the physics imposter
  76972. * @param _options The options for the physics imposter
  76973. * @param _scene The Babylon scene
  76974. */
  76975. constructor(
  76976. /**
  76977. * The physics-enabled object used as the physics imposter
  76978. */
  76979. object: IPhysicsEnabledObject,
  76980. /**
  76981. * The type of the physics imposter
  76982. */
  76983. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76984. /**
  76985. * This function will completly initialize this impostor.
  76986. * It will create a new body - but only if this mesh has no parent.
  76987. * If it has, this impostor will not be used other than to define the impostor
  76988. * of the child mesh.
  76989. * @hidden
  76990. */
  76991. _init(): void;
  76992. private _getPhysicsParent;
  76993. /**
  76994. * Should a new body be generated.
  76995. * @returns boolean specifying if body initialization is required
  76996. */
  76997. isBodyInitRequired(): boolean;
  76998. /**
  76999. * Sets the updated scaling
  77000. * @param updated Specifies if the scaling is updated
  77001. */
  77002. setScalingUpdated(): void;
  77003. /**
  77004. * Force a regeneration of this or the parent's impostor's body.
  77005. * Use under cautious - This will remove all joints already implemented.
  77006. */
  77007. forceUpdate(): void;
  77008. /**
  77009. * Gets the body that holds this impostor. Either its own, or its parent.
  77010. */
  77011. /**
  77012. * Set the physics body. Used mainly by the physics engine/plugin
  77013. */
  77014. physicsBody: any;
  77015. /**
  77016. * Get the parent of the physics imposter
  77017. * @returns Physics imposter or null
  77018. */
  77019. /**
  77020. * Sets the parent of the physics imposter
  77021. */
  77022. parent: Nullable<PhysicsImpostor>;
  77023. /**
  77024. * Resets the update flags
  77025. */
  77026. resetUpdateFlags(): void;
  77027. /**
  77028. * Gets the object extend size
  77029. * @returns the object extend size
  77030. */
  77031. getObjectExtendSize(): Vector3;
  77032. /**
  77033. * Gets the object center
  77034. * @returns The object center
  77035. */
  77036. getObjectCenter(): Vector3;
  77037. /**
  77038. * Get a specific parametes from the options parameter
  77039. * @param paramName The object parameter name
  77040. * @returns The object parameter
  77041. */
  77042. getParam(paramName: string): any;
  77043. /**
  77044. * Sets a specific parameter in the options given to the physics plugin
  77045. * @param paramName The parameter name
  77046. * @param value The value of the parameter
  77047. */
  77048. setParam(paramName: string, value: number): void;
  77049. /**
  77050. * Specifically change the body's mass option. Won't recreate the physics body object
  77051. * @param mass The mass of the physics imposter
  77052. */
  77053. setMass(mass: number): void;
  77054. /**
  77055. * Gets the linear velocity
  77056. * @returns linear velocity or null
  77057. */
  77058. getLinearVelocity(): Nullable<Vector3>;
  77059. /**
  77060. * Sets the linear velocity
  77061. * @param velocity linear velocity or null
  77062. */
  77063. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77064. /**
  77065. * Gets the angular velocity
  77066. * @returns angular velocity or null
  77067. */
  77068. getAngularVelocity(): Nullable<Vector3>;
  77069. /**
  77070. * Sets the angular velocity
  77071. * @param velocity The velocity or null
  77072. */
  77073. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77074. /**
  77075. * Execute a function with the physics plugin native code
  77076. * Provide a function the will have two variables - the world object and the physics body object
  77077. * @param func The function to execute with the physics plugin native code
  77078. */
  77079. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77080. /**
  77081. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77085. /**
  77086. * Unregister a function that will be executed before the physics world is stepping forward
  77087. * @param func The function to execute before the physics world is stepped forward
  77088. */
  77089. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77090. /**
  77091. * Register a function that will be executed after the physics step
  77092. * @param func The function to execute after physics step
  77093. */
  77094. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77095. /**
  77096. * Unregisters a function that will be executed after the physics step
  77097. * @param func The function to execute after physics step
  77098. */
  77099. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77100. /**
  77101. * register a function that will be executed when this impostor collides against a different body
  77102. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77103. * @param func Callback that is executed on collision
  77104. */
  77105. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77106. /**
  77107. * Unregisters the physics imposter on contact
  77108. * @param collideAgainst The physics object to collide against
  77109. * @param func Callback to execute on collision
  77110. */
  77111. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77112. private _tmpQuat;
  77113. private _tmpQuat2;
  77114. /**
  77115. * Get the parent rotation
  77116. * @returns The parent rotation
  77117. */
  77118. getParentsRotation(): Quaternion;
  77119. /**
  77120. * this function is executed by the physics engine.
  77121. */
  77122. beforeStep: () => void;
  77123. /**
  77124. * this function is executed by the physics engine
  77125. */
  77126. afterStep: () => void;
  77127. /**
  77128. * Legacy collision detection event support
  77129. */
  77130. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77131. /**
  77132. * event and body object due to cannon's event-based architecture.
  77133. */
  77134. onCollide: (e: {
  77135. body: any;
  77136. }) => void;
  77137. /**
  77138. * Apply a force
  77139. * @param force The force to apply
  77140. * @param contactPoint The contact point for the force
  77141. * @returns The physics imposter
  77142. */
  77143. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77144. /**
  77145. * Apply an impulse
  77146. * @param force The impulse force
  77147. * @param contactPoint The contact point for the impulse force
  77148. * @returns The physics imposter
  77149. */
  77150. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77151. /**
  77152. * A help function to create a joint
  77153. * @param otherImpostor A physics imposter used to create a joint
  77154. * @param jointType The type of joint
  77155. * @param jointData The data for the joint
  77156. * @returns The physics imposter
  77157. */
  77158. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77159. /**
  77160. * Add a joint to this impostor with a different impostor
  77161. * @param otherImpostor A physics imposter used to add a joint
  77162. * @param joint The joint to add
  77163. * @returns The physics imposter
  77164. */
  77165. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77166. /**
  77167. * Will keep this body still, in a sleep mode.
  77168. * @returns the physics imposter
  77169. */
  77170. sleep(): PhysicsImpostor;
  77171. /**
  77172. * Wake the body up.
  77173. * @returns The physics imposter
  77174. */
  77175. wakeUp(): PhysicsImpostor;
  77176. /**
  77177. * Clones the physics imposter
  77178. * @param newObject The physics imposter clones to this physics-enabled object
  77179. * @returns A nullable physics imposter
  77180. */
  77181. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77182. /**
  77183. * Disposes the physics imposter
  77184. */
  77185. dispose(): void;
  77186. /**
  77187. * Sets the delta position
  77188. * @param position The delta position amount
  77189. */
  77190. setDeltaPosition(position: Vector3): void;
  77191. /**
  77192. * Sets the delta rotation
  77193. * @param rotation The delta rotation amount
  77194. */
  77195. setDeltaRotation(rotation: Quaternion): void;
  77196. /**
  77197. * Gets the box size of the physics imposter and stores the result in the input parameter
  77198. * @param result Stores the box size
  77199. * @returns The physics imposter
  77200. */
  77201. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77202. /**
  77203. * Gets the radius of the physics imposter
  77204. * @returns Radius of the physics imposter
  77205. */
  77206. getRadius(): number;
  77207. /**
  77208. * Sync a bone with this impostor
  77209. * @param bone The bone to sync to the impostor.
  77210. * @param boneMesh The mesh that the bone is influencing.
  77211. * @param jointPivot The pivot of the joint / bone in local space.
  77212. * @param distToJoint Optional distance from the impostor to the joint.
  77213. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77214. */
  77215. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77216. /**
  77217. * Sync impostor to a bone
  77218. * @param bone The bone that the impostor will be synced to.
  77219. * @param boneMesh The mesh that the bone is influencing.
  77220. * @param jointPivot The pivot of the joint / bone in local space.
  77221. * @param distToJoint Optional distance from the impostor to the joint.
  77222. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77223. * @param boneAxis Optional vector3 axis the bone is aligned with
  77224. */
  77225. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77226. /**
  77227. * No-Imposter type
  77228. */
  77229. static NoImpostor: number;
  77230. /**
  77231. * Sphere-Imposter type
  77232. */
  77233. static SphereImpostor: number;
  77234. /**
  77235. * Box-Imposter type
  77236. */
  77237. static BoxImpostor: number;
  77238. /**
  77239. * Plane-Imposter type
  77240. */
  77241. static PlaneImpostor: number;
  77242. /**
  77243. * Mesh-imposter type
  77244. */
  77245. static MeshImpostor: number;
  77246. /**
  77247. * Cylinder-Imposter type
  77248. */
  77249. static CylinderImpostor: number;
  77250. /**
  77251. * Particle-Imposter type
  77252. */
  77253. static ParticleImpostor: number;
  77254. /**
  77255. * Heightmap-Imposter type
  77256. */
  77257. static HeightmapImpostor: number;
  77258. }
  77259. }
  77260. declare module BABYLON {
  77261. /**
  77262. * Class used to represent a specific level of detail of a mesh
  77263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77264. */
  77265. export class MeshLODLevel {
  77266. /** Defines the distance where this level should star being displayed */
  77267. distance: number;
  77268. /** Defines the mesh to use to render this level */
  77269. mesh: Nullable<Mesh>;
  77270. /**
  77271. * Creates a new LOD level
  77272. * @param distance defines the distance where this level should star being displayed
  77273. * @param mesh defines the mesh to use to render this level
  77274. */
  77275. constructor(
  77276. /** Defines the distance where this level should star being displayed */
  77277. distance: number,
  77278. /** Defines the mesh to use to render this level */
  77279. mesh: Nullable<Mesh>);
  77280. }
  77281. /**
  77282. * @hidden
  77283. **/
  77284. export class _CreationDataStorage {
  77285. closePath?: boolean;
  77286. closeArray?: boolean;
  77287. idx: number[];
  77288. dashSize: number;
  77289. gapSize: number;
  77290. path3D: Path3D;
  77291. pathArray: Vector3[][];
  77292. arc: number;
  77293. radius: number;
  77294. cap: number;
  77295. tessellation: number;
  77296. }
  77297. /**
  77298. * @hidden
  77299. **/
  77300. class _InstanceDataStorage {
  77301. visibleInstances: any;
  77302. renderIdForInstances: number[];
  77303. batchCache: _InstancesBatch;
  77304. instancesBufferSize: number;
  77305. instancesBuffer: Nullable<Buffer>;
  77306. instancesData: Float32Array;
  77307. overridenInstanceCount: number;
  77308. }
  77309. /**
  77310. * @hidden
  77311. **/
  77312. export class _InstancesBatch {
  77313. mustReturn: boolean;
  77314. visibleInstances: Nullable<InstancedMesh[]>[];
  77315. renderSelf: boolean[];
  77316. }
  77317. /**
  77318. * Class used to represent renderable models
  77319. */
  77320. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77321. /**
  77322. * Mesh side orientation : usually the external or front surface
  77323. */
  77324. static readonly FRONTSIDE: number;
  77325. /**
  77326. * Mesh side orientation : usually the internal or back surface
  77327. */
  77328. static readonly BACKSIDE: number;
  77329. /**
  77330. * Mesh side orientation : both internal and external or front and back surfaces
  77331. */
  77332. static readonly DOUBLESIDE: number;
  77333. /**
  77334. * Mesh side orientation : by default, `FRONTSIDE`
  77335. */
  77336. static readonly DEFAULTSIDE: number;
  77337. /**
  77338. * Mesh cap setting : no cap
  77339. */
  77340. static readonly NO_CAP: number;
  77341. /**
  77342. * Mesh cap setting : one cap at the beginning of the mesh
  77343. */
  77344. static readonly CAP_START: number;
  77345. /**
  77346. * Mesh cap setting : one cap at the end of the mesh
  77347. */
  77348. static readonly CAP_END: number;
  77349. /**
  77350. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77351. */
  77352. static readonly CAP_ALL: number;
  77353. /**
  77354. * Gets the default side orientation.
  77355. * @param orientation the orientation to value to attempt to get
  77356. * @returns the default orientation
  77357. * @hidden
  77358. */
  77359. static _GetDefaultSideOrientation(orientation?: number): number;
  77360. private _onBeforeRenderObservable;
  77361. private _onBeforeBindObservable;
  77362. private _onAfterRenderObservable;
  77363. private _onBeforeDrawObservable;
  77364. /**
  77365. * An event triggered before rendering the mesh
  77366. */
  77367. readonly onBeforeRenderObservable: Observable<Mesh>;
  77368. /**
  77369. * An event triggered before binding the mesh
  77370. */
  77371. readonly onBeforeBindObservable: Observable<Mesh>;
  77372. /**
  77373. * An event triggered after rendering the mesh
  77374. */
  77375. readonly onAfterRenderObservable: Observable<Mesh>;
  77376. /**
  77377. * An event triggered before drawing the mesh
  77378. */
  77379. readonly onBeforeDrawObservable: Observable<Mesh>;
  77380. private _onBeforeDrawObserver;
  77381. /**
  77382. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77383. */
  77384. onBeforeDraw: () => void;
  77385. /**
  77386. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77387. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77388. */
  77389. delayLoadState: number;
  77390. /**
  77391. * Gets the list of instances created from this mesh
  77392. * it is not supposed to be modified manually.
  77393. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77394. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77395. */
  77396. instances: InstancedMesh[];
  77397. /**
  77398. * Gets the file containing delay loading data for this mesh
  77399. */
  77400. delayLoadingFile: string;
  77401. /** @hidden */
  77402. _binaryInfo: any;
  77403. private _LODLevels;
  77404. /**
  77405. * User defined function used to change how LOD level selection is done
  77406. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77407. */
  77408. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77409. private _morphTargetManager;
  77410. /**
  77411. * Gets or sets the morph target manager
  77412. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77413. */
  77414. morphTargetManager: Nullable<MorphTargetManager>;
  77415. /** @hidden */
  77416. _creationDataStorage: Nullable<_CreationDataStorage>;
  77417. /** @hidden */
  77418. _geometry: Nullable<Geometry>;
  77419. /** @hidden */
  77420. _delayInfo: Array<string>;
  77421. /** @hidden */
  77422. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77423. /** @hidden */
  77424. _instanceDataStorage: _InstanceDataStorage;
  77425. private _effectiveMaterial;
  77426. /** @hidden */
  77427. _shouldGenerateFlatShading: boolean;
  77428. private _preActivateId;
  77429. /** @hidden */
  77430. _originalBuilderSideOrientation: number;
  77431. /**
  77432. * Use this property to change the original side orientation defined at construction time
  77433. */
  77434. overrideMaterialSideOrientation: Nullable<number>;
  77435. private _areNormalsFrozen;
  77436. private _sourcePositions;
  77437. private _sourceNormals;
  77438. private _source;
  77439. private meshMap;
  77440. /**
  77441. * Gets the source mesh (the one used to clone this one from)
  77442. */
  77443. readonly source: Nullable<Mesh>;
  77444. /**
  77445. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77446. */
  77447. isUnIndexed: boolean;
  77448. /**
  77449. * @constructor
  77450. * @param name The value used by scene.getMeshByName() to do a lookup.
  77451. * @param scene The scene to add this mesh to.
  77452. * @param parent The parent of this mesh, if it has one
  77453. * @param source An optional Mesh from which geometry is shared, cloned.
  77454. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77455. * When false, achieved by calling a clone(), also passing False.
  77456. * This will make creation of children, recursive.
  77457. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77458. */
  77459. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77460. /**
  77461. * Gets the class name
  77462. * @returns the string "Mesh".
  77463. */
  77464. getClassName(): string;
  77465. /** @hidden */
  77466. readonly _isMesh: boolean;
  77467. /**
  77468. * Returns a description of this mesh
  77469. * @param fullDetails define if full details about this mesh must be used
  77470. * @returns a descriptive string representing this mesh
  77471. */
  77472. toString(fullDetails?: boolean): string;
  77473. /** @hidden */
  77474. _unBindEffect(): void;
  77475. /**
  77476. * Gets a boolean indicating if this mesh has LOD
  77477. */
  77478. readonly hasLODLevels: boolean;
  77479. /**
  77480. * Gets the list of MeshLODLevel associated with the current mesh
  77481. * @returns an array of MeshLODLevel
  77482. */
  77483. getLODLevels(): MeshLODLevel[];
  77484. private _sortLODLevels;
  77485. /**
  77486. * Add a mesh as LOD level triggered at the given distance.
  77487. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77488. * @param distance The distance from the center of the object to show this level
  77489. * @param mesh The mesh to be added as LOD level (can be null)
  77490. * @return This mesh (for chaining)
  77491. */
  77492. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77493. /**
  77494. * Returns the LOD level mesh at the passed distance or null if not found.
  77495. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77496. * @param distance The distance from the center of the object to show this level
  77497. * @returns a Mesh or `null`
  77498. */
  77499. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77500. /**
  77501. * Remove a mesh from the LOD array
  77502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77503. * @param mesh defines the mesh to be removed
  77504. * @return This mesh (for chaining)
  77505. */
  77506. removeLODLevel(mesh: Mesh): Mesh;
  77507. /**
  77508. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77510. * @param camera defines the camera to use to compute distance
  77511. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77512. * @return This mesh (for chaining)
  77513. */
  77514. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77515. /**
  77516. * Gets the mesh internal Geometry object
  77517. */
  77518. readonly geometry: Nullable<Geometry>;
  77519. /**
  77520. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77521. * @returns the total number of vertices
  77522. */
  77523. getTotalVertices(): number;
  77524. /**
  77525. * Returns the content of an associated vertex buffer
  77526. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77527. * - VertexBuffer.PositionKind
  77528. * - VertexBuffer.UVKind
  77529. * - VertexBuffer.UV2Kind
  77530. * - VertexBuffer.UV3Kind
  77531. * - VertexBuffer.UV4Kind
  77532. * - VertexBuffer.UV5Kind
  77533. * - VertexBuffer.UV6Kind
  77534. * - VertexBuffer.ColorKind
  77535. * - VertexBuffer.MatricesIndicesKind
  77536. * - VertexBuffer.MatricesIndicesExtraKind
  77537. * - VertexBuffer.MatricesWeightsKind
  77538. * - VertexBuffer.MatricesWeightsExtraKind
  77539. * @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
  77540. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77541. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77542. */
  77543. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77544. /**
  77545. * Returns the mesh VertexBuffer object from the requested `kind`
  77546. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77547. * - VertexBuffer.PositionKind
  77548. * - VertexBuffer.UVKind
  77549. * - VertexBuffer.UV2Kind
  77550. * - VertexBuffer.UV3Kind
  77551. * - VertexBuffer.UV4Kind
  77552. * - VertexBuffer.UV5Kind
  77553. * - VertexBuffer.UV6Kind
  77554. * - VertexBuffer.ColorKind
  77555. * - VertexBuffer.MatricesIndicesKind
  77556. * - VertexBuffer.MatricesIndicesExtraKind
  77557. * - VertexBuffer.MatricesWeightsKind
  77558. * - VertexBuffer.MatricesWeightsExtraKind
  77559. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77560. */
  77561. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77562. /**
  77563. * Tests if a specific vertex buffer is associated with this mesh
  77564. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77565. * - VertexBuffer.PositionKind
  77566. * - VertexBuffer.UVKind
  77567. * - VertexBuffer.UV2Kind
  77568. * - VertexBuffer.UV3Kind
  77569. * - VertexBuffer.UV4Kind
  77570. * - VertexBuffer.UV5Kind
  77571. * - VertexBuffer.UV6Kind
  77572. * - VertexBuffer.ColorKind
  77573. * - VertexBuffer.MatricesIndicesKind
  77574. * - VertexBuffer.MatricesIndicesExtraKind
  77575. * - VertexBuffer.MatricesWeightsKind
  77576. * - VertexBuffer.MatricesWeightsExtraKind
  77577. * @returns a boolean
  77578. */
  77579. isVerticesDataPresent(kind: string): boolean;
  77580. /**
  77581. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77582. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77583. * - VertexBuffer.PositionKind
  77584. * - VertexBuffer.UVKind
  77585. * - VertexBuffer.UV2Kind
  77586. * - VertexBuffer.UV3Kind
  77587. * - VertexBuffer.UV4Kind
  77588. * - VertexBuffer.UV5Kind
  77589. * - VertexBuffer.UV6Kind
  77590. * - VertexBuffer.ColorKind
  77591. * - VertexBuffer.MatricesIndicesKind
  77592. * - VertexBuffer.MatricesIndicesExtraKind
  77593. * - VertexBuffer.MatricesWeightsKind
  77594. * - VertexBuffer.MatricesWeightsExtraKind
  77595. * @returns a boolean
  77596. */
  77597. isVertexBufferUpdatable(kind: string): boolean;
  77598. /**
  77599. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77600. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77601. * - VertexBuffer.PositionKind
  77602. * - VertexBuffer.UVKind
  77603. * - VertexBuffer.UV2Kind
  77604. * - VertexBuffer.UV3Kind
  77605. * - VertexBuffer.UV4Kind
  77606. * - VertexBuffer.UV5Kind
  77607. * - VertexBuffer.UV6Kind
  77608. * - VertexBuffer.ColorKind
  77609. * - VertexBuffer.MatricesIndicesKind
  77610. * - VertexBuffer.MatricesIndicesExtraKind
  77611. * - VertexBuffer.MatricesWeightsKind
  77612. * - VertexBuffer.MatricesWeightsExtraKind
  77613. * @returns an array of strings
  77614. */
  77615. getVerticesDataKinds(): string[];
  77616. /**
  77617. * Returns a positive integer : the total number of indices in this mesh geometry.
  77618. * @returns the numner of indices or zero if the mesh has no geometry.
  77619. */
  77620. getTotalIndices(): number;
  77621. /**
  77622. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77623. * @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.
  77624. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77625. * @returns the indices array or an empty array if the mesh has no geometry
  77626. */
  77627. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77628. readonly isBlocked: boolean;
  77629. /**
  77630. * Determine if the current mesh is ready to be rendered
  77631. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77632. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77633. * @returns true if all associated assets are ready (material, textures, shaders)
  77634. */
  77635. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77636. /**
  77637. * 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.
  77638. */
  77639. readonly areNormalsFrozen: boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  77642. * @returns the current mesh
  77643. */
  77644. freezeNormals(): Mesh;
  77645. /**
  77646. * 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
  77647. * @returns the current mesh
  77648. */
  77649. unfreezeNormals(): Mesh;
  77650. /**
  77651. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77652. */
  77653. overridenInstanceCount: number;
  77654. /** @hidden */
  77655. _preActivate(): Mesh;
  77656. /** @hidden */
  77657. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77658. /** @hidden */
  77659. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77660. /**
  77661. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77662. * This means the mesh underlying bounding box and sphere are recomputed.
  77663. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77664. * @returns the current mesh
  77665. */
  77666. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77667. /** @hidden */
  77668. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77669. /**
  77670. * This function will subdivide the mesh into multiple submeshes
  77671. * @param count defines the expected number of submeshes
  77672. */
  77673. subdivide(count: number): void;
  77674. /**
  77675. * Copy a FloatArray into a specific associated vertex buffer
  77676. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77677. * - VertexBuffer.PositionKind
  77678. * - VertexBuffer.UVKind
  77679. * - VertexBuffer.UV2Kind
  77680. * - VertexBuffer.UV3Kind
  77681. * - VertexBuffer.UV4Kind
  77682. * - VertexBuffer.UV5Kind
  77683. * - VertexBuffer.UV6Kind
  77684. * - VertexBuffer.ColorKind
  77685. * - VertexBuffer.MatricesIndicesKind
  77686. * - VertexBuffer.MatricesIndicesExtraKind
  77687. * - VertexBuffer.MatricesWeightsKind
  77688. * - VertexBuffer.MatricesWeightsExtraKind
  77689. * @param data defines the data source
  77690. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77691. * @param stride defines the data stride size (can be null)
  77692. * @returns the current mesh
  77693. */
  77694. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77695. /**
  77696. * Flags an associated vertex buffer as updatable
  77697. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77698. * - VertexBuffer.PositionKind
  77699. * - VertexBuffer.UVKind
  77700. * - VertexBuffer.UV2Kind
  77701. * - VertexBuffer.UV3Kind
  77702. * - VertexBuffer.UV4Kind
  77703. * - VertexBuffer.UV5Kind
  77704. * - VertexBuffer.UV6Kind
  77705. * - VertexBuffer.ColorKind
  77706. * - VertexBuffer.MatricesIndicesKind
  77707. * - VertexBuffer.MatricesIndicesExtraKind
  77708. * - VertexBuffer.MatricesWeightsKind
  77709. * - VertexBuffer.MatricesWeightsExtraKind
  77710. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77711. */
  77712. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77713. /**
  77714. * Sets the mesh global Vertex Buffer
  77715. * @param buffer defines the buffer to use
  77716. * @returns the current mesh
  77717. */
  77718. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77719. /**
  77720. * Update a specific associated vertex buffer
  77721. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77722. * - VertexBuffer.PositionKind
  77723. * - VertexBuffer.UVKind
  77724. * - VertexBuffer.UV2Kind
  77725. * - VertexBuffer.UV3Kind
  77726. * - VertexBuffer.UV4Kind
  77727. * - VertexBuffer.UV5Kind
  77728. * - VertexBuffer.UV6Kind
  77729. * - VertexBuffer.ColorKind
  77730. * - VertexBuffer.MatricesIndicesKind
  77731. * - VertexBuffer.MatricesIndicesExtraKind
  77732. * - VertexBuffer.MatricesWeightsKind
  77733. * - VertexBuffer.MatricesWeightsExtraKind
  77734. * @param data defines the data source
  77735. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77736. * @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)
  77737. * @returns the current mesh
  77738. */
  77739. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77740. /**
  77741. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77742. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77743. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77744. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77745. * @returns the current mesh
  77746. */
  77747. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77748. /**
  77749. * Creates a un-shared specific occurence of the geometry for the mesh.
  77750. * @returns the current mesh
  77751. */
  77752. makeGeometryUnique(): Mesh;
  77753. /**
  77754. * Set the index buffer of this mesh
  77755. * @param indices defines the source data
  77756. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77757. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77758. * @returns the current mesh
  77759. */
  77760. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77761. /**
  77762. * Update the current index buffer
  77763. * @param indices defines the source data
  77764. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77765. * @returns the current mesh
  77766. */
  77767. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77768. /**
  77769. * Invert the geometry to move from a right handed system to a left handed one.
  77770. * @returns the current mesh
  77771. */
  77772. toLeftHanded(): Mesh;
  77773. /** @hidden */
  77774. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77775. /** @hidden */
  77776. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77777. /**
  77778. * Registers for this mesh a javascript function called just before the rendering process
  77779. * @param func defines the function to call before rendering this mesh
  77780. * @returns the current mesh
  77781. */
  77782. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77783. /**
  77784. * Disposes a previously registered javascript function called before the rendering
  77785. * @param func defines the function to remove
  77786. * @returns the current mesh
  77787. */
  77788. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77789. /**
  77790. * Registers for this mesh a javascript function called just after the rendering is complete
  77791. * @param func defines the function to call after rendering this mesh
  77792. * @returns the current mesh
  77793. */
  77794. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77795. /**
  77796. * Disposes a previously registered javascript function called after the rendering.
  77797. * @param func defines the function to remove
  77798. * @returns the current mesh
  77799. */
  77800. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77801. /** @hidden */
  77802. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77803. /** @hidden */
  77804. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77805. /** @hidden */
  77806. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77807. /**
  77808. * 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
  77809. * @param subMesh defines the subMesh to render
  77810. * @param enableAlphaMode defines if alpha mode can be changed
  77811. * @returns the current mesh
  77812. */
  77813. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77814. private _onBeforeDraw;
  77815. /**
  77816. * Renormalize the mesh and patch it up if there are no weights
  77817. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77818. * However in the case of zero weights then we set just a single influence to 1.
  77819. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77820. */
  77821. cleanMatrixWeights(): void;
  77822. private normalizeSkinFourWeights;
  77823. private normalizeSkinWeightsAndExtra;
  77824. /**
  77825. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77826. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77827. * the user know there was an issue with importing the mesh
  77828. * @returns a validation object with skinned, valid and report string
  77829. */
  77830. validateSkinning(): {
  77831. skinned: boolean;
  77832. valid: boolean;
  77833. report: string;
  77834. };
  77835. /** @hidden */
  77836. _checkDelayState(): Mesh;
  77837. private _queueLoad;
  77838. /**
  77839. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77840. * A mesh is in the frustum if its bounding box intersects the frustum
  77841. * @param frustumPlanes defines the frustum to test
  77842. * @returns true if the mesh is in the frustum planes
  77843. */
  77844. isInFrustum(frustumPlanes: Plane[]): boolean;
  77845. /**
  77846. * Sets the mesh material by the material or multiMaterial `id` property
  77847. * @param id is a string identifying the material or the multiMaterial
  77848. * @returns the current mesh
  77849. */
  77850. setMaterialByID(id: string): Mesh;
  77851. /**
  77852. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77853. * @returns an array of IAnimatable
  77854. */
  77855. getAnimatables(): IAnimatable[];
  77856. /**
  77857. * Modifies the mesh geometry according to the passed transformation matrix.
  77858. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77859. * The mesh normals are modified using the same transformation.
  77860. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77861. * @param transform defines the transform matrix to use
  77862. * @see http://doc.babylonjs.com/resources/baking_transformations
  77863. * @returns the current mesh
  77864. */
  77865. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77866. /**
  77867. * Modifies the mesh geometry according to its own current World Matrix.
  77868. * The mesh World Matrix is then reset.
  77869. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77870. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77871. * @see http://doc.babylonjs.com/resources/baking_transformations
  77872. * @returns the current mesh
  77873. */
  77874. bakeCurrentTransformIntoVertices(): Mesh;
  77875. /** @hidden */
  77876. readonly _positions: Nullable<Vector3[]>;
  77877. /** @hidden */
  77878. _resetPointsArrayCache(): Mesh;
  77879. /** @hidden */
  77880. _generatePointsArray(): boolean;
  77881. /**
  77882. * Returns a new Mesh object generated from the current mesh properties.
  77883. * This method must not get confused with createInstance()
  77884. * @param name is a string, the name given to the new mesh
  77885. * @param newParent can be any Node object (default `null`)
  77886. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77887. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77888. * @returns a new mesh
  77889. */
  77890. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77891. /**
  77892. * Releases resources associated with this mesh.
  77893. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77894. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77895. */
  77896. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77897. /**
  77898. * Modifies the mesh geometry according to a displacement map.
  77899. * 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.
  77900. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77901. * @param url is a string, the URL from the image file is to be downloaded.
  77902. * @param minHeight is the lower limit of the displacement.
  77903. * @param maxHeight is the upper limit of the displacement.
  77904. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  77905. * @param uvOffset is an optional vector2 used to offset UV.
  77906. * @param uvScale is an optional vector2 used to scale UV.
  77907. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  77908. * @returns the Mesh.
  77909. */
  77910. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77911. /**
  77912. * Modifies the mesh geometry according to a displacementMap buffer.
  77913. * 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.
  77914. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77915. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77916. * @param heightMapWidth is the width of the buffer image.
  77917. * @param heightMapHeight is the height of the buffer image.
  77918. * @param minHeight is the lower limit of the displacement.
  77919. * @param maxHeight is the upper limit of the displacement.
  77920. * @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.
  77921. * @param uvOffset is an optional vector2 used to offset UV.
  77922. * @param uvScale is an optional vector2 used to scale UV.
  77923. * @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.
  77924. * @returns the Mesh.
  77925. */
  77926. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77927. /**
  77928. * Modify the mesh to get a flat shading rendering.
  77929. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77930. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77931. * @returns current mesh
  77932. */
  77933. convertToFlatShadedMesh(): Mesh;
  77934. /**
  77935. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77936. * In other words, more vertices, no more indices and a single bigger VBO.
  77937. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77938. * @returns current mesh
  77939. */
  77940. convertToUnIndexedMesh(): Mesh;
  77941. /**
  77942. * Inverses facet orientations.
  77943. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77944. * @param flipNormals will also inverts the normals
  77945. * @returns current mesh
  77946. */
  77947. flipFaces(flipNormals?: boolean): Mesh;
  77948. /** @hidden */
  77949. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77950. /** @hidden */
  77951. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77952. /**
  77953. * Creates a new InstancedMesh object from the mesh model.
  77954. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77955. * @param name defines the name of the new instance
  77956. * @returns a new InstancedMesh
  77957. */
  77958. createInstance(name: string): InstancedMesh;
  77959. /**
  77960. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77961. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77962. * @returns the current mesh
  77963. */
  77964. synchronizeInstances(): Mesh;
  77965. /**
  77966. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77967. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77968. * This should be used together with the simplification to avoid disappearing triangles.
  77969. * @param successCallback an optional success callback to be called after the optimization finished.
  77970. * @returns the current mesh
  77971. */
  77972. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77973. /**
  77974. * Serialize current mesh
  77975. * @param serializationObject defines the object which will receive the serialization data
  77976. */
  77977. serialize(serializationObject: any): void;
  77978. /** @hidden */
  77979. _syncGeometryWithMorphTargetManager(): void;
  77980. /** @hidden */
  77981. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77982. /**
  77983. * Returns a new Mesh object parsed from the source provided.
  77984. * @param parsedMesh is the source
  77985. * @param scene defines the hosting scene
  77986. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77987. * @returns a new Mesh
  77988. */
  77989. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77990. /**
  77991. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77992. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77993. * @param name defines the name of the mesh to create
  77994. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77995. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77996. * @param closePath creates a seam between the first and the last points of each path of the path array
  77997. * @param offset is taken in account only if the `pathArray` is containing a single path
  77998. * @param scene defines the hosting scene
  77999. * @param updatable defines if the mesh must be flagged as updatable
  78000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78001. * @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)
  78002. * @returns a new Mesh
  78003. */
  78004. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78005. /**
  78006. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78007. * @param name defines the name of the mesh to create
  78008. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78009. * @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
  78010. * @param scene defines the hosting scene
  78011. * @param updatable defines if the mesh must be flagged as updatable
  78012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78013. * @returns a new Mesh
  78014. */
  78015. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78016. /**
  78017. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78018. * @param name defines the name of the mesh to create
  78019. * @param size sets the size (float) of each box side (default 1)
  78020. * @param scene defines the hosting scene
  78021. * @param updatable defines if the mesh must be flagged as updatable
  78022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78023. * @returns a new Mesh
  78024. */
  78025. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78026. /**
  78027. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78028. * @param name defines the name of the mesh to create
  78029. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78030. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78031. * @param scene defines the hosting scene
  78032. * @param updatable defines if the mesh must be flagged as updatable
  78033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78034. * @returns a new Mesh
  78035. */
  78036. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78037. /**
  78038. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78039. * @param name defines the name of the mesh to create
  78040. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78041. * @param diameterTop set the top cap diameter (floats, default 1)
  78042. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78043. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78044. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78045. * @param scene defines the hosting scene
  78046. * @param updatable defines if the mesh must be flagged as updatable
  78047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78048. * @returns a new Mesh
  78049. */
  78050. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78051. /**
  78052. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78053. * @param name defines the name of the mesh to create
  78054. * @param diameter sets the diameter size (float) of the torus (default 1)
  78055. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78056. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78057. * @param scene defines the hosting scene
  78058. * @param updatable defines if the mesh must be flagged as updatable
  78059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78060. * @returns a new Mesh
  78061. */
  78062. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78063. /**
  78064. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78065. * @param name defines the name of the mesh to create
  78066. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78067. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78068. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78069. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78070. * @param p the number of windings on X axis (positive integers, default 2)
  78071. * @param q the number of windings on Y axis (positive integers, default 3)
  78072. * @param scene defines the hosting scene
  78073. * @param updatable defines if the mesh must be flagged as updatable
  78074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78075. * @returns a new Mesh
  78076. */
  78077. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78078. /**
  78079. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78080. * @param name defines the name of the mesh to create
  78081. * @param points is an array successive Vector3
  78082. * @param scene defines the hosting scene
  78083. * @param updatable defines if the mesh must be flagged as updatable
  78084. * @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).
  78085. * @returns a new Mesh
  78086. */
  78087. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78088. /**
  78089. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78090. * @param name defines the name of the mesh to create
  78091. * @param points is an array successive Vector3
  78092. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78093. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78094. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78095. * @param scene defines the hosting scene
  78096. * @param updatable defines if the mesh must be flagged as updatable
  78097. * @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)
  78098. * @returns a new Mesh
  78099. */
  78100. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78101. /**
  78102. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78103. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78104. * 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.
  78105. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78106. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78107. * Remember you can only change the shape positions, not their number when updating a polygon.
  78108. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78109. * @param name defines the name of the mesh to create
  78110. * @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
  78111. * @param scene defines the hosting scene
  78112. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78113. * @param updatable defines if the mesh must be flagged as updatable
  78114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78115. * @param earcutInjection can be used to inject your own earcut reference
  78116. * @returns a new Mesh
  78117. */
  78118. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78119. /**
  78120. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78122. * @param name defines the name of the mesh to create
  78123. * @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
  78124. * @param depth defines the height of extrusion
  78125. * @param scene defines the hosting scene
  78126. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78127. * @param updatable defines if the mesh must be flagged as updatable
  78128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78129. * @param earcutInjection can be used to inject your own earcut reference
  78130. * @returns a new Mesh
  78131. */
  78132. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78133. /**
  78134. * Creates an extruded shape mesh.
  78135. * 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
  78136. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78138. * @param name defines the name of the mesh to create
  78139. * @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
  78140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78141. * @param scale is the value to scale the shape
  78142. * @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
  78143. * @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
  78144. * @param scene defines the hosting scene
  78145. * @param updatable defines if the mesh must be flagged as updatable
  78146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78147. * @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)
  78148. * @returns a new Mesh
  78149. */
  78150. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78151. /**
  78152. * Creates an custom extruded shape mesh.
  78153. * The custom extrusion is a parametric shape.
  78154. * It has no predefined shape. Its final shape will depend on the input parameters.
  78155. * Please consider using the same method from the MeshBuilder class instead
  78156. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78157. * @param name defines the name of the mesh to create
  78158. * @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
  78159. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78160. * @param scaleFunction is a custom Javascript function called on each path point
  78161. * @param rotationFunction is a custom Javascript function called on each path point
  78162. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78163. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78164. * @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
  78165. * @param scene defines the hosting scene
  78166. * @param updatable defines if the mesh must be flagged as updatable
  78167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78168. * @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)
  78169. * @returns a new Mesh
  78170. */
  78171. 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;
  78172. /**
  78173. * Creates lathe mesh.
  78174. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78175. * Please consider using the same method from the MeshBuilder class instead
  78176. * @param name defines the name of the mesh to create
  78177. * @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
  78178. * @param radius is the radius value of the lathe
  78179. * @param tessellation is the side number of the lathe.
  78180. * @param scene defines the hosting scene
  78181. * @param updatable defines if the mesh must be flagged as updatable
  78182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78183. * @returns a new Mesh
  78184. */
  78185. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78186. /**
  78187. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78188. * @param name defines the name of the mesh to create
  78189. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78190. * @param scene defines the hosting scene
  78191. * @param updatable defines if the mesh must be flagged as updatable
  78192. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78193. * @returns a new Mesh
  78194. */
  78195. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78196. /**
  78197. * Creates a ground mesh.
  78198. * Please consider using the same method from the MeshBuilder class instead
  78199. * @param name defines the name of the mesh to create
  78200. * @param width set the width of the ground
  78201. * @param height set the height of the ground
  78202. * @param subdivisions sets the number of subdivisions per side
  78203. * @param scene defines the hosting scene
  78204. * @param updatable defines if the mesh must be flagged as updatable
  78205. * @returns a new Mesh
  78206. */
  78207. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78208. /**
  78209. * Creates a tiled ground mesh.
  78210. * Please consider using the same method from the MeshBuilder class instead
  78211. * @param name defines the name of the mesh to create
  78212. * @param xmin set the ground minimum X coordinate
  78213. * @param zmin set the ground minimum Y coordinate
  78214. * @param xmax set the ground maximum X coordinate
  78215. * @param zmax set the ground maximum Z coordinate
  78216. * @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
  78217. * @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
  78218. * @param scene defines the hosting scene
  78219. * @param updatable defines if the mesh must be flagged as updatable
  78220. * @returns a new Mesh
  78221. */
  78222. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78223. w: number;
  78224. h: number;
  78225. }, precision: {
  78226. w: number;
  78227. h: number;
  78228. }, scene: Scene, updatable?: boolean): Mesh;
  78229. /**
  78230. * Creates a ground mesh from a height map.
  78231. * Please consider using the same method from the MeshBuilder class instead
  78232. * @see http://doc.babylonjs.com/babylon101/height_map
  78233. * @param name defines the name of the mesh to create
  78234. * @param url sets the URL of the height map image resource
  78235. * @param width set the ground width size
  78236. * @param height set the ground height size
  78237. * @param subdivisions sets the number of subdivision per side
  78238. * @param minHeight is the minimum altitude on the ground
  78239. * @param maxHeight is the maximum altitude on the ground
  78240. * @param scene defines the hosting scene
  78241. * @param updatable defines if the mesh must be flagged as updatable
  78242. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78243. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78244. * @returns a new Mesh
  78245. */
  78246. 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;
  78247. /**
  78248. * Creates a tube mesh.
  78249. * The tube is a parametric shape.
  78250. * It has no predefined shape. Its final shape will depend on the input parameters.
  78251. * Please consider using the same method from the MeshBuilder class instead
  78252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78253. * @param name defines the name of the mesh to create
  78254. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78255. * @param radius sets the tube radius size
  78256. * @param tessellation is the number of sides on the tubular surface
  78257. * @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
  78258. * @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
  78259. * @param scene defines the hosting scene
  78260. * @param updatable defines if the mesh must be flagged as updatable
  78261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78262. * @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)
  78263. * @returns a new Mesh
  78264. */
  78265. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78266. (i: number, distance: number): number;
  78267. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78268. /**
  78269. * Creates a polyhedron mesh.
  78270. * Please consider using the same method from the MeshBuilder class instead.
  78271. * * 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
  78272. * * The parameter `size` (positive float, default 1) sets the polygon size
  78273. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78274. * * 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`
  78275. * * 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
  78276. * * 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)`)
  78277. * * 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
  78278. * * 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
  78279. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78280. * * If you create a double-sided mesh, you can choose what parts of 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
  78281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78282. * @param name defines the name of the mesh to create
  78283. * @param options defines the options used to create the mesh
  78284. * @param scene defines the hosting scene
  78285. * @returns a new Mesh
  78286. */
  78287. static CreatePolyhedron(name: string, options: {
  78288. type?: number;
  78289. size?: number;
  78290. sizeX?: number;
  78291. sizeY?: number;
  78292. sizeZ?: number;
  78293. custom?: any;
  78294. faceUV?: Vector4[];
  78295. faceColors?: Color4[];
  78296. updatable?: boolean;
  78297. sideOrientation?: number;
  78298. }, scene: Scene): Mesh;
  78299. /**
  78300. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78301. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78302. * * 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`)
  78303. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78304. * * 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
  78305. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78306. * * If you create a double-sided mesh, you can choose what parts of 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
  78307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78308. * @param name defines the name of the mesh
  78309. * @param options defines the options used to create the mesh
  78310. * @param scene defines the hosting scene
  78311. * @returns a new Mesh
  78312. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78313. */
  78314. static CreateIcoSphere(name: string, options: {
  78315. radius?: number;
  78316. flat?: boolean;
  78317. subdivisions?: number;
  78318. sideOrientation?: number;
  78319. updatable?: boolean;
  78320. }, scene: Scene): Mesh;
  78321. /**
  78322. * Creates a decal mesh.
  78323. * Please consider using the same method from the MeshBuilder class instead.
  78324. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78325. * @param name defines the name of the mesh
  78326. * @param sourceMesh defines the mesh receiving the decal
  78327. * @param position sets the position of the decal in world coordinates
  78328. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78329. * @param size sets the decal scaling
  78330. * @param angle sets the angle to rotate the decal
  78331. * @returns a new Mesh
  78332. */
  78333. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78334. /**
  78335. * Prepare internal position array for software CPU skinning
  78336. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78337. */
  78338. setPositionsForCPUSkinning(): Float32Array;
  78339. /**
  78340. * Prepare internal normal array for software CPU skinning
  78341. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78342. */
  78343. setNormalsForCPUSkinning(): Float32Array;
  78344. /**
  78345. * Updates the vertex buffer by applying transformation from the bones
  78346. * @param skeleton defines the skeleton to apply to current mesh
  78347. * @returns the current mesh
  78348. */
  78349. applySkeleton(skeleton: Skeleton): Mesh;
  78350. /**
  78351. * 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
  78352. * @param meshes defines the list of meshes to scan
  78353. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78354. */
  78355. static MinMax(meshes: AbstractMesh[]): {
  78356. min: Vector3;
  78357. max: Vector3;
  78358. };
  78359. /**
  78360. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78361. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78362. * @returns a vector3
  78363. */
  78364. static Center(meshesOrMinMaxVector: {
  78365. min: Vector3;
  78366. max: Vector3;
  78367. } | AbstractMesh[]): Vector3;
  78368. /**
  78369. * Merge the array of meshes into a single mesh for performance reasons.
  78370. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78371. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78372. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78373. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78374. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78375. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78376. * @returns a new mesh
  78377. */
  78378. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78379. /** @hidden */
  78380. addInstance(instance: InstancedMesh): void;
  78381. /** @hidden */
  78382. removeInstance(instance: InstancedMesh): void;
  78383. }
  78384. }
  78385. declare module BABYLON {
  78386. /**
  78387. * Base class for the main features of a material in Babylon.js
  78388. */
  78389. export class Material implements IAnimatable {
  78390. /**
  78391. * Returns the triangle fill mode
  78392. */
  78393. static readonly TriangleFillMode: number;
  78394. /**
  78395. * Returns the wireframe mode
  78396. */
  78397. static readonly WireFrameFillMode: number;
  78398. /**
  78399. * Returns the point fill mode
  78400. */
  78401. static readonly PointFillMode: number;
  78402. /**
  78403. * Returns the point list draw mode
  78404. */
  78405. static readonly PointListDrawMode: number;
  78406. /**
  78407. * Returns the line list draw mode
  78408. */
  78409. static readonly LineListDrawMode: number;
  78410. /**
  78411. * Returns the line loop draw mode
  78412. */
  78413. static readonly LineLoopDrawMode: number;
  78414. /**
  78415. * Returns the line strip draw mode
  78416. */
  78417. static readonly LineStripDrawMode: number;
  78418. /**
  78419. * Returns the triangle strip draw mode
  78420. */
  78421. static readonly TriangleStripDrawMode: number;
  78422. /**
  78423. * Returns the triangle fan draw mode
  78424. */
  78425. static readonly TriangleFanDrawMode: number;
  78426. /**
  78427. * Stores the clock-wise side orientation
  78428. */
  78429. static readonly ClockWiseSideOrientation: number;
  78430. /**
  78431. * Stores the counter clock-wise side orientation
  78432. */
  78433. static readonly CounterClockWiseSideOrientation: number;
  78434. /**
  78435. * The dirty texture flag value
  78436. */
  78437. static readonly TextureDirtyFlag: number;
  78438. /**
  78439. * The dirty light flag value
  78440. */
  78441. static readonly LightDirtyFlag: number;
  78442. /**
  78443. * The dirty fresnel flag value
  78444. */
  78445. static readonly FresnelDirtyFlag: number;
  78446. /**
  78447. * The dirty attribute flag value
  78448. */
  78449. static readonly AttributesDirtyFlag: number;
  78450. /**
  78451. * The dirty misc flag value
  78452. */
  78453. static readonly MiscDirtyFlag: number;
  78454. /**
  78455. * The all dirty flag value
  78456. */
  78457. static readonly AllDirtyFlag: number;
  78458. /**
  78459. * The ID of the material
  78460. */
  78461. id: string;
  78462. /**
  78463. * Gets or sets the unique id of the material
  78464. */
  78465. uniqueId: number;
  78466. /**
  78467. * The name of the material
  78468. */
  78469. name: string;
  78470. /**
  78471. * Gets or sets user defined metadata
  78472. */
  78473. metadata: any;
  78474. /**
  78475. * For internal use only. Please do not use.
  78476. */
  78477. reservedDataStore: any;
  78478. /**
  78479. * Specifies if the ready state should be checked on each call
  78480. */
  78481. checkReadyOnEveryCall: boolean;
  78482. /**
  78483. * Specifies if the ready state should be checked once
  78484. */
  78485. checkReadyOnlyOnce: boolean;
  78486. /**
  78487. * The state of the material
  78488. */
  78489. state: string;
  78490. /**
  78491. * The alpha value of the material
  78492. */
  78493. protected _alpha: number;
  78494. /**
  78495. * Sets the alpha value of the material
  78496. */
  78497. /**
  78498. * Gets the alpha value of the material
  78499. */
  78500. alpha: number;
  78501. /**
  78502. * Specifies if back face culling is enabled
  78503. */
  78504. protected _backFaceCulling: boolean;
  78505. /**
  78506. * Sets the back-face culling state
  78507. */
  78508. /**
  78509. * Gets the back-face culling state
  78510. */
  78511. backFaceCulling: boolean;
  78512. /**
  78513. * Stores the value for side orientation
  78514. */
  78515. sideOrientation: number;
  78516. /**
  78517. * Callback triggered when the material is compiled
  78518. */
  78519. onCompiled: (effect: Effect) => void;
  78520. /**
  78521. * Callback triggered when an error occurs
  78522. */
  78523. onError: (effect: Effect, errors: string) => void;
  78524. /**
  78525. * Callback triggered to get the render target textures
  78526. */
  78527. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78528. /**
  78529. * Gets a boolean indicating that current material needs to register RTT
  78530. */
  78531. readonly hasRenderTargetTextures: boolean;
  78532. /**
  78533. * Specifies if the material should be serialized
  78534. */
  78535. doNotSerialize: boolean;
  78536. /**
  78537. * @hidden
  78538. */
  78539. _storeEffectOnSubMeshes: boolean;
  78540. /**
  78541. * Stores the animations for the material
  78542. */
  78543. animations: Array<Animation>;
  78544. /**
  78545. * An event triggered when the material is disposed
  78546. */
  78547. onDisposeObservable: Observable<Material>;
  78548. /**
  78549. * An observer which watches for dispose events
  78550. */
  78551. private _onDisposeObserver;
  78552. private _onUnBindObservable;
  78553. /**
  78554. * Called during a dispose event
  78555. */
  78556. onDispose: () => void;
  78557. private _onBindObservable;
  78558. /**
  78559. * An event triggered when the material is bound
  78560. */
  78561. readonly onBindObservable: Observable<AbstractMesh>;
  78562. /**
  78563. * An observer which watches for bind events
  78564. */
  78565. private _onBindObserver;
  78566. /**
  78567. * Called during a bind event
  78568. */
  78569. onBind: (Mesh: AbstractMesh) => void;
  78570. /**
  78571. * An event triggered when the material is unbound
  78572. */
  78573. readonly onUnBindObservable: Observable<Material>;
  78574. /**
  78575. * Stores the value of the alpha mode
  78576. */
  78577. private _alphaMode;
  78578. /**
  78579. * Sets the value of the alpha mode.
  78580. *
  78581. * | Value | Type | Description |
  78582. * | --- | --- | --- |
  78583. * | 0 | ALPHA_DISABLE | |
  78584. * | 1 | ALPHA_ADD | |
  78585. * | 2 | ALPHA_COMBINE | |
  78586. * | 3 | ALPHA_SUBTRACT | |
  78587. * | 4 | ALPHA_MULTIPLY | |
  78588. * | 5 | ALPHA_MAXIMIZED | |
  78589. * | 6 | ALPHA_ONEONE | |
  78590. * | 7 | ALPHA_PREMULTIPLIED | |
  78591. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78592. * | 9 | ALPHA_INTERPOLATE | |
  78593. * | 10 | ALPHA_SCREENMODE | |
  78594. *
  78595. */
  78596. /**
  78597. * Gets the value of the alpha mode
  78598. */
  78599. alphaMode: number;
  78600. /**
  78601. * Stores the state of the need depth pre-pass value
  78602. */
  78603. private _needDepthPrePass;
  78604. /**
  78605. * Sets the need depth pre-pass value
  78606. */
  78607. /**
  78608. * Gets the depth pre-pass value
  78609. */
  78610. needDepthPrePass: boolean;
  78611. /**
  78612. * Specifies if depth writing should be disabled
  78613. */
  78614. disableDepthWrite: boolean;
  78615. /**
  78616. * Specifies if depth writing should be forced
  78617. */
  78618. forceDepthWrite: boolean;
  78619. /**
  78620. * Specifies if there should be a separate pass for culling
  78621. */
  78622. separateCullingPass: boolean;
  78623. /**
  78624. * Stores the state specifing if fog should be enabled
  78625. */
  78626. private _fogEnabled;
  78627. /**
  78628. * Sets the state for enabling fog
  78629. */
  78630. /**
  78631. * Gets the value of the fog enabled state
  78632. */
  78633. fogEnabled: boolean;
  78634. /**
  78635. * Stores the size of points
  78636. */
  78637. pointSize: number;
  78638. /**
  78639. * Stores the z offset value
  78640. */
  78641. zOffset: number;
  78642. /**
  78643. * Gets a value specifying if wireframe mode is enabled
  78644. */
  78645. /**
  78646. * Sets the state of wireframe mode
  78647. */
  78648. wireframe: boolean;
  78649. /**
  78650. * Gets the value specifying if point clouds are enabled
  78651. */
  78652. /**
  78653. * Sets the state of point cloud mode
  78654. */
  78655. pointsCloud: boolean;
  78656. /**
  78657. * Gets the material fill mode
  78658. */
  78659. /**
  78660. * Sets the material fill mode
  78661. */
  78662. fillMode: number;
  78663. /**
  78664. * @hidden
  78665. * Stores the effects for the material
  78666. */
  78667. _effect: Nullable<Effect>;
  78668. /**
  78669. * @hidden
  78670. * Specifies if the material was previously ready
  78671. */
  78672. _wasPreviouslyReady: boolean;
  78673. /**
  78674. * Specifies if uniform buffers should be used
  78675. */
  78676. private _useUBO;
  78677. /**
  78678. * Stores a reference to the scene
  78679. */
  78680. private _scene;
  78681. /**
  78682. * Stores the fill mode state
  78683. */
  78684. private _fillMode;
  78685. /**
  78686. * Specifies if the depth write state should be cached
  78687. */
  78688. private _cachedDepthWriteState;
  78689. /**
  78690. * Stores the uniform buffer
  78691. */
  78692. protected _uniformBuffer: UniformBuffer;
  78693. /** @hidden */
  78694. _indexInSceneMaterialArray: number;
  78695. /** @hidden */
  78696. meshMap: Nullable<{
  78697. [id: string]: AbstractMesh | undefined;
  78698. }>;
  78699. /**
  78700. * Creates a material instance
  78701. * @param name defines the name of the material
  78702. * @param scene defines the scene to reference
  78703. * @param doNotAdd specifies if the material should be added to the scene
  78704. */
  78705. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78706. /**
  78707. * Returns a string representation of the current material
  78708. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78709. * @returns a string with material information
  78710. */
  78711. toString(fullDetails?: boolean): string;
  78712. /**
  78713. * Gets the class name of the material
  78714. * @returns a string with the class name of the material
  78715. */
  78716. getClassName(): string;
  78717. /**
  78718. * Specifies if updates for the material been locked
  78719. */
  78720. readonly isFrozen: boolean;
  78721. /**
  78722. * Locks updates for the material
  78723. */
  78724. freeze(): void;
  78725. /**
  78726. * Unlocks updates for the material
  78727. */
  78728. unfreeze(): void;
  78729. /**
  78730. * Specifies if the material is ready to be used
  78731. * @param mesh defines the mesh to check
  78732. * @param useInstances specifies if instances should be used
  78733. * @returns a boolean indicating if the material is ready to be used
  78734. */
  78735. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78736. /**
  78737. * Specifies that the submesh is ready to be used
  78738. * @param mesh defines the mesh to check
  78739. * @param subMesh defines which submesh to check
  78740. * @param useInstances specifies that instances should be used
  78741. * @returns a boolean indicating that the submesh is ready or not
  78742. */
  78743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78744. /**
  78745. * Returns the material effect
  78746. * @returns the effect associated with the material
  78747. */
  78748. getEffect(): Nullable<Effect>;
  78749. /**
  78750. * Returns the current scene
  78751. * @returns a Scene
  78752. */
  78753. getScene(): Scene;
  78754. /**
  78755. * Specifies if the material will require alpha blending
  78756. * @returns a boolean specifying if alpha blending is needed
  78757. */
  78758. needAlphaBlending(): boolean;
  78759. /**
  78760. * Specifies if the mesh will require alpha blending
  78761. * @param mesh defines the mesh to check
  78762. * @returns a boolean specifying if alpha blending is needed for the mesh
  78763. */
  78764. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78765. /**
  78766. * Specifies if this material should be rendered in alpha test mode
  78767. * @returns a boolean specifying if an alpha test is needed.
  78768. */
  78769. needAlphaTesting(): boolean;
  78770. /**
  78771. * Gets the texture used for the alpha test
  78772. * @returns the texture to use for alpha testing
  78773. */
  78774. getAlphaTestTexture(): Nullable<BaseTexture>;
  78775. /**
  78776. * Marks the material to indicate that it needs to be re-calculated
  78777. */
  78778. markDirty(): void;
  78779. /** @hidden */
  78780. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78781. /**
  78782. * Binds the material to the mesh
  78783. * @param world defines the world transformation matrix
  78784. * @param mesh defines the mesh to bind the material to
  78785. */
  78786. bind(world: Matrix, mesh?: Mesh): void;
  78787. /**
  78788. * Binds the submesh to the material
  78789. * @param world defines the world transformation matrix
  78790. * @param mesh defines the mesh containing the submesh
  78791. * @param subMesh defines the submesh to bind the material to
  78792. */
  78793. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78794. /**
  78795. * Binds the world matrix to the material
  78796. * @param world defines the world transformation matrix
  78797. */
  78798. bindOnlyWorldMatrix(world: Matrix): void;
  78799. /**
  78800. * Binds the scene's uniform buffer to the effect.
  78801. * @param effect defines the effect to bind to the scene uniform buffer
  78802. * @param sceneUbo defines the uniform buffer storing scene data
  78803. */
  78804. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78805. /**
  78806. * Binds the view matrix to the effect
  78807. * @param effect defines the effect to bind the view matrix to
  78808. */
  78809. bindView(effect: Effect): void;
  78810. /**
  78811. * Binds the view projection matrix to the effect
  78812. * @param effect defines the effect to bind the view projection matrix to
  78813. */
  78814. bindViewProjection(effect: Effect): void;
  78815. /**
  78816. * Specifies if material alpha testing should be turned on for the mesh
  78817. * @param mesh defines the mesh to check
  78818. */
  78819. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78820. /**
  78821. * Processes to execute after binding the material to a mesh
  78822. * @param mesh defines the rendered mesh
  78823. */
  78824. protected _afterBind(mesh?: Mesh): void;
  78825. /**
  78826. * Unbinds the material from the mesh
  78827. */
  78828. unbind(): void;
  78829. /**
  78830. * Gets the active textures from the material
  78831. * @returns an array of textures
  78832. */
  78833. getActiveTextures(): BaseTexture[];
  78834. /**
  78835. * Specifies if the material uses a texture
  78836. * @param texture defines the texture to check against the material
  78837. * @returns a boolean specifying if the material uses the texture
  78838. */
  78839. hasTexture(texture: BaseTexture): boolean;
  78840. /**
  78841. * Makes a duplicate of the material, and gives it a new name
  78842. * @param name defines the new name for the duplicated material
  78843. * @returns the cloned material
  78844. */
  78845. clone(name: string): Nullable<Material>;
  78846. /**
  78847. * Gets the meshes bound to the material
  78848. * @returns an array of meshes bound to the material
  78849. */
  78850. getBindedMeshes(): AbstractMesh[];
  78851. /**
  78852. * Force shader compilation
  78853. * @param mesh defines the mesh associated with this material
  78854. * @param onCompiled defines a function to execute once the material is compiled
  78855. * @param options defines the options to configure the compilation
  78856. */
  78857. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78858. clipPlane: boolean;
  78859. }>): void;
  78860. /**
  78861. * Force shader compilation
  78862. * @param mesh defines the mesh that will use this material
  78863. * @param options defines additional options for compiling the shaders
  78864. * @returns a promise that resolves when the compilation completes
  78865. */
  78866. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78867. clipPlane: boolean;
  78868. }>): Promise<void>;
  78869. private static readonly _ImageProcessingDirtyCallBack;
  78870. private static readonly _TextureDirtyCallBack;
  78871. private static readonly _FresnelDirtyCallBack;
  78872. private static readonly _MiscDirtyCallBack;
  78873. private static readonly _LightsDirtyCallBack;
  78874. private static readonly _AttributeDirtyCallBack;
  78875. private static _FresnelAndMiscDirtyCallBack;
  78876. private static _TextureAndMiscDirtyCallBack;
  78877. private static readonly _DirtyCallbackArray;
  78878. private static readonly _RunDirtyCallBacks;
  78879. /**
  78880. * Marks a define in the material to indicate that it needs to be re-computed
  78881. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78882. */
  78883. markAsDirty(flag: number): void;
  78884. /**
  78885. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78886. * @param func defines a function which checks material defines against the submeshes
  78887. */
  78888. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78889. /**
  78890. * Indicates that image processing needs to be re-calculated for all submeshes
  78891. */
  78892. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78893. /**
  78894. * Indicates that textures need to be re-calculated for all submeshes
  78895. */
  78896. protected _markAllSubMeshesAsTexturesDirty(): void;
  78897. /**
  78898. * Indicates that fresnel needs to be re-calculated for all submeshes
  78899. */
  78900. protected _markAllSubMeshesAsFresnelDirty(): void;
  78901. /**
  78902. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78903. */
  78904. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78905. /**
  78906. * Indicates that lights need to be re-calculated for all submeshes
  78907. */
  78908. protected _markAllSubMeshesAsLightsDirty(): void;
  78909. /**
  78910. * Indicates that attributes need to be re-calculated for all submeshes
  78911. */
  78912. protected _markAllSubMeshesAsAttributesDirty(): void;
  78913. /**
  78914. * Indicates that misc needs to be re-calculated for all submeshes
  78915. */
  78916. protected _markAllSubMeshesAsMiscDirty(): void;
  78917. /**
  78918. * Indicates that textures and misc need to be re-calculated for all submeshes
  78919. */
  78920. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78921. /**
  78922. * Disposes the material
  78923. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78924. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78925. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78926. */
  78927. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78928. /** @hidden */
  78929. private releaseVertexArrayObject;
  78930. /**
  78931. * Serializes this material
  78932. * @returns the serialized material object
  78933. */
  78934. serialize(): any;
  78935. /**
  78936. * Creates a material from parsed material data
  78937. * @param parsedMaterial defines parsed material data
  78938. * @param scene defines the hosting scene
  78939. * @param rootUrl defines the root URL to use to load textures
  78940. * @returns a new material
  78941. */
  78942. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78943. }
  78944. }
  78945. declare module BABYLON {
  78946. /**
  78947. * Base class for submeshes
  78948. */
  78949. export class BaseSubMesh {
  78950. /** @hidden */
  78951. _materialDefines: Nullable<MaterialDefines>;
  78952. /** @hidden */
  78953. _materialEffect: Nullable<Effect>;
  78954. /**
  78955. * Gets associated effect
  78956. */
  78957. readonly effect: Nullable<Effect>;
  78958. /**
  78959. * Sets associated effect (effect used to render this submesh)
  78960. * @param effect defines the effect to associate with
  78961. * @param defines defines the set of defines used to compile this effect
  78962. */
  78963. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78964. }
  78965. /**
  78966. * Defines a subdivision inside a mesh
  78967. */
  78968. export class SubMesh extends BaseSubMesh implements ICullable {
  78969. /** the material index to use */
  78970. materialIndex: number;
  78971. /** vertex index start */
  78972. verticesStart: number;
  78973. /** vertices count */
  78974. verticesCount: number;
  78975. /** index start */
  78976. indexStart: number;
  78977. /** indices count */
  78978. indexCount: number;
  78979. /** @hidden */
  78980. _linesIndexCount: number;
  78981. private _mesh;
  78982. private _renderingMesh;
  78983. private _boundingInfo;
  78984. private _linesIndexBuffer;
  78985. /** @hidden */
  78986. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78987. /** @hidden */
  78988. _trianglePlanes: Plane[];
  78989. /** @hidden */
  78990. _lastColliderTransformMatrix: Matrix;
  78991. /** @hidden */
  78992. _renderId: number;
  78993. /** @hidden */
  78994. _alphaIndex: number;
  78995. /** @hidden */
  78996. _distanceToCamera: number;
  78997. /** @hidden */
  78998. _id: number;
  78999. private _currentMaterial;
  79000. /**
  79001. * Add a new submesh to a mesh
  79002. * @param materialIndex defines the material index to use
  79003. * @param verticesStart defines vertex index start
  79004. * @param verticesCount defines vertices count
  79005. * @param indexStart defines index start
  79006. * @param indexCount defines indices count
  79007. * @param mesh defines the parent mesh
  79008. * @param renderingMesh defines an optional rendering mesh
  79009. * @param createBoundingBox defines if bounding box should be created for this submesh
  79010. * @returns the new submesh
  79011. */
  79012. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79013. /**
  79014. * Creates a new submesh
  79015. * @param materialIndex defines the material index to use
  79016. * @param verticesStart defines vertex index start
  79017. * @param verticesCount defines vertices count
  79018. * @param indexStart defines index start
  79019. * @param indexCount defines indices count
  79020. * @param mesh defines the parent mesh
  79021. * @param renderingMesh defines an optional rendering mesh
  79022. * @param createBoundingBox defines if bounding box should be created for this submesh
  79023. */
  79024. constructor(
  79025. /** the material index to use */
  79026. materialIndex: number,
  79027. /** vertex index start */
  79028. verticesStart: number,
  79029. /** vertices count */
  79030. verticesCount: number,
  79031. /** index start */
  79032. indexStart: number,
  79033. /** indices count */
  79034. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79035. /**
  79036. * Returns true if this submesh covers the entire parent mesh
  79037. * @ignorenaming
  79038. */
  79039. readonly IsGlobal: boolean;
  79040. /**
  79041. * Returns the submesh BoudingInfo object
  79042. * @returns current bounding info (or mesh's one if the submesh is global)
  79043. */
  79044. getBoundingInfo(): BoundingInfo;
  79045. /**
  79046. * Sets the submesh BoundingInfo
  79047. * @param boundingInfo defines the new bounding info to use
  79048. * @returns the SubMesh
  79049. */
  79050. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79051. /**
  79052. * Returns the mesh of the current submesh
  79053. * @return the parent mesh
  79054. */
  79055. getMesh(): AbstractMesh;
  79056. /**
  79057. * Returns the rendering mesh of the submesh
  79058. * @returns the rendering mesh (could be different from parent mesh)
  79059. */
  79060. getRenderingMesh(): Mesh;
  79061. /**
  79062. * Returns the submesh material
  79063. * @returns null or the current material
  79064. */
  79065. getMaterial(): Nullable<Material>;
  79066. /**
  79067. * Sets a new updated BoundingInfo object to the submesh
  79068. * @returns the SubMesh
  79069. */
  79070. refreshBoundingInfo(): SubMesh;
  79071. /** @hidden */
  79072. _checkCollision(collider: Collider): boolean;
  79073. /**
  79074. * Updates the submesh BoundingInfo
  79075. * @param world defines the world matrix to use to update the bounding info
  79076. * @returns the submesh
  79077. */
  79078. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79079. /**
  79080. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79081. * @param frustumPlanes defines the frustum planes
  79082. * @returns true if the submesh is intersecting with the frustum
  79083. */
  79084. isInFrustum(frustumPlanes: Plane[]): boolean;
  79085. /**
  79086. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79087. * @param frustumPlanes defines the frustum planes
  79088. * @returns true if the submesh is inside the frustum
  79089. */
  79090. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79091. /**
  79092. * Renders the submesh
  79093. * @param enableAlphaMode defines if alpha needs to be used
  79094. * @returns the submesh
  79095. */
  79096. render(enableAlphaMode: boolean): SubMesh;
  79097. /**
  79098. * @hidden
  79099. */
  79100. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79101. /**
  79102. * Checks if the submesh intersects with a ray
  79103. * @param ray defines the ray to test
  79104. * @returns true is the passed ray intersects the submesh bounding box
  79105. */
  79106. canIntersects(ray: Ray): boolean;
  79107. /**
  79108. * Intersects current submesh with a ray
  79109. * @param ray defines the ray to test
  79110. * @param positions defines mesh's positions array
  79111. * @param indices defines mesh's indices array
  79112. * @param fastCheck defines if only bounding info should be used
  79113. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79114. * @returns intersection info or null if no intersection
  79115. */
  79116. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79117. /** @hidden */
  79118. private _intersectLines;
  79119. /** @hidden */
  79120. private _intersectTriangles;
  79121. /** @hidden */
  79122. _rebuild(): void;
  79123. /**
  79124. * Creates a new submesh from the passed mesh
  79125. * @param newMesh defines the new hosting mesh
  79126. * @param newRenderingMesh defines an optional rendering mesh
  79127. * @returns the new submesh
  79128. */
  79129. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79130. /**
  79131. * Release associated resources
  79132. */
  79133. dispose(): void;
  79134. /**
  79135. * Gets the class name
  79136. * @returns the string "SubMesh".
  79137. */
  79138. getClassName(): string;
  79139. /**
  79140. * Creates a new submesh from indices data
  79141. * @param materialIndex the index of the main mesh material
  79142. * @param startIndex the index where to start the copy in the mesh indices array
  79143. * @param indexCount the number of indices to copy then from the startIndex
  79144. * @param mesh the main mesh to create the submesh from
  79145. * @param renderingMesh the optional rendering mesh
  79146. * @returns a new submesh
  79147. */
  79148. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79149. }
  79150. }
  79151. declare module BABYLON {
  79152. /**
  79153. * Class used to store geometry data (vertex buffers + index buffer)
  79154. */
  79155. export class Geometry implements IGetSetVerticesData {
  79156. /**
  79157. * Gets or sets the ID of the geometry
  79158. */
  79159. id: string;
  79160. /**
  79161. * Gets or sets the unique ID of the geometry
  79162. */
  79163. uniqueId: number;
  79164. /**
  79165. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79166. */
  79167. delayLoadState: number;
  79168. /**
  79169. * Gets the file containing the data to load when running in delay load state
  79170. */
  79171. delayLoadingFile: Nullable<string>;
  79172. /**
  79173. * Callback called when the geometry is updated
  79174. */
  79175. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79176. private _scene;
  79177. private _engine;
  79178. private _meshes;
  79179. private _totalVertices;
  79180. /** @hidden */
  79181. _indices: IndicesArray;
  79182. /** @hidden */
  79183. _vertexBuffers: {
  79184. [key: string]: VertexBuffer;
  79185. };
  79186. private _isDisposed;
  79187. private _extend;
  79188. private _boundingBias;
  79189. /** @hidden */
  79190. _delayInfo: Array<string>;
  79191. private _indexBuffer;
  79192. private _indexBufferIsUpdatable;
  79193. /** @hidden */
  79194. _boundingInfo: Nullable<BoundingInfo>;
  79195. /** @hidden */
  79196. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79197. /** @hidden */
  79198. _softwareSkinningFrameId: number;
  79199. private _vertexArrayObjects;
  79200. private _updatable;
  79201. /** @hidden */
  79202. _positions: Nullable<Vector3[]>;
  79203. /**
  79204. * 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
  79205. */
  79206. /**
  79207. * 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
  79208. */
  79209. boundingBias: Vector2;
  79210. /**
  79211. * Static function used to attach a new empty geometry to a mesh
  79212. * @param mesh defines the mesh to attach the geometry to
  79213. * @returns the new Geometry
  79214. */
  79215. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79216. /**
  79217. * Creates a new geometry
  79218. * @param id defines the unique ID
  79219. * @param scene defines the hosting scene
  79220. * @param vertexData defines the VertexData used to get geometry data
  79221. * @param updatable defines if geometry must be updatable (false by default)
  79222. * @param mesh defines the mesh that will be associated with the geometry
  79223. */
  79224. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79225. /**
  79226. * Gets the current extend of the geometry
  79227. */
  79228. readonly extend: {
  79229. minimum: Vector3;
  79230. maximum: Vector3;
  79231. };
  79232. /**
  79233. * Gets the hosting scene
  79234. * @returns the hosting Scene
  79235. */
  79236. getScene(): Scene;
  79237. /**
  79238. * Gets the hosting engine
  79239. * @returns the hosting Engine
  79240. */
  79241. getEngine(): Engine;
  79242. /**
  79243. * Defines if the geometry is ready to use
  79244. * @returns true if the geometry is ready to be used
  79245. */
  79246. isReady(): boolean;
  79247. /**
  79248. * Gets a value indicating that the geometry should not be serialized
  79249. */
  79250. readonly doNotSerialize: boolean;
  79251. /** @hidden */
  79252. _rebuild(): void;
  79253. /**
  79254. * Affects all geometry data in one call
  79255. * @param vertexData defines the geometry data
  79256. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79257. */
  79258. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79259. /**
  79260. * Set specific vertex data
  79261. * @param kind defines the data kind (Position, normal, etc...)
  79262. * @param data defines the vertex data to use
  79263. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79264. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79265. */
  79266. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79267. /**
  79268. * Removes a specific vertex data
  79269. * @param kind defines the data kind (Position, normal, etc...)
  79270. */
  79271. removeVerticesData(kind: string): void;
  79272. /**
  79273. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79274. * @param buffer defines the vertex buffer to use
  79275. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79276. */
  79277. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79278. /**
  79279. * Update a specific vertex buffer
  79280. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79281. * It will do nothing if the buffer is not updatable
  79282. * @param kind defines the data kind (Position, normal, etc...)
  79283. * @param data defines the data to use
  79284. * @param offset defines the offset in the target buffer where to store the data
  79285. * @param useBytes set to true if the offset is in bytes
  79286. */
  79287. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79288. /**
  79289. * Update a specific vertex buffer
  79290. * This function will create a new buffer if the current one is not updatable
  79291. * @param kind defines the data kind (Position, normal, etc...)
  79292. * @param data defines the data to use
  79293. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79294. */
  79295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79296. private _updateBoundingInfo;
  79297. /** @hidden */
  79298. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79299. /**
  79300. * Gets total number of vertices
  79301. * @returns the total number of vertices
  79302. */
  79303. getTotalVertices(): number;
  79304. /**
  79305. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79306. * @param kind defines the data kind (Position, normal, etc...)
  79307. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79309. * @returns a float array containing vertex data
  79310. */
  79311. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79312. /**
  79313. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79314. * @param kind defines the data kind (Position, normal, etc...)
  79315. * @returns true if the vertex buffer with the specified kind is updatable
  79316. */
  79317. isVertexBufferUpdatable(kind: string): boolean;
  79318. /**
  79319. * Gets a specific vertex buffer
  79320. * @param kind defines the data kind (Position, normal, etc...)
  79321. * @returns a VertexBuffer
  79322. */
  79323. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79324. /**
  79325. * Returns all vertex buffers
  79326. * @return an object holding all vertex buffers indexed by kind
  79327. */
  79328. getVertexBuffers(): Nullable<{
  79329. [key: string]: VertexBuffer;
  79330. }>;
  79331. /**
  79332. * Gets a boolean indicating if specific vertex buffer is present
  79333. * @param kind defines the data kind (Position, normal, etc...)
  79334. * @returns true if data is present
  79335. */
  79336. isVerticesDataPresent(kind: string): boolean;
  79337. /**
  79338. * Gets a list of all attached data kinds (Position, normal, etc...)
  79339. * @returns a list of string containing all kinds
  79340. */
  79341. getVerticesDataKinds(): string[];
  79342. /**
  79343. * Update index buffer
  79344. * @param indices defines the indices to store in the index buffer
  79345. * @param offset defines the offset in the target buffer where to store the data
  79346. */
  79347. updateIndices(indices: IndicesArray, offset?: number): void;
  79348. /**
  79349. * Creates a new index buffer
  79350. * @param indices defines the indices to store in the index buffer
  79351. * @param totalVertices defines the total number of vertices (could be null)
  79352. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79353. */
  79354. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79355. /**
  79356. * Return the total number of indices
  79357. * @returns the total number of indices
  79358. */
  79359. getTotalIndices(): number;
  79360. /**
  79361. * Gets the index buffer array
  79362. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79363. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79364. * @returns the index buffer array
  79365. */
  79366. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79367. /**
  79368. * Gets the index buffer
  79369. * @return the index buffer
  79370. */
  79371. getIndexBuffer(): Nullable<WebGLBuffer>;
  79372. /** @hidden */
  79373. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79374. /**
  79375. * Release the associated resources for a specific mesh
  79376. * @param mesh defines the source mesh
  79377. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79378. */
  79379. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79380. /**
  79381. * Apply current geometry to a given mesh
  79382. * @param mesh defines the mesh to apply geometry to
  79383. */
  79384. applyToMesh(mesh: Mesh): void;
  79385. private _updateExtend;
  79386. private _applyToMesh;
  79387. private notifyUpdate;
  79388. /**
  79389. * Load the geometry if it was flagged as delay loaded
  79390. * @param scene defines the hosting scene
  79391. * @param onLoaded defines a callback called when the geometry is loaded
  79392. */
  79393. load(scene: Scene, onLoaded?: () => void): void;
  79394. private _queueLoad;
  79395. /**
  79396. * Invert the geometry to move from a right handed system to a left handed one.
  79397. */
  79398. toLeftHanded(): void;
  79399. /** @hidden */
  79400. _resetPointsArrayCache(): void;
  79401. /** @hidden */
  79402. _generatePointsArray(): boolean;
  79403. /**
  79404. * Gets a value indicating if the geometry is disposed
  79405. * @returns true if the geometry was disposed
  79406. */
  79407. isDisposed(): boolean;
  79408. private _disposeVertexArrayObjects;
  79409. /**
  79410. * Free all associated resources
  79411. */
  79412. dispose(): void;
  79413. /**
  79414. * Clone the current geometry into a new geometry
  79415. * @param id defines the unique ID of the new geometry
  79416. * @returns a new geometry object
  79417. */
  79418. copy(id: string): Geometry;
  79419. /**
  79420. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79421. * @return a JSON representation of the current geometry data (without the vertices data)
  79422. */
  79423. serialize(): any;
  79424. private toNumberArray;
  79425. /**
  79426. * Serialize all vertices data into a JSON oject
  79427. * @returns a JSON representation of the current geometry data
  79428. */
  79429. serializeVerticeData(): any;
  79430. /**
  79431. * Extracts a clone of a mesh geometry
  79432. * @param mesh defines the source mesh
  79433. * @param id defines the unique ID of the new geometry object
  79434. * @returns the new geometry object
  79435. */
  79436. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79437. /**
  79438. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79439. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79440. * Be aware Math.random() could cause collisions, but:
  79441. * "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"
  79442. * @returns a string containing a new GUID
  79443. */
  79444. static RandomId(): string;
  79445. /** @hidden */
  79446. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79447. private static _CleanMatricesWeights;
  79448. /**
  79449. * Create a new geometry from persisted data (Using .babylon file format)
  79450. * @param parsedVertexData defines the persisted data
  79451. * @param scene defines the hosting scene
  79452. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79453. * @returns the new geometry object
  79454. */
  79455. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79456. }
  79457. }
  79458. declare module BABYLON {
  79459. /**
  79460. * Define an interface for all classes that will get and set the data on vertices
  79461. */
  79462. export interface IGetSetVerticesData {
  79463. /**
  79464. * Gets a boolean indicating if specific vertex data is present
  79465. * @param kind defines the vertex data kind to use
  79466. * @returns true is data kind is present
  79467. */
  79468. isVerticesDataPresent(kind: string): boolean;
  79469. /**
  79470. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79471. * @param kind defines the data kind (Position, normal, etc...)
  79472. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79473. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79474. * @returns a float array containing vertex data
  79475. */
  79476. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79477. /**
  79478. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79479. * @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.
  79480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79481. * @returns the indices array or an empty array if the mesh has no geometry
  79482. */
  79483. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79484. /**
  79485. * Set specific vertex data
  79486. * @param kind defines the data kind (Position, normal, etc...)
  79487. * @param data defines the vertex data to use
  79488. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79489. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79490. */
  79491. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79492. /**
  79493. * Update a specific associated vertex buffer
  79494. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79495. * - VertexBuffer.PositionKind
  79496. * - VertexBuffer.UVKind
  79497. * - VertexBuffer.UV2Kind
  79498. * - VertexBuffer.UV3Kind
  79499. * - VertexBuffer.UV4Kind
  79500. * - VertexBuffer.UV5Kind
  79501. * - VertexBuffer.UV6Kind
  79502. * - VertexBuffer.ColorKind
  79503. * - VertexBuffer.MatricesIndicesKind
  79504. * - VertexBuffer.MatricesIndicesExtraKind
  79505. * - VertexBuffer.MatricesWeightsKind
  79506. * - VertexBuffer.MatricesWeightsExtraKind
  79507. * @param data defines the data source
  79508. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79509. * @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)
  79510. */
  79511. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79512. /**
  79513. * Creates a new index buffer
  79514. * @param indices defines the indices to store in the index buffer
  79515. * @param totalVertices defines the total number of vertices (could be null)
  79516. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79517. */
  79518. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79519. }
  79520. /**
  79521. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79522. */
  79523. export class VertexData {
  79524. /**
  79525. * Mesh side orientation : usually the external or front surface
  79526. */
  79527. static readonly FRONTSIDE: number;
  79528. /**
  79529. * Mesh side orientation : usually the internal or back surface
  79530. */
  79531. static readonly BACKSIDE: number;
  79532. /**
  79533. * Mesh side orientation : both internal and external or front and back surfaces
  79534. */
  79535. static readonly DOUBLESIDE: number;
  79536. /**
  79537. * Mesh side orientation : by default, `FRONTSIDE`
  79538. */
  79539. static readonly DEFAULTSIDE: number;
  79540. /**
  79541. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79542. */
  79543. positions: Nullable<FloatArray>;
  79544. /**
  79545. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79546. */
  79547. normals: Nullable<FloatArray>;
  79548. /**
  79549. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79550. */
  79551. tangents: Nullable<FloatArray>;
  79552. /**
  79553. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79554. */
  79555. uvs: Nullable<FloatArray>;
  79556. /**
  79557. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79558. */
  79559. uvs2: Nullable<FloatArray>;
  79560. /**
  79561. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79562. */
  79563. uvs3: Nullable<FloatArray>;
  79564. /**
  79565. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79566. */
  79567. uvs4: Nullable<FloatArray>;
  79568. /**
  79569. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79570. */
  79571. uvs5: Nullable<FloatArray>;
  79572. /**
  79573. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79574. */
  79575. uvs6: Nullable<FloatArray>;
  79576. /**
  79577. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79578. */
  79579. colors: Nullable<FloatArray>;
  79580. /**
  79581. * 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).
  79582. */
  79583. matricesIndices: Nullable<FloatArray>;
  79584. /**
  79585. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79586. */
  79587. matricesWeights: Nullable<FloatArray>;
  79588. /**
  79589. * An array extending the number of possible indices
  79590. */
  79591. matricesIndicesExtra: Nullable<FloatArray>;
  79592. /**
  79593. * An array extending the number of possible weights when the number of indices is extended
  79594. */
  79595. matricesWeightsExtra: Nullable<FloatArray>;
  79596. /**
  79597. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79598. */
  79599. indices: Nullable<IndicesArray>;
  79600. /**
  79601. * Uses the passed data array to set the set the values for the specified kind of data
  79602. * @param data a linear array of floating numbers
  79603. * @param kind the type of data that is being set, eg positions, colors etc
  79604. */
  79605. set(data: FloatArray, kind: string): void;
  79606. /**
  79607. * Associates the vertexData to the passed Mesh.
  79608. * Sets it as updatable or not (default `false`)
  79609. * @param mesh the mesh the vertexData is applied to
  79610. * @param updatable when used and having the value true allows new data to update the vertexData
  79611. * @returns the VertexData
  79612. */
  79613. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79614. /**
  79615. * Associates the vertexData to the passed Geometry.
  79616. * Sets it as updatable or not (default `false`)
  79617. * @param geometry the geometry the vertexData is applied to
  79618. * @param updatable when used and having the value true allows new data to update the vertexData
  79619. * @returns VertexData
  79620. */
  79621. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79622. /**
  79623. * Updates the associated mesh
  79624. * @param mesh the mesh to be updated
  79625. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79626. * @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
  79627. * @returns VertexData
  79628. */
  79629. updateMesh(mesh: Mesh): VertexData;
  79630. /**
  79631. * Updates the associated geometry
  79632. * @param geometry the geometry to be updated
  79633. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79634. * @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
  79635. * @returns VertexData.
  79636. */
  79637. updateGeometry(geometry: Geometry): VertexData;
  79638. private _applyTo;
  79639. private _update;
  79640. /**
  79641. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79642. * @param matrix the transforming matrix
  79643. * @returns the VertexData
  79644. */
  79645. transform(matrix: Matrix): VertexData;
  79646. /**
  79647. * Merges the passed VertexData into the current one
  79648. * @param other the VertexData to be merged into the current one
  79649. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79650. * @returns the modified VertexData
  79651. */
  79652. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79653. private _mergeElement;
  79654. private _validate;
  79655. /**
  79656. * Serializes the VertexData
  79657. * @returns a serialized object
  79658. */
  79659. serialize(): any;
  79660. /**
  79661. * Extracts the vertexData from a mesh
  79662. * @param mesh the mesh from which to extract the VertexData
  79663. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79664. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79665. * @returns the object VertexData associated to the passed mesh
  79666. */
  79667. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79668. /**
  79669. * Extracts the vertexData from the geometry
  79670. * @param geometry the geometry from which to extract the VertexData
  79671. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79672. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79673. * @returns the object VertexData associated to the passed mesh
  79674. */
  79675. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79676. private static _ExtractFrom;
  79677. /**
  79678. * Creates the VertexData for a Ribbon
  79679. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79680. * * pathArray array of paths, each of which an array of successive Vector3
  79681. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79682. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79683. * * 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
  79684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79685. * * 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)
  79686. * * 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)
  79687. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79688. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79689. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79690. * @returns the VertexData of the ribbon
  79691. */
  79692. static CreateRibbon(options: {
  79693. pathArray: Vector3[][];
  79694. closeArray?: boolean;
  79695. closePath?: boolean;
  79696. offset?: number;
  79697. sideOrientation?: number;
  79698. frontUVs?: Vector4;
  79699. backUVs?: Vector4;
  79700. invertUV?: boolean;
  79701. uvs?: Vector2[];
  79702. colors?: Color4[];
  79703. }): VertexData;
  79704. /**
  79705. * Creates the VertexData for a box
  79706. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79707. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79708. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79709. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79710. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79711. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79712. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79714. * * 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)
  79715. * * 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)
  79716. * @returns the VertexData of the box
  79717. */
  79718. static CreateBox(options: {
  79719. size?: number;
  79720. width?: number;
  79721. height?: number;
  79722. depth?: number;
  79723. faceUV?: Vector4[];
  79724. faceColors?: Color4[];
  79725. sideOrientation?: number;
  79726. frontUVs?: Vector4;
  79727. backUVs?: Vector4;
  79728. }): VertexData;
  79729. /**
  79730. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79731. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79732. * * segments sets the number of horizontal strips optional, default 32
  79733. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79734. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79735. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79736. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79737. * * 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
  79738. * * 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
  79739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79740. * * 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)
  79741. * * 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)
  79742. * @returns the VertexData of the ellipsoid
  79743. */
  79744. static CreateSphere(options: {
  79745. segments?: number;
  79746. diameter?: number;
  79747. diameterX?: number;
  79748. diameterY?: number;
  79749. diameterZ?: number;
  79750. arc?: number;
  79751. slice?: number;
  79752. sideOrientation?: number;
  79753. frontUVs?: Vector4;
  79754. backUVs?: Vector4;
  79755. }): VertexData;
  79756. /**
  79757. * Creates the VertexData for a cylinder, cone or prism
  79758. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79759. * * height sets the height (y direction) of the cylinder, optional, default 2
  79760. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79761. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79762. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79763. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79764. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79765. * * 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
  79766. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79767. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79768. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79769. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79770. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79771. * * 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)
  79772. * * 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)
  79773. * @returns the VertexData of the cylinder, cone or prism
  79774. */
  79775. static CreateCylinder(options: {
  79776. height?: number;
  79777. diameterTop?: number;
  79778. diameterBottom?: number;
  79779. diameter?: number;
  79780. tessellation?: number;
  79781. subdivisions?: number;
  79782. arc?: number;
  79783. faceColors?: Color4[];
  79784. faceUV?: Vector4[];
  79785. hasRings?: boolean;
  79786. enclose?: boolean;
  79787. sideOrientation?: number;
  79788. frontUVs?: Vector4;
  79789. backUVs?: Vector4;
  79790. }): VertexData;
  79791. /**
  79792. * Creates the VertexData for a torus
  79793. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79794. * * diameter the diameter of the torus, optional default 1
  79795. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79796. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79798. * * 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)
  79799. * * 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)
  79800. * @returns the VertexData of the torus
  79801. */
  79802. static CreateTorus(options: {
  79803. diameter?: number;
  79804. thickness?: number;
  79805. tessellation?: number;
  79806. sideOrientation?: number;
  79807. frontUVs?: Vector4;
  79808. backUVs?: Vector4;
  79809. }): VertexData;
  79810. /**
  79811. * Creates the VertexData of the LineSystem
  79812. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79813. * - lines an array of lines, each line being an array of successive Vector3
  79814. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79815. * @returns the VertexData of the LineSystem
  79816. */
  79817. static CreateLineSystem(options: {
  79818. lines: Vector3[][];
  79819. colors?: Nullable<Color4[][]>;
  79820. }): VertexData;
  79821. /**
  79822. * Create the VertexData for a DashedLines
  79823. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79824. * - points an array successive Vector3
  79825. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79826. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79827. * - dashNb the intended total number of dashes, optional, default 200
  79828. * @returns the VertexData for the DashedLines
  79829. */
  79830. static CreateDashedLines(options: {
  79831. points: Vector3[];
  79832. dashSize?: number;
  79833. gapSize?: number;
  79834. dashNb?: number;
  79835. }): VertexData;
  79836. /**
  79837. * Creates the VertexData for a Ground
  79838. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79839. * - width the width (x direction) of the ground, optional, default 1
  79840. * - height the height (z direction) of the ground, optional, default 1
  79841. * - subdivisions the number of subdivisions per side, optional, default 1
  79842. * @returns the VertexData of the Ground
  79843. */
  79844. static CreateGround(options: {
  79845. width?: number;
  79846. height?: number;
  79847. subdivisions?: number;
  79848. subdivisionsX?: number;
  79849. subdivisionsY?: number;
  79850. }): VertexData;
  79851. /**
  79852. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79853. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79854. * * xmin the ground minimum X coordinate, optional, default -1
  79855. * * zmin the ground minimum Z coordinate, optional, default -1
  79856. * * xmax the ground maximum X coordinate, optional, default 1
  79857. * * zmax the ground maximum Z coordinate, optional, default 1
  79858. * * 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}
  79859. * * 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}
  79860. * @returns the VertexData of the TiledGround
  79861. */
  79862. static CreateTiledGround(options: {
  79863. xmin: number;
  79864. zmin: number;
  79865. xmax: number;
  79866. zmax: number;
  79867. subdivisions?: {
  79868. w: number;
  79869. h: number;
  79870. };
  79871. precision?: {
  79872. w: number;
  79873. h: number;
  79874. };
  79875. }): VertexData;
  79876. /**
  79877. * Creates the VertexData of the Ground designed from a heightmap
  79878. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79879. * * width the width (x direction) of the ground
  79880. * * height the height (z direction) of the ground
  79881. * * subdivisions the number of subdivisions per side
  79882. * * minHeight the minimum altitude on the ground, optional, default 0
  79883. * * maxHeight the maximum altitude on the ground, optional default 1
  79884. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79885. * * buffer the array holding the image color data
  79886. * * bufferWidth the width of image
  79887. * * bufferHeight the height of image
  79888. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79889. * @returns the VertexData of the Ground designed from a heightmap
  79890. */
  79891. static CreateGroundFromHeightMap(options: {
  79892. width: number;
  79893. height: number;
  79894. subdivisions: number;
  79895. minHeight: number;
  79896. maxHeight: number;
  79897. colorFilter: Color3;
  79898. buffer: Uint8Array;
  79899. bufferWidth: number;
  79900. bufferHeight: number;
  79901. alphaFilter: number;
  79902. }): VertexData;
  79903. /**
  79904. * Creates the VertexData for a Plane
  79905. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79906. * * size sets the width and height of the plane to the value of size, optional default 1
  79907. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79908. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79910. * * 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)
  79911. * * 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)
  79912. * @returns the VertexData of the box
  79913. */
  79914. static CreatePlane(options: {
  79915. size?: number;
  79916. width?: number;
  79917. height?: number;
  79918. sideOrientation?: number;
  79919. frontUVs?: Vector4;
  79920. backUVs?: Vector4;
  79921. }): VertexData;
  79922. /**
  79923. * Creates the VertexData of the Disc or regular Polygon
  79924. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79925. * * radius the radius of the disc, optional default 0.5
  79926. * * tessellation the number of polygon sides, optional, default 64
  79927. * * 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
  79928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79929. * * 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)
  79930. * * 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)
  79931. * @returns the VertexData of the box
  79932. */
  79933. static CreateDisc(options: {
  79934. radius?: number;
  79935. tessellation?: number;
  79936. arc?: number;
  79937. sideOrientation?: number;
  79938. frontUVs?: Vector4;
  79939. backUVs?: Vector4;
  79940. }): VertexData;
  79941. /**
  79942. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79943. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79944. * @param polygon a mesh built from polygonTriangulation.build()
  79945. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79946. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79947. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79948. * @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)
  79949. * @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)
  79950. * @returns the VertexData of the Polygon
  79951. */
  79952. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79953. /**
  79954. * Creates the VertexData of the IcoSphere
  79955. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79956. * * radius the radius of the IcoSphere, optional default 1
  79957. * * radiusX allows stretching in the x direction, optional, default radius
  79958. * * radiusY allows stretching in the y direction, optional, default radius
  79959. * * radiusZ allows stretching in the z direction, optional, default radius
  79960. * * flat when true creates a flat shaded mesh, optional, default true
  79961. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79963. * * 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)
  79964. * * 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)
  79965. * @returns the VertexData of the IcoSphere
  79966. */
  79967. static CreateIcoSphere(options: {
  79968. radius?: number;
  79969. radiusX?: number;
  79970. radiusY?: number;
  79971. radiusZ?: number;
  79972. flat?: boolean;
  79973. subdivisions?: number;
  79974. sideOrientation?: number;
  79975. frontUVs?: Vector4;
  79976. backUVs?: Vector4;
  79977. }): VertexData;
  79978. /**
  79979. * Creates the VertexData for a Polyhedron
  79980. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79981. * * type provided types are:
  79982. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79983. * * 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)
  79984. * * size the size of the IcoSphere, optional default 1
  79985. * * sizeX allows stretching in the x direction, optional, default size
  79986. * * sizeY allows stretching in the y direction, optional, default size
  79987. * * sizeZ allows stretching in the z direction, optional, default size
  79988. * * 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
  79989. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79990. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79991. * * flat when true creates a flat shaded mesh, optional, default true
  79992. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79994. * * 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)
  79995. * * 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)
  79996. * @returns the VertexData of the Polyhedron
  79997. */
  79998. static CreatePolyhedron(options: {
  79999. type?: number;
  80000. size?: number;
  80001. sizeX?: number;
  80002. sizeY?: number;
  80003. sizeZ?: number;
  80004. custom?: any;
  80005. faceUV?: Vector4[];
  80006. faceColors?: Color4[];
  80007. flat?: boolean;
  80008. sideOrientation?: number;
  80009. frontUVs?: Vector4;
  80010. backUVs?: Vector4;
  80011. }): VertexData;
  80012. /**
  80013. * Creates the VertexData for a TorusKnot
  80014. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80015. * * radius the radius of the torus knot, optional, default 2
  80016. * * tube the thickness of the tube, optional, default 0.5
  80017. * * radialSegments the number of sides on each tube segments, optional, default 32
  80018. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80019. * * p the number of windings around the z axis, optional, default 2
  80020. * * q the number of windings around the x axis, optional, default 3
  80021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80022. * * 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)
  80023. * * 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)
  80024. * @returns the VertexData of the Torus Knot
  80025. */
  80026. static CreateTorusKnot(options: {
  80027. radius?: number;
  80028. tube?: number;
  80029. radialSegments?: number;
  80030. tubularSegments?: number;
  80031. p?: number;
  80032. q?: number;
  80033. sideOrientation?: number;
  80034. frontUVs?: Vector4;
  80035. backUVs?: Vector4;
  80036. }): VertexData;
  80037. /**
  80038. * Compute normals for given positions and indices
  80039. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80040. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80041. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80042. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80043. * * facetNormals : optional array of facet normals (vector3)
  80044. * * facetPositions : optional array of facet positions (vector3)
  80045. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80046. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80047. * * bInfo : optional bounding info, required for facetPartitioning computation
  80048. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80049. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80050. * * useRightHandedSystem: optional boolean to for right handed system computation
  80051. * * depthSort : optional boolean to enable the facet depth sort computation
  80052. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80053. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80054. */
  80055. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80056. facetNormals?: any;
  80057. facetPositions?: any;
  80058. facetPartitioning?: any;
  80059. ratio?: number;
  80060. bInfo?: any;
  80061. bbSize?: Vector3;
  80062. subDiv?: any;
  80063. useRightHandedSystem?: boolean;
  80064. depthSort?: boolean;
  80065. distanceTo?: Vector3;
  80066. depthSortedFacets?: any;
  80067. }): void;
  80068. /** @hidden */
  80069. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80070. /**
  80071. * Applies VertexData created from the imported parameters to the geometry
  80072. * @param parsedVertexData the parsed data from an imported file
  80073. * @param geometry the geometry to apply the VertexData to
  80074. */
  80075. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80076. }
  80077. }
  80078. declare module BABYLON {
  80079. /**
  80080. * Class containing static functions to help procedurally build meshes
  80081. */
  80082. export class DiscBuilder {
  80083. /**
  80084. * Creates a plane polygonal mesh. By default, this is a disc
  80085. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80086. * * 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
  80087. * * 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
  80088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80089. * * If you create a double-sided mesh, you can choose what parts of 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
  80090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80091. * @param name defines the name of the mesh
  80092. * @param options defines the options used to create the mesh
  80093. * @param scene defines the hosting scene
  80094. * @returns the plane polygonal mesh
  80095. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80096. */
  80097. static CreateDisc(name: string, options: {
  80098. radius?: number;
  80099. tessellation?: number;
  80100. arc?: number;
  80101. updatable?: boolean;
  80102. sideOrientation?: number;
  80103. frontUVs?: Vector4;
  80104. backUVs?: Vector4;
  80105. }, scene?: Nullable<Scene>): Mesh;
  80106. }
  80107. }
  80108. declare module BABYLON {
  80109. /**
  80110. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80111. *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.
  80112. * The SPS is also a particle system. It provides some methods to manage the particles.
  80113. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80114. *
  80115. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80116. */
  80117. export class SolidParticleSystem implements IDisposable {
  80118. /**
  80119. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80120. * Example : var p = SPS.particles[i];
  80121. */
  80122. particles: SolidParticle[];
  80123. /**
  80124. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80125. */
  80126. nbParticles: number;
  80127. /**
  80128. * If the particles must ever face the camera (default false). Useful for planar particles.
  80129. */
  80130. billboard: boolean;
  80131. /**
  80132. * Recompute normals when adding a shape
  80133. */
  80134. recomputeNormals: boolean;
  80135. /**
  80136. * This a counter ofr your own usage. It's not set by any SPS functions.
  80137. */
  80138. counter: number;
  80139. /**
  80140. * The SPS name. This name is also given to the underlying mesh.
  80141. */
  80142. name: string;
  80143. /**
  80144. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80145. */
  80146. mesh: Mesh;
  80147. /**
  80148. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80149. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80150. */
  80151. vars: any;
  80152. /**
  80153. * This array is populated when the SPS is set as 'pickable'.
  80154. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80155. * Each element of this array is an object `{idx: int, faceId: int}`.
  80156. * `idx` is the picked particle index in the `SPS.particles` array
  80157. * `faceId` is the picked face index counted within this particle.
  80158. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80159. */
  80160. pickedParticles: {
  80161. idx: number;
  80162. faceId: number;
  80163. }[];
  80164. /**
  80165. * This array is populated when `enableDepthSort` is set to true.
  80166. * Each element of this array is an instance of the class DepthSortedParticle.
  80167. */
  80168. depthSortedParticles: DepthSortedParticle[];
  80169. /**
  80170. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80171. * @hidden
  80172. */
  80173. _bSphereOnly: boolean;
  80174. /**
  80175. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80176. * @hidden
  80177. */
  80178. _bSphereRadiusFactor: number;
  80179. private _scene;
  80180. private _positions;
  80181. private _indices;
  80182. private _normals;
  80183. private _colors;
  80184. private _uvs;
  80185. private _indices32;
  80186. private _positions32;
  80187. private _normals32;
  80188. private _fixedNormal32;
  80189. private _colors32;
  80190. private _uvs32;
  80191. private _index;
  80192. private _updatable;
  80193. private _pickable;
  80194. private _isVisibilityBoxLocked;
  80195. private _alwaysVisible;
  80196. private _depthSort;
  80197. private _shapeCounter;
  80198. private _copy;
  80199. private _color;
  80200. private _computeParticleColor;
  80201. private _computeParticleTexture;
  80202. private _computeParticleRotation;
  80203. private _computeParticleVertex;
  80204. private _computeBoundingBox;
  80205. private _depthSortParticles;
  80206. private _camera;
  80207. private _mustUnrotateFixedNormals;
  80208. private _particlesIntersect;
  80209. private _needs32Bits;
  80210. /**
  80211. * Creates a SPS (Solid Particle System) object.
  80212. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80213. * @param scene (Scene) is the scene in which the SPS is added.
  80214. * @param options defines the options of the sps e.g.
  80215. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80216. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80217. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80218. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80219. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80220. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80221. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80222. */
  80223. constructor(name: string, scene: Scene, options?: {
  80224. updatable?: boolean;
  80225. isPickable?: boolean;
  80226. enableDepthSort?: boolean;
  80227. particleIntersection?: boolean;
  80228. boundingSphereOnly?: boolean;
  80229. bSphereRadiusFactor?: number;
  80230. });
  80231. /**
  80232. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80233. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80234. * @returns the created mesh
  80235. */
  80236. buildMesh(): Mesh;
  80237. /**
  80238. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80239. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80240. * Thus the particles generated from `digest()` have their property `position` set yet.
  80241. * @param mesh ( Mesh ) is the mesh to be digested
  80242. * @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
  80243. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80244. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80245. * @returns the current SPS
  80246. */
  80247. digest(mesh: Mesh, options?: {
  80248. facetNb?: number;
  80249. number?: number;
  80250. delta?: number;
  80251. }): SolidParticleSystem;
  80252. private _unrotateFixedNormals;
  80253. private _resetCopy;
  80254. private _meshBuilder;
  80255. private _posToShape;
  80256. private _uvsToShapeUV;
  80257. private _addParticle;
  80258. /**
  80259. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80260. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80261. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80262. * @param nb (positive integer) the number of particles to be created from this model
  80263. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80264. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80265. * @returns the number of shapes in the system
  80266. */
  80267. addShape(mesh: Mesh, nb: number, options?: {
  80268. positionFunction?: any;
  80269. vertexFunction?: any;
  80270. }): number;
  80271. private _rebuildParticle;
  80272. /**
  80273. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80274. * @returns the SPS.
  80275. */
  80276. rebuildMesh(): SolidParticleSystem;
  80277. /**
  80278. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80279. * This method calls `updateParticle()` for each particle of the SPS.
  80280. * For an animated SPS, it is usually called within the render loop.
  80281. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80282. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80283. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80284. * @returns the SPS.
  80285. */
  80286. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80287. /**
  80288. * Disposes the SPS.
  80289. */
  80290. dispose(): void;
  80291. /**
  80292. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80293. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80294. * @returns the SPS.
  80295. */
  80296. refreshVisibleSize(): SolidParticleSystem;
  80297. /**
  80298. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80299. * @param size the size (float) of the visibility box
  80300. * note : this doesn't lock the SPS mesh bounding box.
  80301. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80302. */
  80303. setVisibilityBox(size: number): void;
  80304. /**
  80305. * Gets whether the SPS as always visible or not
  80306. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80307. */
  80308. /**
  80309. * Sets the SPS as always visible or not
  80310. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80311. */
  80312. isAlwaysVisible: boolean;
  80313. /**
  80314. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80315. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80316. */
  80317. /**
  80318. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80319. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80320. */
  80321. isVisibilityBoxLocked: boolean;
  80322. /**
  80323. * Tells to `setParticles()` to compute 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. /**
  80328. * Gets if `setParticles()` computes the particle rotations or not.
  80329. * Default value : true. The SPS is faster when it's set to false.
  80330. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80331. */
  80332. computeParticleRotation: boolean;
  80333. /**
  80334. * Tells to `setParticles()` to compute 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. /**
  80339. * Gets if `setParticles()` computes the particle colors or not.
  80340. * Default value : true. The SPS is faster when it's set to false.
  80341. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80342. */
  80343. computeParticleColor: boolean;
  80344. /**
  80345. * Gets if `setParticles()` computes the particle textures or not.
  80346. * Default value : true. The SPS is faster when it's set to false.
  80347. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80348. */
  80349. computeParticleTexture: boolean;
  80350. /**
  80351. * Tells to `setParticles()` to call 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. /**
  80356. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80357. * Default value : false. The SPS is faster when it's set to false.
  80358. * Note : the particle custom vertex positions aren't stored values.
  80359. */
  80360. computeParticleVertex: boolean;
  80361. /**
  80362. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80363. */
  80364. /**
  80365. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80366. */
  80367. computeBoundingBox: boolean;
  80368. /**
  80369. * Tells to `setParticles()` to sort 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. /**
  80374. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80375. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80376. * Default : `true`
  80377. */
  80378. depthSortParticles: boolean;
  80379. /**
  80380. * This function does nothing. It may be overwritten to set all the particle first values.
  80381. * The SPS doesn't call this function, you may have to call it by your own.
  80382. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80383. */
  80384. initParticles(): void;
  80385. /**
  80386. * This function does nothing. It may be overwritten to recycle a particle.
  80387. * The SPS doesn't call this function, you may have to call it by your own.
  80388. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80389. * @param particle The particle to recycle
  80390. * @returns the recycled particle
  80391. */
  80392. recycleParticle(particle: SolidParticle): SolidParticle;
  80393. /**
  80394. * Updates a particle : this function should be overwritten by the user.
  80395. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80396. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80397. * @example : just set a particle position or velocity and recycle conditions
  80398. * @param particle The particle to update
  80399. * @returns the updated particle
  80400. */
  80401. updateParticle(particle: SolidParticle): SolidParticle;
  80402. /**
  80403. * Updates a vertex of a particle : it can be overwritten by the user.
  80404. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80405. * @param particle the current particle
  80406. * @param vertex the current index of the current particle
  80407. * @param pt the index of the current vertex in the particle shape
  80408. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80409. * @example : just set a vertex particle position
  80410. * @returns the updated vertex
  80411. */
  80412. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80413. /**
  80414. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80415. * This does nothing and may be overwritten by the user.
  80416. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80417. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80418. * @param update the boolean update value actually passed to setParticles()
  80419. */
  80420. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80421. /**
  80422. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80423. * This will be passed three parameters.
  80424. * This does nothing and may be overwritten by the user.
  80425. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80426. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80427. * @param update the boolean update value actually passed to setParticles()
  80428. */
  80429. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80430. }
  80431. }
  80432. declare module BABYLON {
  80433. /**
  80434. * Represents one particle of a solid particle system.
  80435. */
  80436. export class SolidParticle {
  80437. /**
  80438. * particle global index
  80439. */
  80440. idx: number;
  80441. /**
  80442. * The color of the particle
  80443. */
  80444. color: Nullable<Color4>;
  80445. /**
  80446. * The world space position of the particle.
  80447. */
  80448. position: Vector3;
  80449. /**
  80450. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80451. */
  80452. rotation: Vector3;
  80453. /**
  80454. * The world space rotation quaternion of the particle.
  80455. */
  80456. rotationQuaternion: Nullable<Quaternion>;
  80457. /**
  80458. * The scaling of the particle.
  80459. */
  80460. scaling: Vector3;
  80461. /**
  80462. * The uvs of the particle.
  80463. */
  80464. uvs: Vector4;
  80465. /**
  80466. * The current speed of the particle.
  80467. */
  80468. velocity: Vector3;
  80469. /**
  80470. * The pivot point in the particle local space.
  80471. */
  80472. pivot: Vector3;
  80473. /**
  80474. * Must the particle be translated from its pivot point in its local space ?
  80475. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80476. * Default : false
  80477. */
  80478. translateFromPivot: boolean;
  80479. /**
  80480. * Is the particle active or not ?
  80481. */
  80482. alive: boolean;
  80483. /**
  80484. * Is the particle visible or not ?
  80485. */
  80486. isVisible: boolean;
  80487. /**
  80488. * Index of this particle in the global "positions" array (Internal use)
  80489. * @hidden
  80490. */
  80491. _pos: number;
  80492. /**
  80493. * @hidden Index of this particle in the global "indices" array (Internal use)
  80494. */
  80495. _ind: number;
  80496. /**
  80497. * @hidden ModelShape of this particle (Internal use)
  80498. */
  80499. _model: ModelShape;
  80500. /**
  80501. * ModelShape id of this particle
  80502. */
  80503. shapeId: number;
  80504. /**
  80505. * Index of the particle in its shape id (Internal use)
  80506. */
  80507. idxInShape: number;
  80508. /**
  80509. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80510. */
  80511. _modelBoundingInfo: BoundingInfo;
  80512. /**
  80513. * @hidden Particle BoundingInfo object (Internal use)
  80514. */
  80515. _boundingInfo: BoundingInfo;
  80516. /**
  80517. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80518. */
  80519. _sps: SolidParticleSystem;
  80520. /**
  80521. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80522. */
  80523. _stillInvisible: boolean;
  80524. /**
  80525. * @hidden Last computed particle rotation matrix
  80526. */
  80527. _rotationMatrix: number[];
  80528. /**
  80529. * Parent particle Id, if any.
  80530. * Default null.
  80531. */
  80532. parentId: Nullable<number>;
  80533. /**
  80534. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80535. * The possible values are :
  80536. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80537. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80538. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80539. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80540. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80541. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80542. * */
  80543. cullingStrategy: number;
  80544. /**
  80545. * @hidden Internal global position in the SPS.
  80546. */
  80547. _globalPosition: Vector3;
  80548. /**
  80549. * Creates a Solid Particle object.
  80550. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80551. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80552. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80553. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80554. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80555. * @param shapeId (integer) is the model shape identifier in the SPS.
  80556. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80557. * @param sps defines the sps it is associated to
  80558. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80559. */
  80560. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80561. /**
  80562. * Legacy support, changed scale to scaling
  80563. */
  80564. /**
  80565. * Legacy support, changed scale to scaling
  80566. */
  80567. scale: Vector3;
  80568. /**
  80569. * Legacy support, changed quaternion to rotationQuaternion
  80570. */
  80571. /**
  80572. * Legacy support, changed quaternion to rotationQuaternion
  80573. */
  80574. quaternion: Nullable<Quaternion>;
  80575. /**
  80576. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80577. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80578. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80579. * @returns true if it intersects
  80580. */
  80581. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80582. /**
  80583. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80584. * A particle is in the frustum if its bounding box intersects the frustum
  80585. * @param frustumPlanes defines the frustum to test
  80586. * @returns true if the particle is in the frustum planes
  80587. */
  80588. isInFrustum(frustumPlanes: Plane[]): boolean;
  80589. /**
  80590. * get the rotation matrix of the particle
  80591. * @hidden
  80592. */
  80593. getRotationMatrix(m: Matrix): void;
  80594. }
  80595. /**
  80596. * Represents the shape of the model used by one particle of a solid particle system.
  80597. * SPS internal tool, don't use it manually.
  80598. */
  80599. export class ModelShape {
  80600. /**
  80601. * The shape id
  80602. * @hidden
  80603. */
  80604. shapeID: number;
  80605. /**
  80606. * flat array of model positions (internal use)
  80607. * @hidden
  80608. */
  80609. _shape: Vector3[];
  80610. /**
  80611. * flat array of model UVs (internal use)
  80612. * @hidden
  80613. */
  80614. _shapeUV: number[];
  80615. /**
  80616. * length of the shape in the model indices array (internal use)
  80617. * @hidden
  80618. */
  80619. _indicesLength: number;
  80620. /**
  80621. * Custom position function (internal use)
  80622. * @hidden
  80623. */
  80624. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80625. /**
  80626. * Custom vertex function (internal use)
  80627. * @hidden
  80628. */
  80629. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80630. /**
  80631. * 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.
  80632. * SPS internal tool, don't use it manually.
  80633. * @hidden
  80634. */
  80635. 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>);
  80636. }
  80637. /**
  80638. * Represents a Depth Sorted Particle in the solid particle system.
  80639. */
  80640. export class DepthSortedParticle {
  80641. /**
  80642. * Index of the particle in the "indices" array
  80643. */
  80644. ind: number;
  80645. /**
  80646. * Length of the particle shape in the "indices" array
  80647. */
  80648. indicesLength: number;
  80649. /**
  80650. * Squared distance from the particle to the camera
  80651. */
  80652. sqDistance: number;
  80653. }
  80654. }
  80655. declare module BABYLON {
  80656. /**
  80657. * Class used to store all common mesh properties
  80658. */
  80659. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80660. /** No occlusion */
  80661. static OCCLUSION_TYPE_NONE: number;
  80662. /** Occlusion set to optimisitic */
  80663. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80664. /** Occlusion set to strict */
  80665. static OCCLUSION_TYPE_STRICT: number;
  80666. /** Use an accurante occlusion algorithm */
  80667. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80668. /** Use a conservative occlusion algorithm */
  80669. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80670. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80671. * Test order :
  80672. * Is the bounding sphere outside the frustum ?
  80673. * If not, are the bounding box vertices outside the frustum ?
  80674. * It not, then the cullable object is in the frustum.
  80675. */
  80676. static readonly CULLINGSTRATEGY_STANDARD: number;
  80677. /** Culling strategy : Bounding Sphere Only.
  80678. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80679. * It's also less accurate than the standard because some not visible objects can still be selected.
  80680. * Test : is the bounding sphere outside the frustum ?
  80681. * If not, then the cullable object is in the frustum.
  80682. */
  80683. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80684. /** Culling strategy : Optimistic Inclusion.
  80685. * This in an inclusion test first, then the standard exclusion test.
  80686. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80687. * 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.
  80688. * Anyway, it's as accurate as the standard strategy.
  80689. * Test :
  80690. * Is the cullable object bounding sphere center in the frustum ?
  80691. * If not, apply the default culling strategy.
  80692. */
  80693. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80694. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80695. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80696. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80697. * 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.
  80698. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80699. * Test :
  80700. * Is the cullable object bounding sphere center in the frustum ?
  80701. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80702. */
  80703. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80704. /**
  80705. * No billboard
  80706. */
  80707. static readonly BILLBOARDMODE_NONE: number;
  80708. /** Billboard on X axis */
  80709. static readonly BILLBOARDMODE_X: number;
  80710. /** Billboard on Y axis */
  80711. static readonly BILLBOARDMODE_Y: number;
  80712. /** Billboard on Z axis */
  80713. static readonly BILLBOARDMODE_Z: number;
  80714. /** Billboard on all axes */
  80715. static readonly BILLBOARDMODE_ALL: number;
  80716. private _facetData;
  80717. /**
  80718. * The culling strategy to use to check whether the mesh must be rendered or not.
  80719. * This value can be changed at any time and will be used on the next render mesh selection.
  80720. * The possible values are :
  80721. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80722. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80723. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80724. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80725. * Please read each static variable documentation to get details about the culling process.
  80726. * */
  80727. cullingStrategy: number;
  80728. /**
  80729. * Gets the number of facets in the mesh
  80730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80731. */
  80732. readonly facetNb: number;
  80733. /**
  80734. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80736. */
  80737. partitioningSubdivisions: number;
  80738. /**
  80739. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80740. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80742. */
  80743. partitioningBBoxRatio: number;
  80744. /**
  80745. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80746. * Works only for updatable meshes.
  80747. * Doesn't work with multi-materials
  80748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80749. */
  80750. mustDepthSortFacets: boolean;
  80751. /**
  80752. * The location (Vector3) where the facet depth sort must be computed from.
  80753. * By default, the active camera position.
  80754. * Used only when facet depth sort is enabled
  80755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80756. */
  80757. facetDepthSortFrom: Vector3;
  80758. /**
  80759. * gets a boolean indicating if facetData is enabled
  80760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80761. */
  80762. readonly isFacetDataEnabled: boolean;
  80763. /** @hidden */
  80764. _updateNonUniformScalingState(value: boolean): boolean;
  80765. /**
  80766. * An event triggered when this mesh collides with another one
  80767. */
  80768. onCollideObservable: Observable<AbstractMesh>;
  80769. private _onCollideObserver;
  80770. /** Set a function to call when this mesh collides with another one */
  80771. onCollide: () => void;
  80772. /**
  80773. * An event triggered when the collision's position changes
  80774. */
  80775. onCollisionPositionChangeObservable: Observable<Vector3>;
  80776. private _onCollisionPositionChangeObserver;
  80777. /** Set a function to call when the collision's position changes */
  80778. onCollisionPositionChange: () => void;
  80779. /**
  80780. * An event triggered when material is changed
  80781. */
  80782. onMaterialChangedObservable: Observable<AbstractMesh>;
  80783. /**
  80784. * Gets or sets the orientation for POV movement & rotation
  80785. */
  80786. definedFacingForward: boolean;
  80787. /** @hidden */
  80788. _occlusionQuery: Nullable<WebGLQuery>;
  80789. private _visibility;
  80790. /**
  80791. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80792. */
  80793. /**
  80794. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80795. */
  80796. visibility: number;
  80797. /** Gets or sets the alpha index used to sort transparent meshes
  80798. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80799. */
  80800. alphaIndex: number;
  80801. /**
  80802. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80803. */
  80804. isVisible: boolean;
  80805. /**
  80806. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80807. */
  80808. isPickable: boolean;
  80809. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80810. showSubMeshesBoundingBox: boolean;
  80811. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80812. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80813. */
  80814. isBlocker: boolean;
  80815. /**
  80816. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80817. */
  80818. enablePointerMoveEvents: boolean;
  80819. /**
  80820. * Specifies the rendering group id for this mesh (0 by default)
  80821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80822. */
  80823. renderingGroupId: number;
  80824. private _material;
  80825. /** Gets or sets current material */
  80826. material: Nullable<Material>;
  80827. private _receiveShadows;
  80828. /**
  80829. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80830. * @see http://doc.babylonjs.com/babylon101/shadows
  80831. */
  80832. receiveShadows: boolean;
  80833. /** Defines color to use when rendering outline */
  80834. outlineColor: Color3;
  80835. /** Define width to use when rendering outline */
  80836. outlineWidth: number;
  80837. /** Defines color to use when rendering overlay */
  80838. overlayColor: Color3;
  80839. /** Defines alpha to use when rendering overlay */
  80840. overlayAlpha: number;
  80841. private _hasVertexAlpha;
  80842. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80843. hasVertexAlpha: boolean;
  80844. private _useVertexColors;
  80845. /** 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) */
  80846. useVertexColors: boolean;
  80847. private _computeBonesUsingShaders;
  80848. /**
  80849. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80850. */
  80851. computeBonesUsingShaders: boolean;
  80852. private _numBoneInfluencers;
  80853. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80854. numBoneInfluencers: number;
  80855. private _applyFog;
  80856. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80857. applyFog: boolean;
  80858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80859. useOctreeForRenderingSelection: boolean;
  80860. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80861. useOctreeForPicking: boolean;
  80862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80863. useOctreeForCollisions: boolean;
  80864. private _layerMask;
  80865. /**
  80866. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80867. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80868. */
  80869. layerMask: number;
  80870. /**
  80871. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80872. */
  80873. alwaysSelectAsActiveMesh: boolean;
  80874. /**
  80875. * Gets or sets the current action manager
  80876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80877. */
  80878. actionManager: Nullable<AbstractActionManager>;
  80879. private _checkCollisions;
  80880. private _collisionMask;
  80881. private _collisionGroup;
  80882. /**
  80883. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80885. */
  80886. ellipsoid: Vector3;
  80887. /**
  80888. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80890. */
  80891. ellipsoidOffset: Vector3;
  80892. private _collider;
  80893. private _oldPositionForCollisions;
  80894. private _diffPositionForCollisions;
  80895. /**
  80896. * Gets or sets a collision mask used to mask collisions (default is -1).
  80897. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80898. */
  80899. collisionMask: number;
  80900. /**
  80901. * Gets or sets the current collision group mask (-1 by default).
  80902. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80903. */
  80904. collisionGroup: number;
  80905. /**
  80906. * Defines edge width used when edgesRenderer is enabled
  80907. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80908. */
  80909. edgesWidth: number;
  80910. /**
  80911. * Defines edge color used when edgesRenderer is enabled
  80912. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80913. */
  80914. edgesColor: Color4;
  80915. /** @hidden */
  80916. _edgesRenderer: Nullable<IEdgesRenderer>;
  80917. /** @hidden */
  80918. _masterMesh: Nullable<AbstractMesh>;
  80919. /** @hidden */
  80920. _boundingInfo: Nullable<BoundingInfo>;
  80921. /** @hidden */
  80922. _renderId: number;
  80923. /**
  80924. * Gets or sets the list of subMeshes
  80925. * @see http://doc.babylonjs.com/how_to/multi_materials
  80926. */
  80927. subMeshes: SubMesh[];
  80928. /** @hidden */
  80929. _intersectionsInProgress: AbstractMesh[];
  80930. /** @hidden */
  80931. _unIndexed: boolean;
  80932. /** @hidden */
  80933. _lightSources: Light[];
  80934. /** @hidden */
  80935. readonly _positions: Nullable<Vector3[]>;
  80936. /** @hidden */
  80937. _waitingActions: any;
  80938. /** @hidden */
  80939. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80940. private _skeleton;
  80941. /** @hidden */
  80942. _bonesTransformMatrices: Nullable<Float32Array>;
  80943. /**
  80944. * Gets or sets a skeleton to apply skining transformations
  80945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80946. */
  80947. skeleton: Nullable<Skeleton>;
  80948. /**
  80949. * An event triggered when the mesh is rebuilt.
  80950. */
  80951. onRebuildObservable: Observable<AbstractMesh>;
  80952. /**
  80953. * Creates a new AbstractMesh
  80954. * @param name defines the name of the mesh
  80955. * @param scene defines the hosting scene
  80956. */
  80957. constructor(name: string, scene?: Nullable<Scene>);
  80958. /**
  80959. * Returns the string "AbstractMesh"
  80960. * @returns "AbstractMesh"
  80961. */
  80962. getClassName(): string;
  80963. /**
  80964. * Gets a string representation of the current mesh
  80965. * @param fullDetails defines a boolean indicating if full details must be included
  80966. * @returns a string representation of the current mesh
  80967. */
  80968. toString(fullDetails?: boolean): string;
  80969. /** @hidden */
  80970. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80971. /** @hidden */
  80972. _rebuild(): void;
  80973. /** @hidden */
  80974. _resyncLightSources(): void;
  80975. /** @hidden */
  80976. _resyncLighSource(light: Light): void;
  80977. /** @hidden */
  80978. _unBindEffect(): void;
  80979. /** @hidden */
  80980. _removeLightSource(light: Light): void;
  80981. private _markSubMeshesAsDirty;
  80982. /** @hidden */
  80983. _markSubMeshesAsLightDirty(): void;
  80984. /** @hidden */
  80985. _markSubMeshesAsAttributesDirty(): void;
  80986. /** @hidden */
  80987. _markSubMeshesAsMiscDirty(): void;
  80988. /**
  80989. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80990. */
  80991. scaling: Vector3;
  80992. /**
  80993. * Returns true if the mesh is blocked. Implemented by child classes
  80994. */
  80995. readonly isBlocked: boolean;
  80996. /**
  80997. * Returns the mesh itself by default. Implemented by child classes
  80998. * @param camera defines the camera to use to pick the right LOD level
  80999. * @returns the currentAbstractMesh
  81000. */
  81001. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81002. /**
  81003. * Returns 0 by default. Implemented by child classes
  81004. * @returns an integer
  81005. */
  81006. getTotalVertices(): number;
  81007. /**
  81008. * Returns a positive integer : the total number of indices in this mesh geometry.
  81009. * @returns the numner of indices or zero if the mesh has no geometry.
  81010. */
  81011. getTotalIndices(): number;
  81012. /**
  81013. * Returns null by default. Implemented by child classes
  81014. * @returns null
  81015. */
  81016. getIndices(): Nullable<IndicesArray>;
  81017. /**
  81018. * Returns the array of the requested vertex data kind. Implemented by child classes
  81019. * @param kind defines the vertex data kind to use
  81020. * @returns null
  81021. */
  81022. getVerticesData(kind: string): Nullable<FloatArray>;
  81023. /**
  81024. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81025. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81026. * Note that a new underlying VertexBuffer object is created each call.
  81027. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81028. * @param kind defines vertex data kind:
  81029. * * VertexBuffer.PositionKind
  81030. * * VertexBuffer.UVKind
  81031. * * VertexBuffer.UV2Kind
  81032. * * VertexBuffer.UV3Kind
  81033. * * VertexBuffer.UV4Kind
  81034. * * VertexBuffer.UV5Kind
  81035. * * VertexBuffer.UV6Kind
  81036. * * VertexBuffer.ColorKind
  81037. * * VertexBuffer.MatricesIndicesKind
  81038. * * VertexBuffer.MatricesIndicesExtraKind
  81039. * * VertexBuffer.MatricesWeightsKind
  81040. * * VertexBuffer.MatricesWeightsExtraKind
  81041. * @param data defines the data source
  81042. * @param updatable defines if the data must be flagged as updatable (or static)
  81043. * @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
  81044. * @returns the current mesh
  81045. */
  81046. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81047. /**
  81048. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81049. * If the mesh has no geometry, it is simply returned as it is.
  81050. * @param kind defines vertex data kind:
  81051. * * VertexBuffer.PositionKind
  81052. * * VertexBuffer.UVKind
  81053. * * VertexBuffer.UV2Kind
  81054. * * VertexBuffer.UV3Kind
  81055. * * VertexBuffer.UV4Kind
  81056. * * VertexBuffer.UV5Kind
  81057. * * VertexBuffer.UV6Kind
  81058. * * VertexBuffer.ColorKind
  81059. * * VertexBuffer.MatricesIndicesKind
  81060. * * VertexBuffer.MatricesIndicesExtraKind
  81061. * * VertexBuffer.MatricesWeightsKind
  81062. * * VertexBuffer.MatricesWeightsExtraKind
  81063. * @param data defines the data source
  81064. * @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
  81065. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81066. * @returns the current mesh
  81067. */
  81068. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81069. /**
  81070. * Sets the mesh indices,
  81071. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81072. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81073. * @param totalVertices Defines the total number of vertices
  81074. * @returns the current mesh
  81075. */
  81076. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81077. /**
  81078. * Gets a boolean indicating if specific vertex data is present
  81079. * @param kind defines the vertex data kind to use
  81080. * @returns true is data kind is present
  81081. */
  81082. isVerticesDataPresent(kind: string): boolean;
  81083. /**
  81084. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81085. * @returns a BoundingInfo
  81086. */
  81087. getBoundingInfo(): BoundingInfo;
  81088. /**
  81089. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81090. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81091. * @returns the current mesh
  81092. */
  81093. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81094. /**
  81095. * Overwrite the current bounding info
  81096. * @param boundingInfo defines the new bounding info
  81097. * @returns the current mesh
  81098. */
  81099. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81100. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81101. readonly useBones: boolean;
  81102. /** @hidden */
  81103. _preActivate(): void;
  81104. /** @hidden */
  81105. _preActivateForIntermediateRendering(renderId: number): void;
  81106. /** @hidden */
  81107. _activate(renderId: number): void;
  81108. /**
  81109. * Gets the current world matrix
  81110. * @returns a Matrix
  81111. */
  81112. getWorldMatrix(): Matrix;
  81113. /** @hidden */
  81114. _getWorldMatrixDeterminant(): number;
  81115. /**
  81116. * Perform relative position change from the point of view of behind the front of the mesh.
  81117. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81118. * Supports definition of mesh facing forward or backward
  81119. * @param amountRight defines the distance on the right axis
  81120. * @param amountUp defines the distance on the up axis
  81121. * @param amountForward defines the distance on the forward axis
  81122. * @returns the current mesh
  81123. */
  81124. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81125. /**
  81126. * Calculate relative position change from the point of view of behind the front of the mesh.
  81127. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81128. * Supports definition of mesh facing forward or backward
  81129. * @param amountRight defines the distance on the right axis
  81130. * @param amountUp defines the distance on the up axis
  81131. * @param amountForward defines the distance on the forward axis
  81132. * @returns the new displacement vector
  81133. */
  81134. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81135. /**
  81136. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81137. * Supports definition of mesh facing forward or backward
  81138. * @param flipBack defines the flip
  81139. * @param twirlClockwise defines the twirl
  81140. * @param tiltRight defines the tilt
  81141. * @returns the current mesh
  81142. */
  81143. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81144. /**
  81145. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81146. * Supports definition of mesh facing forward or backward.
  81147. * @param flipBack defines the flip
  81148. * @param twirlClockwise defines the twirl
  81149. * @param tiltRight defines the tilt
  81150. * @returns the new rotation vector
  81151. */
  81152. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81153. /**
  81154. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81155. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81156. * @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
  81157. * @returns the new bounding vectors
  81158. */
  81159. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81160. min: Vector3;
  81161. max: Vector3;
  81162. };
  81163. /**
  81164. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81165. * This means the mesh underlying bounding box and sphere are recomputed.
  81166. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81167. * @returns the current mesh
  81168. */
  81169. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81170. /** @hidden */
  81171. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81172. /** @hidden */
  81173. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81174. /** @hidden */
  81175. _updateBoundingInfo(): AbstractMesh;
  81176. /** @hidden */
  81177. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81178. /** @hidden */
  81179. protected _afterComputeWorldMatrix(): void;
  81180. /**
  81181. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81182. * A mesh is in the frustum if its bounding box intersects the frustum
  81183. * @param frustumPlanes defines the frustum to test
  81184. * @returns true if the mesh is in the frustum planes
  81185. */
  81186. isInFrustum(frustumPlanes: Plane[]): boolean;
  81187. /**
  81188. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81189. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81190. * @param frustumPlanes defines the frustum to test
  81191. * @returns true if the mesh is completely in the frustum planes
  81192. */
  81193. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81194. /**
  81195. * True if the mesh intersects another mesh or a SolidParticle object
  81196. * @param mesh defines a target mesh or SolidParticle to test
  81197. * @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)
  81198. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81199. * @returns true if there is an intersection
  81200. */
  81201. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81202. /**
  81203. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81204. * @param point defines the point to test
  81205. * @returns true if there is an intersection
  81206. */
  81207. intersectsPoint(point: Vector3): boolean;
  81208. /**
  81209. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81210. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81211. */
  81212. checkCollisions: boolean;
  81213. /**
  81214. * Gets Collider object used to compute collisions (not physics)
  81215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81216. */
  81217. readonly collider: Collider;
  81218. /**
  81219. * Move the mesh using collision engine
  81220. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81221. * @param displacement defines the requested displacement vector
  81222. * @returns the current mesh
  81223. */
  81224. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81225. private _onCollisionPositionChange;
  81226. /** @hidden */
  81227. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81228. /** @hidden */
  81229. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81230. /** @hidden */
  81231. _checkCollision(collider: Collider): AbstractMesh;
  81232. /** @hidden */
  81233. _generatePointsArray(): boolean;
  81234. /**
  81235. * Checks if the passed Ray intersects with the mesh
  81236. * @param ray defines the ray to use
  81237. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81238. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81239. * @returns the picking info
  81240. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81241. */
  81242. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81243. /**
  81244. * Clones the current mesh
  81245. * @param name defines the mesh name
  81246. * @param newParent defines the new mesh parent
  81247. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81248. * @returns the new mesh
  81249. */
  81250. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81251. /**
  81252. * Disposes all the submeshes of the current meshnp
  81253. * @returns the current mesh
  81254. */
  81255. releaseSubMeshes(): AbstractMesh;
  81256. /**
  81257. * Releases resources associated with this abstract mesh.
  81258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81260. */
  81261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81262. /**
  81263. * Adds the passed mesh as a child to the current mesh
  81264. * @param mesh defines the child mesh
  81265. * @returns the current mesh
  81266. */
  81267. addChild(mesh: AbstractMesh): AbstractMesh;
  81268. /**
  81269. * Removes the passed mesh from the current mesh children list
  81270. * @param mesh defines the child mesh
  81271. * @returns the current mesh
  81272. */
  81273. removeChild(mesh: AbstractMesh): AbstractMesh;
  81274. /** @hidden */
  81275. private _initFacetData;
  81276. /**
  81277. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81278. * This method can be called within the render loop.
  81279. * 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
  81280. * @returns the current mesh
  81281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81282. */
  81283. updateFacetData(): AbstractMesh;
  81284. /**
  81285. * Returns the facetLocalNormals array.
  81286. * The normals are expressed in the mesh local spac
  81287. * @returns an array of Vector3
  81288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81289. */
  81290. getFacetLocalNormals(): Vector3[];
  81291. /**
  81292. * Returns the facetLocalPositions array.
  81293. * The facet positions are expressed in the mesh local space
  81294. * @returns an array of Vector3
  81295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81296. */
  81297. getFacetLocalPositions(): Vector3[];
  81298. /**
  81299. * Returns the facetLocalPartioning array
  81300. * @returns an array of array of numbers
  81301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81302. */
  81303. getFacetLocalPartitioning(): number[][];
  81304. /**
  81305. * Returns the i-th facet position in the world system.
  81306. * This method allocates a new Vector3 per call
  81307. * @param i defines the facet index
  81308. * @returns a new Vector3
  81309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81310. */
  81311. getFacetPosition(i: number): Vector3;
  81312. /**
  81313. * Sets the reference Vector3 with the i-th facet position in the world system
  81314. * @param i defines the facet index
  81315. * @param ref defines the target vector
  81316. * @returns the current mesh
  81317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81318. */
  81319. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81320. /**
  81321. * Returns the i-th facet normal in the world system.
  81322. * This method allocates a new Vector3 per call
  81323. * @param i defines the facet index
  81324. * @returns a new Vector3
  81325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81326. */
  81327. getFacetNormal(i: number): Vector3;
  81328. /**
  81329. * Sets the reference Vector3 with the i-th facet normal in the world system
  81330. * @param i defines the facet index
  81331. * @param ref defines the target vector
  81332. * @returns the current mesh
  81333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81334. */
  81335. getFacetNormalToRef(i: number, ref: Vector3): this;
  81336. /**
  81337. * 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)
  81338. * @param x defines x coordinate
  81339. * @param y defines y coordinate
  81340. * @param z defines z coordinate
  81341. * @returns the array of facet indexes
  81342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81343. */
  81344. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81345. /**
  81346. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81347. * @param projected sets as the (x,y,z) world projection on the facet
  81348. * @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
  81349. * @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
  81350. * @param x defines x coordinate
  81351. * @param y defines y coordinate
  81352. * @param z defines z coordinate
  81353. * @returns the face index if found (or null instead)
  81354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81355. */
  81356. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81357. /**
  81358. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81359. * @param projected sets as the (x,y,z) local projection on the facet
  81360. * @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
  81361. * @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
  81362. * @param x defines x coordinate
  81363. * @param y defines y coordinate
  81364. * @param z defines z coordinate
  81365. * @returns the face index if found (or null instead)
  81366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81367. */
  81368. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81369. /**
  81370. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81371. * @returns the parameters
  81372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81373. */
  81374. getFacetDataParameters(): any;
  81375. /**
  81376. * Disables the feature FacetData and frees the related memory
  81377. * @returns the current mesh
  81378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81379. */
  81380. disableFacetData(): AbstractMesh;
  81381. /**
  81382. * Updates the AbstractMesh indices array
  81383. * @param indices defines the data source
  81384. * @returns the current mesh
  81385. */
  81386. updateIndices(indices: IndicesArray): AbstractMesh;
  81387. /**
  81388. * Creates new normals data for the mesh
  81389. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81390. * @returns the current mesh
  81391. */
  81392. createNormals(updatable: boolean): AbstractMesh;
  81393. /**
  81394. * Align the mesh with a normal
  81395. * @param normal defines the normal to use
  81396. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81397. * @returns the current mesh
  81398. */
  81399. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81400. /** @hidden */
  81401. _checkOcclusionQuery(): boolean;
  81402. }
  81403. }
  81404. declare module BABYLON {
  81405. /**
  81406. * Interface used to define ActionEvent
  81407. */
  81408. export interface IActionEvent {
  81409. /** The mesh or sprite that triggered the action */
  81410. source: any;
  81411. /** The X mouse cursor position at the time of the event */
  81412. pointerX: number;
  81413. /** The Y mouse cursor position at the time of the event */
  81414. pointerY: number;
  81415. /** The mesh that is currently pointed at (can be null) */
  81416. meshUnderPointer: Nullable<AbstractMesh>;
  81417. /** the original (browser) event that triggered the ActionEvent */
  81418. sourceEvent?: any;
  81419. /** additional data for the event */
  81420. additionalData?: any;
  81421. }
  81422. /**
  81423. * ActionEvent is the event being sent when an action is triggered.
  81424. */
  81425. export class ActionEvent implements IActionEvent {
  81426. /** The mesh or sprite that triggered the action */
  81427. source: any;
  81428. /** The X mouse cursor position at the time of the event */
  81429. pointerX: number;
  81430. /** The Y mouse cursor position at the time of the event */
  81431. pointerY: number;
  81432. /** The mesh that is currently pointed at (can be null) */
  81433. meshUnderPointer: Nullable<AbstractMesh>;
  81434. /** the original (browser) event that triggered the ActionEvent */
  81435. sourceEvent?: any;
  81436. /** additional data for the event */
  81437. additionalData?: any;
  81438. /**
  81439. * Creates a new ActionEvent
  81440. * @param source The mesh or sprite that triggered the action
  81441. * @param pointerX The X mouse cursor position at the time of the event
  81442. * @param pointerY The Y mouse cursor position at the time of the event
  81443. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81444. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81445. * @param additionalData additional data for the event
  81446. */
  81447. constructor(
  81448. /** The mesh or sprite that triggered the action */
  81449. source: any,
  81450. /** The X mouse cursor position at the time of the event */
  81451. pointerX: number,
  81452. /** The Y mouse cursor position at the time of the event */
  81453. pointerY: number,
  81454. /** The mesh that is currently pointed at (can be null) */
  81455. meshUnderPointer: Nullable<AbstractMesh>,
  81456. /** the original (browser) event that triggered the ActionEvent */
  81457. sourceEvent?: any,
  81458. /** additional data for the event */
  81459. additionalData?: any);
  81460. /**
  81461. * Helper function to auto-create an ActionEvent from a source mesh.
  81462. * @param source The source mesh that triggered the event
  81463. * @param evt The original (browser) event
  81464. * @param additionalData additional data for the event
  81465. * @returns the new ActionEvent
  81466. */
  81467. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81468. /**
  81469. * Helper function to auto-create an ActionEvent from a source sprite
  81470. * @param source The source sprite that triggered the event
  81471. * @param scene Scene associated with the sprite
  81472. * @param evt The original (browser) event
  81473. * @param additionalData additional data for the event
  81474. * @returns the new ActionEvent
  81475. */
  81476. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81477. /**
  81478. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81479. * @param scene the scene where the event occurred
  81480. * @param evt The original (browser) event
  81481. * @returns the new ActionEvent
  81482. */
  81483. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81484. /**
  81485. * Helper function to auto-create an ActionEvent from a primitive
  81486. * @param prim defines the target primitive
  81487. * @param pointerPos defines the pointer position
  81488. * @param evt The original (browser) event
  81489. * @param additionalData additional data for the event
  81490. * @returns the new ActionEvent
  81491. */
  81492. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81493. }
  81494. }
  81495. declare module BABYLON {
  81496. /**
  81497. * Abstract class used to decouple action Manager from scene and meshes.
  81498. * Do not instantiate.
  81499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81500. */
  81501. export abstract class AbstractActionManager implements IDisposable {
  81502. /** Gets the list of active triggers */
  81503. static Triggers: {
  81504. [key: string]: number;
  81505. };
  81506. /** Gets the cursor to use when hovering items */
  81507. hoverCursor: string;
  81508. /** Gets the list of actions */
  81509. actions: IAction[];
  81510. /**
  81511. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81512. */
  81513. isRecursive: boolean;
  81514. /**
  81515. * Releases all associated resources
  81516. */
  81517. abstract dispose(): void;
  81518. /**
  81519. * Does this action manager has pointer triggers
  81520. */
  81521. abstract readonly hasPointerTriggers: boolean;
  81522. /**
  81523. * Does this action manager has pick triggers
  81524. */
  81525. abstract readonly hasPickTriggers: boolean;
  81526. /**
  81527. * Process a specific trigger
  81528. * @param trigger defines the trigger to process
  81529. * @param evt defines the event details to be processed
  81530. */
  81531. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81532. /**
  81533. * Does this action manager handles actions of any of the given triggers
  81534. * @param triggers defines the triggers to be tested
  81535. * @return a boolean indicating whether one (or more) of the triggers is handled
  81536. */
  81537. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81538. /**
  81539. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81540. * speed.
  81541. * @param triggerA defines the trigger to be tested
  81542. * @param triggerB defines the trigger to be tested
  81543. * @return a boolean indicating whether one (or more) of the triggers is handled
  81544. */
  81545. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81546. /**
  81547. * Does this action manager handles actions of a given trigger
  81548. * @param trigger defines the trigger to be tested
  81549. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81550. * @return whether the trigger is handled
  81551. */
  81552. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81553. /**
  81554. * Serialize this manager to a JSON object
  81555. * @param name defines the property name to store this manager
  81556. * @returns a JSON representation of this manager
  81557. */
  81558. abstract serialize(name: string): any;
  81559. /**
  81560. * Registers an action to this action manager
  81561. * @param action defines the action to be registered
  81562. * @return the action amended (prepared) after registration
  81563. */
  81564. abstract registerAction(action: IAction): Nullable<IAction>;
  81565. /**
  81566. * Unregisters an action to this action manager
  81567. * @param action defines the action to be unregistered
  81568. * @return a boolean indicating whether the action has been unregistered
  81569. */
  81570. abstract unregisterAction(action: IAction): Boolean;
  81571. /**
  81572. * Does exist one action manager with at least one trigger
  81573. **/
  81574. static readonly HasTriggers: boolean;
  81575. /**
  81576. * Does exist one action manager with at least one pick trigger
  81577. **/
  81578. static readonly HasPickTriggers: boolean;
  81579. /**
  81580. * Does exist one action manager that handles actions of a given trigger
  81581. * @param trigger defines the trigger to be tested
  81582. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81583. **/
  81584. static HasSpecificTrigger(trigger: number): boolean;
  81585. }
  81586. }
  81587. declare module BABYLON {
  81588. /**
  81589. * Defines how a node can be built from a string name.
  81590. */
  81591. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81592. /**
  81593. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81594. */
  81595. export class Node implements IBehaviorAware<Node> {
  81596. /** @hidden */
  81597. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81598. private static _NodeConstructors;
  81599. /**
  81600. * Add a new node constructor
  81601. * @param type defines the type name of the node to construct
  81602. * @param constructorFunc defines the constructor function
  81603. */
  81604. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81605. /**
  81606. * Returns a node constructor based on type name
  81607. * @param type defines the type name
  81608. * @param name defines the new node name
  81609. * @param scene defines the hosting scene
  81610. * @param options defines optional options to transmit to constructors
  81611. * @returns the new constructor or null
  81612. */
  81613. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81614. /**
  81615. * Gets or sets the name of the node
  81616. */
  81617. name: string;
  81618. /**
  81619. * Gets or sets the id of the node
  81620. */
  81621. id: string;
  81622. /**
  81623. * Gets or sets the unique id of the node
  81624. */
  81625. uniqueId: number;
  81626. /**
  81627. * Gets or sets a string used to store user defined state for the node
  81628. */
  81629. state: string;
  81630. /**
  81631. * Gets or sets an object used to store user defined information for the node
  81632. */
  81633. metadata: any;
  81634. /**
  81635. * For internal use only. Please do not use.
  81636. */
  81637. reservedDataStore: any;
  81638. /**
  81639. * Gets or sets a boolean used to define if the node must be serialized
  81640. */
  81641. doNotSerialize: boolean;
  81642. /** @hidden */
  81643. _isDisposed: boolean;
  81644. /**
  81645. * Gets a list of Animations associated with the node
  81646. */
  81647. animations: Animation[];
  81648. protected _ranges: {
  81649. [name: string]: Nullable<AnimationRange>;
  81650. };
  81651. /**
  81652. * Callback raised when the node is ready to be used
  81653. */
  81654. onReady: (node: Node) => void;
  81655. private _isEnabled;
  81656. private _isParentEnabled;
  81657. private _isReady;
  81658. /** @hidden */
  81659. _currentRenderId: number;
  81660. private _parentRenderId;
  81661. protected _childRenderId: number;
  81662. /** @hidden */
  81663. _waitingParentId: Nullable<string>;
  81664. /** @hidden */
  81665. _scene: Scene;
  81666. /** @hidden */
  81667. _cache: any;
  81668. private _parentNode;
  81669. private _children;
  81670. /** @hidden */
  81671. _worldMatrix: Matrix;
  81672. /** @hidden */
  81673. _worldMatrixDeterminant: number;
  81674. /** @hidden */
  81675. private _sceneRootNodesIndex;
  81676. /**
  81677. * Gets a boolean indicating if the node has been disposed
  81678. * @returns true if the node was disposed
  81679. */
  81680. isDisposed(): boolean;
  81681. /**
  81682. * Gets or sets the parent of the node
  81683. */
  81684. parent: Nullable<Node>;
  81685. private addToSceneRootNodes;
  81686. private removeFromSceneRootNodes;
  81687. private _animationPropertiesOverride;
  81688. /**
  81689. * Gets or sets the animation properties override
  81690. */
  81691. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81692. /**
  81693. * Gets a string idenfifying the name of the class
  81694. * @returns "Node" string
  81695. */
  81696. getClassName(): string;
  81697. /** @hidden */
  81698. readonly _isNode: boolean;
  81699. /**
  81700. * An event triggered when the mesh is disposed
  81701. */
  81702. onDisposeObservable: Observable<Node>;
  81703. private _onDisposeObserver;
  81704. /**
  81705. * Sets a callback that will be raised when the node will be disposed
  81706. */
  81707. onDispose: () => void;
  81708. /**
  81709. * Creates a new Node
  81710. * @param name the name and id to be given to this node
  81711. * @param scene the scene this node will be added to
  81712. * @param addToRootNodes the node will be added to scene.rootNodes
  81713. */
  81714. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81715. /**
  81716. * Gets the scene of the node
  81717. * @returns a scene
  81718. */
  81719. getScene(): Scene;
  81720. /**
  81721. * Gets the engine of the node
  81722. * @returns a Engine
  81723. */
  81724. getEngine(): Engine;
  81725. private _behaviors;
  81726. /**
  81727. * Attach a behavior to the node
  81728. * @see http://doc.babylonjs.com/features/behaviour
  81729. * @param behavior defines the behavior to attach
  81730. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81731. * @returns the current Node
  81732. */
  81733. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81734. /**
  81735. * Remove an attached behavior
  81736. * @see http://doc.babylonjs.com/features/behaviour
  81737. * @param behavior defines the behavior to attach
  81738. * @returns the current Node
  81739. */
  81740. removeBehavior(behavior: Behavior<Node>): Node;
  81741. /**
  81742. * Gets the list of attached behaviors
  81743. * @see http://doc.babylonjs.com/features/behaviour
  81744. */
  81745. readonly behaviors: Behavior<Node>[];
  81746. /**
  81747. * Gets an attached behavior by name
  81748. * @param name defines the name of the behavior to look for
  81749. * @see http://doc.babylonjs.com/features/behaviour
  81750. * @returns null if behavior was not found else the requested behavior
  81751. */
  81752. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81753. /**
  81754. * Returns the latest update of the World matrix
  81755. * @returns a Matrix
  81756. */
  81757. getWorldMatrix(): Matrix;
  81758. /** @hidden */
  81759. _getWorldMatrixDeterminant(): number;
  81760. /**
  81761. * Returns directly the latest state of the mesh World matrix.
  81762. * A Matrix is returned.
  81763. */
  81764. readonly worldMatrixFromCache: Matrix;
  81765. /** @hidden */
  81766. _initCache(): void;
  81767. /** @hidden */
  81768. updateCache(force?: boolean): void;
  81769. /** @hidden */
  81770. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81771. /** @hidden */
  81772. _updateCache(ignoreParentClass?: boolean): void;
  81773. /** @hidden */
  81774. _isSynchronized(): boolean;
  81775. /** @hidden */
  81776. _markSyncedWithParent(): void;
  81777. /** @hidden */
  81778. isSynchronizedWithParent(): boolean;
  81779. /** @hidden */
  81780. isSynchronized(): boolean;
  81781. /**
  81782. * Is this node ready to be used/rendered
  81783. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81784. * @return true if the node is ready
  81785. */
  81786. isReady(completeCheck?: boolean): boolean;
  81787. /**
  81788. * Is this node enabled?
  81789. * 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
  81790. * @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
  81791. * @return whether this node (and its parent) is enabled
  81792. */
  81793. isEnabled(checkAncestors?: boolean): boolean;
  81794. /** @hidden */
  81795. protected _syncParentEnabledState(): void;
  81796. /**
  81797. * Set the enabled state of this node
  81798. * @param value defines the new enabled state
  81799. */
  81800. setEnabled(value: boolean): void;
  81801. /**
  81802. * Is this node a descendant of the given node?
  81803. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81804. * @param ancestor defines the parent node to inspect
  81805. * @returns a boolean indicating if this node is a descendant of the given node
  81806. */
  81807. isDescendantOf(ancestor: Node): boolean;
  81808. /** @hidden */
  81809. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81810. /**
  81811. * Will return all nodes that have this node as ascendant
  81812. * @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
  81813. * @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
  81814. * @return all children nodes of all types
  81815. */
  81816. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81817. /**
  81818. * Get all child-meshes of this node
  81819. * @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)
  81820. * @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
  81821. * @returns an array of AbstractMesh
  81822. */
  81823. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81824. /**
  81825. * Get all direct children of this node
  81826. * @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
  81827. * @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)
  81828. * @returns an array of Node
  81829. */
  81830. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81831. /** @hidden */
  81832. _setReady(state: boolean): void;
  81833. /**
  81834. * Get an animation by name
  81835. * @param name defines the name of the animation to look for
  81836. * @returns null if not found else the requested animation
  81837. */
  81838. getAnimationByName(name: string): Nullable<Animation>;
  81839. /**
  81840. * Creates an animation range for this node
  81841. * @param name defines the name of the range
  81842. * @param from defines the starting key
  81843. * @param to defines the end key
  81844. */
  81845. createAnimationRange(name: string, from: number, to: number): void;
  81846. /**
  81847. * Delete a specific animation range
  81848. * @param name defines the name of the range to delete
  81849. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81850. */
  81851. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81852. /**
  81853. * Get an animation range by name
  81854. * @param name defines the name of the animation range to look for
  81855. * @returns null if not found else the requested animation range
  81856. */
  81857. getAnimationRange(name: string): Nullable<AnimationRange>;
  81858. /**
  81859. * Gets the list of all animation ranges defined on this node
  81860. * @returns an array
  81861. */
  81862. getAnimationRanges(): Nullable<AnimationRange>[];
  81863. /**
  81864. * Will start the animation sequence
  81865. * @param name defines the range frames for animation sequence
  81866. * @param loop defines if the animation should loop (false by default)
  81867. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81868. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81869. * @returns the object created for this animation. If range does not exist, it will return null
  81870. */
  81871. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81872. /**
  81873. * Serialize animation ranges into a JSON compatible object
  81874. * @returns serialization object
  81875. */
  81876. serializeAnimationRanges(): any;
  81877. /**
  81878. * Computes the world matrix of the node
  81879. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81880. * @returns the world matrix
  81881. */
  81882. computeWorldMatrix(force?: boolean): Matrix;
  81883. /**
  81884. * Releases resources associated with this node.
  81885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81887. */
  81888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81889. /**
  81890. * Parse animation range data from a serialization object and store them into a given node
  81891. * @param node defines where to store the animation ranges
  81892. * @param parsedNode defines the serialization object to read data from
  81893. * @param scene defines the hosting scene
  81894. */
  81895. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81896. }
  81897. }
  81898. declare module BABYLON {
  81899. /**
  81900. * Class used to store any kind of animation
  81901. */
  81902. export class Animation {
  81903. /**Name of the animation */
  81904. name: string;
  81905. /**Property to animate */
  81906. targetProperty: string;
  81907. /**The frames per second of the animation */
  81908. framePerSecond: number;
  81909. /**The data type of the animation */
  81910. dataType: number;
  81911. /**The loop mode of the animation */
  81912. loopMode?: number | undefined;
  81913. /**Specifies if blending should be enabled */
  81914. enableBlending?: boolean | undefined;
  81915. /**
  81916. * Use matrix interpolation instead of using direct key value when animating matrices
  81917. */
  81918. static AllowMatricesInterpolation: boolean;
  81919. /**
  81920. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81921. */
  81922. static AllowMatrixDecomposeForInterpolation: boolean;
  81923. /**
  81924. * Stores the key frames of the animation
  81925. */
  81926. private _keys;
  81927. /**
  81928. * Stores the easing function of the animation
  81929. */
  81930. private _easingFunction;
  81931. /**
  81932. * @hidden Internal use only
  81933. */
  81934. _runtimeAnimations: RuntimeAnimation[];
  81935. /**
  81936. * The set of event that will be linked to this animation
  81937. */
  81938. private _events;
  81939. /**
  81940. * Stores an array of target property paths
  81941. */
  81942. targetPropertyPath: string[];
  81943. /**
  81944. * Stores the blending speed of the animation
  81945. */
  81946. blendingSpeed: number;
  81947. /**
  81948. * Stores the animation ranges for the animation
  81949. */
  81950. private _ranges;
  81951. /**
  81952. * @hidden Internal use
  81953. */
  81954. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81955. /**
  81956. * Sets up an animation
  81957. * @param property The property to animate
  81958. * @param animationType The animation type to apply
  81959. * @param framePerSecond The frames per second of the animation
  81960. * @param easingFunction The easing function used in the animation
  81961. * @returns The created animation
  81962. */
  81963. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81964. /**
  81965. * Create and start an animation on a node
  81966. * @param name defines the name of the global animation that will be run on all nodes
  81967. * @param node defines the root node where the animation will take place
  81968. * @param targetProperty defines property to animate
  81969. * @param framePerSecond defines the number of frame per second yo use
  81970. * @param totalFrame defines the number of frames in total
  81971. * @param from defines the initial value
  81972. * @param to defines the final value
  81973. * @param loopMode defines which loop mode you want to use (off by default)
  81974. * @param easingFunction defines the easing function to use (linear by default)
  81975. * @param onAnimationEnd defines the callback to call when animation end
  81976. * @returns the animatable created for this animation
  81977. */
  81978. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81979. /**
  81980. * Create and start an animation on a node and its descendants
  81981. * @param name defines the name of the global animation that will be run on all nodes
  81982. * @param node defines the root node where the animation will take place
  81983. * @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
  81984. * @param targetProperty defines property to animate
  81985. * @param framePerSecond defines the number of frame per second to use
  81986. * @param totalFrame defines the number of frames in total
  81987. * @param from defines the initial value
  81988. * @param to defines the final value
  81989. * @param loopMode defines which loop mode you want to use (off by default)
  81990. * @param easingFunction defines the easing function to use (linear by default)
  81991. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81992. * @returns the list of animatables created for all nodes
  81993. * @example https://www.babylonjs-playground.com/#MH0VLI
  81994. */
  81995. 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[]>;
  81996. /**
  81997. * Creates a new animation, merges it with the existing animations and starts it
  81998. * @param name Name of the animation
  81999. * @param node Node which contains the scene that begins the animations
  82000. * @param targetProperty Specifies which property to animate
  82001. * @param framePerSecond The frames per second of the animation
  82002. * @param totalFrame The total number of frames
  82003. * @param from The frame at the beginning of the animation
  82004. * @param to The frame at the end of the animation
  82005. * @param loopMode Specifies the loop mode of the animation
  82006. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82007. * @param onAnimationEnd Callback to run once the animation is complete
  82008. * @returns Nullable animation
  82009. */
  82010. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82011. /**
  82012. * Transition property of an host to the target Value
  82013. * @param property The property to transition
  82014. * @param targetValue The target Value of the property
  82015. * @param host The object where the property to animate belongs
  82016. * @param scene Scene used to run the animation
  82017. * @param frameRate Framerate (in frame/s) to use
  82018. * @param transition The transition type we want to use
  82019. * @param duration The duration of the animation, in milliseconds
  82020. * @param onAnimationEnd Callback trigger at the end of the animation
  82021. * @returns Nullable animation
  82022. */
  82023. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82024. /**
  82025. * Return the array of runtime animations currently using this animation
  82026. */
  82027. readonly runtimeAnimations: RuntimeAnimation[];
  82028. /**
  82029. * Specifies if any of the runtime animations are currently running
  82030. */
  82031. readonly hasRunningRuntimeAnimations: boolean;
  82032. /**
  82033. * Initializes the animation
  82034. * @param name Name of the animation
  82035. * @param targetProperty Property to animate
  82036. * @param framePerSecond The frames per second of the animation
  82037. * @param dataType The data type of the animation
  82038. * @param loopMode The loop mode of the animation
  82039. * @param enableBlending Specifies if blending should be enabled
  82040. */
  82041. constructor(
  82042. /**Name of the animation */
  82043. name: string,
  82044. /**Property to animate */
  82045. targetProperty: string,
  82046. /**The frames per second of the animation */
  82047. framePerSecond: number,
  82048. /**The data type of the animation */
  82049. dataType: number,
  82050. /**The loop mode of the animation */
  82051. loopMode?: number | undefined,
  82052. /**Specifies if blending should be enabled */
  82053. enableBlending?: boolean | undefined);
  82054. /**
  82055. * Converts the animation to a string
  82056. * @param fullDetails support for multiple levels of logging within scene loading
  82057. * @returns String form of the animation
  82058. */
  82059. toString(fullDetails?: boolean): string;
  82060. /**
  82061. * Add an event to this animation
  82062. * @param event Event to add
  82063. */
  82064. addEvent(event: AnimationEvent): void;
  82065. /**
  82066. * Remove all events found at the given frame
  82067. * @param frame The frame to remove events from
  82068. */
  82069. removeEvents(frame: number): void;
  82070. /**
  82071. * Retrieves all the events from the animation
  82072. * @returns Events from the animation
  82073. */
  82074. getEvents(): AnimationEvent[];
  82075. /**
  82076. * Creates an animation range
  82077. * @param name Name of the animation range
  82078. * @param from Starting frame of the animation range
  82079. * @param to Ending frame of the animation
  82080. */
  82081. createRange(name: string, from: number, to: number): void;
  82082. /**
  82083. * Deletes an animation range by name
  82084. * @param name Name of the animation range to delete
  82085. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82086. */
  82087. deleteRange(name: string, deleteFrames?: boolean): void;
  82088. /**
  82089. * Gets the animation range by name, or null if not defined
  82090. * @param name Name of the animation range
  82091. * @returns Nullable animation range
  82092. */
  82093. getRange(name: string): Nullable<AnimationRange>;
  82094. /**
  82095. * Gets the key frames from the animation
  82096. * @returns The key frames of the animation
  82097. */
  82098. getKeys(): Array<IAnimationKey>;
  82099. /**
  82100. * Gets the highest frame rate of the animation
  82101. * @returns Highest frame rate of the animation
  82102. */
  82103. getHighestFrame(): number;
  82104. /**
  82105. * Gets the easing function of the animation
  82106. * @returns Easing function of the animation
  82107. */
  82108. getEasingFunction(): IEasingFunction;
  82109. /**
  82110. * Sets the easing function of the animation
  82111. * @param easingFunction A custom mathematical formula for animation
  82112. */
  82113. setEasingFunction(easingFunction: EasingFunction): void;
  82114. /**
  82115. * Interpolates a scalar linearly
  82116. * @param startValue Start value of the animation curve
  82117. * @param endValue End value of the animation curve
  82118. * @param gradient Scalar amount to interpolate
  82119. * @returns Interpolated scalar value
  82120. */
  82121. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82122. /**
  82123. * Interpolates a scalar cubically
  82124. * @param startValue Start value of the animation curve
  82125. * @param outTangent End tangent of the animation
  82126. * @param endValue End value of the animation curve
  82127. * @param inTangent Start tangent of the animation curve
  82128. * @param gradient Scalar amount to interpolate
  82129. * @returns Interpolated scalar value
  82130. */
  82131. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82132. /**
  82133. * Interpolates a quaternion using a spherical linear interpolation
  82134. * @param startValue Start value of the animation curve
  82135. * @param endValue End value of the animation curve
  82136. * @param gradient Scalar amount to interpolate
  82137. * @returns Interpolated quaternion value
  82138. */
  82139. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82140. /**
  82141. * Interpolates a quaternion cubically
  82142. * @param startValue Start value of the animation curve
  82143. * @param outTangent End tangent of the animation curve
  82144. * @param endValue End value of the animation curve
  82145. * @param inTangent Start tangent of the animation curve
  82146. * @param gradient Scalar amount to interpolate
  82147. * @returns Interpolated quaternion value
  82148. */
  82149. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82150. /**
  82151. * Interpolates a Vector3 linearl
  82152. * @param startValue Start value of the animation curve
  82153. * @param endValue End value of the animation curve
  82154. * @param gradient Scalar amount to interpolate
  82155. * @returns Interpolated scalar value
  82156. */
  82157. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82158. /**
  82159. * Interpolates a Vector3 cubically
  82160. * @param startValue Start value of the animation curve
  82161. * @param outTangent End tangent of the animation
  82162. * @param endValue End value of the animation curve
  82163. * @param inTangent Start tangent of the animation curve
  82164. * @param gradient Scalar amount to interpolate
  82165. * @returns InterpolatedVector3 value
  82166. */
  82167. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82168. /**
  82169. * Interpolates a Vector2 linearly
  82170. * @param startValue Start value of the animation curve
  82171. * @param endValue End value of the animation curve
  82172. * @param gradient Scalar amount to interpolate
  82173. * @returns Interpolated Vector2 value
  82174. */
  82175. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82176. /**
  82177. * Interpolates a Vector2 cubically
  82178. * @param startValue Start value of the animation curve
  82179. * @param outTangent End tangent of the animation
  82180. * @param endValue End value of the animation curve
  82181. * @param inTangent Start tangent of the animation curve
  82182. * @param gradient Scalar amount to interpolate
  82183. * @returns Interpolated Vector2 value
  82184. */
  82185. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82186. /**
  82187. * Interpolates a size linearly
  82188. * @param startValue Start value of the animation curve
  82189. * @param endValue End value of the animation curve
  82190. * @param gradient Scalar amount to interpolate
  82191. * @returns Interpolated Size value
  82192. */
  82193. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82194. /**
  82195. * Interpolates a Color3 linearly
  82196. * @param startValue Start value of the animation curve
  82197. * @param endValue End value of the animation curve
  82198. * @param gradient Scalar amount to interpolate
  82199. * @returns Interpolated Color3 value
  82200. */
  82201. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82202. /**
  82203. * @hidden Internal use only
  82204. */
  82205. _getKeyValue(value: any): any;
  82206. /**
  82207. * @hidden Internal use only
  82208. */
  82209. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82210. /**
  82211. * Defines the function to use to interpolate matrices
  82212. * @param startValue defines the start matrix
  82213. * @param endValue defines the end matrix
  82214. * @param gradient defines the gradient between both matrices
  82215. * @param result defines an optional target matrix where to store the interpolation
  82216. * @returns the interpolated matrix
  82217. */
  82218. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82219. /**
  82220. * Makes a copy of the animation
  82221. * @returns Cloned animation
  82222. */
  82223. clone(): Animation;
  82224. /**
  82225. * Sets the key frames of the animation
  82226. * @param values The animation key frames to set
  82227. */
  82228. setKeys(values: Array<IAnimationKey>): void;
  82229. /**
  82230. * Serializes the animation to an object
  82231. * @returns Serialized object
  82232. */
  82233. serialize(): any;
  82234. /**
  82235. * Float animation type
  82236. */
  82237. private static _ANIMATIONTYPE_FLOAT;
  82238. /**
  82239. * Vector3 animation type
  82240. */
  82241. private static _ANIMATIONTYPE_VECTOR3;
  82242. /**
  82243. * Quaternion animation type
  82244. */
  82245. private static _ANIMATIONTYPE_QUATERNION;
  82246. /**
  82247. * Matrix animation type
  82248. */
  82249. private static _ANIMATIONTYPE_MATRIX;
  82250. /**
  82251. * Color3 animation type
  82252. */
  82253. private static _ANIMATIONTYPE_COLOR3;
  82254. /**
  82255. * Vector2 animation type
  82256. */
  82257. private static _ANIMATIONTYPE_VECTOR2;
  82258. /**
  82259. * Size animation type
  82260. */
  82261. private static _ANIMATIONTYPE_SIZE;
  82262. /**
  82263. * Relative Loop Mode
  82264. */
  82265. private static _ANIMATIONLOOPMODE_RELATIVE;
  82266. /**
  82267. * Cycle Loop Mode
  82268. */
  82269. private static _ANIMATIONLOOPMODE_CYCLE;
  82270. /**
  82271. * Constant Loop Mode
  82272. */
  82273. private static _ANIMATIONLOOPMODE_CONSTANT;
  82274. /**
  82275. * Get the float animation type
  82276. */
  82277. static readonly ANIMATIONTYPE_FLOAT: number;
  82278. /**
  82279. * Get the Vector3 animation type
  82280. */
  82281. static readonly ANIMATIONTYPE_VECTOR3: number;
  82282. /**
  82283. * Get the Vector2 animation type
  82284. */
  82285. static readonly ANIMATIONTYPE_VECTOR2: number;
  82286. /**
  82287. * Get the Size animation type
  82288. */
  82289. static readonly ANIMATIONTYPE_SIZE: number;
  82290. /**
  82291. * Get the Quaternion animation type
  82292. */
  82293. static readonly ANIMATIONTYPE_QUATERNION: number;
  82294. /**
  82295. * Get the Matrix animation type
  82296. */
  82297. static readonly ANIMATIONTYPE_MATRIX: number;
  82298. /**
  82299. * Get the Color3 animation type
  82300. */
  82301. static readonly ANIMATIONTYPE_COLOR3: number;
  82302. /**
  82303. * Get the Relative Loop Mode
  82304. */
  82305. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82306. /**
  82307. * Get the Cycle Loop Mode
  82308. */
  82309. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82310. /**
  82311. * Get the Constant Loop Mode
  82312. */
  82313. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82314. /** @hidden */
  82315. static _UniversalLerp(left: any, right: any, amount: number): any;
  82316. /**
  82317. * Parses an animation object and creates an animation
  82318. * @param parsedAnimation Parsed animation object
  82319. * @returns Animation object
  82320. */
  82321. static Parse(parsedAnimation: any): Animation;
  82322. /**
  82323. * Appends the serialized animations from the source animations
  82324. * @param source Source containing the animations
  82325. * @param destination Target to store the animations
  82326. */
  82327. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82328. }
  82329. }
  82330. declare module BABYLON {
  82331. /**
  82332. * Base class of all the textures in babylon.
  82333. * It groups all the common properties the materials, post process, lights... might need
  82334. * in order to make a correct use of the texture.
  82335. */
  82336. export class BaseTexture implements IAnimatable {
  82337. /**
  82338. * Default anisotropic filtering level for the application.
  82339. * It is set to 4 as a good tradeoff between perf and quality.
  82340. */
  82341. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82342. /**
  82343. * Gets or sets the unique id of the texture
  82344. */
  82345. uniqueId: number;
  82346. /**
  82347. * Define the name of the texture.
  82348. */
  82349. name: string;
  82350. /**
  82351. * Gets or sets an object used to store user defined information.
  82352. */
  82353. metadata: any;
  82354. /**
  82355. * For internal use only. Please do not use.
  82356. */
  82357. reservedDataStore: any;
  82358. private _hasAlpha;
  82359. /**
  82360. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82361. */
  82362. hasAlpha: boolean;
  82363. /**
  82364. * Defines if the alpha value should be determined via the rgb values.
  82365. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82366. */
  82367. getAlphaFromRGB: boolean;
  82368. /**
  82369. * Intensity or strength of the texture.
  82370. * It is commonly used by materials to fine tune the intensity of the texture
  82371. */
  82372. level: number;
  82373. /**
  82374. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82375. * This is part of the texture as textures usually maps to one uv set.
  82376. */
  82377. coordinatesIndex: number;
  82378. private _coordinatesMode;
  82379. /**
  82380. * How a texture is mapped.
  82381. *
  82382. * | Value | Type | Description |
  82383. * | ----- | ----------------------------------- | ----------- |
  82384. * | 0 | EXPLICIT_MODE | |
  82385. * | 1 | SPHERICAL_MODE | |
  82386. * | 2 | PLANAR_MODE | |
  82387. * | 3 | CUBIC_MODE | |
  82388. * | 4 | PROJECTION_MODE | |
  82389. * | 5 | SKYBOX_MODE | |
  82390. * | 6 | INVCUBIC_MODE | |
  82391. * | 7 | EQUIRECTANGULAR_MODE | |
  82392. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82393. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82394. */
  82395. coordinatesMode: number;
  82396. /**
  82397. * | Value | Type | Description |
  82398. * | ----- | ------------------ | ----------- |
  82399. * | 0 | CLAMP_ADDRESSMODE | |
  82400. * | 1 | WRAP_ADDRESSMODE | |
  82401. * | 2 | MIRROR_ADDRESSMODE | |
  82402. */
  82403. wrapU: number;
  82404. /**
  82405. * | Value | Type | Description |
  82406. * | ----- | ------------------ | ----------- |
  82407. * | 0 | CLAMP_ADDRESSMODE | |
  82408. * | 1 | WRAP_ADDRESSMODE | |
  82409. * | 2 | MIRROR_ADDRESSMODE | |
  82410. */
  82411. wrapV: number;
  82412. /**
  82413. * | Value | Type | Description |
  82414. * | ----- | ------------------ | ----------- |
  82415. * | 0 | CLAMP_ADDRESSMODE | |
  82416. * | 1 | WRAP_ADDRESSMODE | |
  82417. * | 2 | MIRROR_ADDRESSMODE | |
  82418. */
  82419. wrapR: number;
  82420. /**
  82421. * With compliant hardware and browser (supporting anisotropic filtering)
  82422. * this defines the level of anisotropic filtering in the texture.
  82423. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82424. */
  82425. anisotropicFilteringLevel: number;
  82426. /**
  82427. * Define if the texture is a cube texture or if false a 2d texture.
  82428. */
  82429. isCube: boolean;
  82430. /**
  82431. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82432. */
  82433. is3D: boolean;
  82434. /**
  82435. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82436. * HDR texture are usually stored in linear space.
  82437. * This only impacts the PBR and Background materials
  82438. */
  82439. gammaSpace: boolean;
  82440. /**
  82441. * Gets whether or not the texture contains RGBD data.
  82442. */
  82443. readonly isRGBD: boolean;
  82444. /**
  82445. * Is Z inverted in the texture (useful in a cube texture).
  82446. */
  82447. invertZ: boolean;
  82448. /**
  82449. * Are mip maps generated for this texture or not.
  82450. */
  82451. readonly noMipmap: boolean;
  82452. /**
  82453. * @hidden
  82454. */
  82455. lodLevelInAlpha: boolean;
  82456. /**
  82457. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82458. */
  82459. lodGenerationOffset: number;
  82460. /**
  82461. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82462. */
  82463. lodGenerationScale: number;
  82464. /**
  82465. * Define if the texture is a render target.
  82466. */
  82467. isRenderTarget: boolean;
  82468. /**
  82469. * Define the unique id of the texture in the scene.
  82470. */
  82471. readonly uid: string;
  82472. /**
  82473. * Return a string representation of the texture.
  82474. * @returns the texture as a string
  82475. */
  82476. toString(): string;
  82477. /**
  82478. * Get the class name of the texture.
  82479. * @returns "BaseTexture"
  82480. */
  82481. getClassName(): string;
  82482. /**
  82483. * Define the list of animation attached to the texture.
  82484. */
  82485. animations: Animation[];
  82486. /**
  82487. * An event triggered when the texture is disposed.
  82488. */
  82489. onDisposeObservable: Observable<BaseTexture>;
  82490. private _onDisposeObserver;
  82491. /**
  82492. * Callback triggered when the texture has been disposed.
  82493. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82494. */
  82495. onDispose: () => void;
  82496. /**
  82497. * Define the current state of the loading sequence when in delayed load mode.
  82498. */
  82499. delayLoadState: number;
  82500. private _scene;
  82501. /** @hidden */
  82502. _texture: Nullable<InternalTexture>;
  82503. private _uid;
  82504. /**
  82505. * Define if the texture is preventinga material to render or not.
  82506. * If not and the texture is not ready, the engine will use a default black texture instead.
  82507. */
  82508. readonly isBlocking: boolean;
  82509. /**
  82510. * Instantiates a new BaseTexture.
  82511. * Base class of all the textures in babylon.
  82512. * It groups all the common properties the materials, post process, lights... might need
  82513. * in order to make a correct use of the texture.
  82514. * @param scene Define the scene the texture blongs to
  82515. */
  82516. constructor(scene: Nullable<Scene>);
  82517. /**
  82518. * Get the scene the texture belongs to.
  82519. * @returns the scene or null if undefined
  82520. */
  82521. getScene(): Nullable<Scene>;
  82522. /**
  82523. * Get the texture transform matrix used to offset tile the texture for istance.
  82524. * @returns the transformation matrix
  82525. */
  82526. getTextureMatrix(): Matrix;
  82527. /**
  82528. * Get the texture reflection matrix used to rotate/transform the reflection.
  82529. * @returns the reflection matrix
  82530. */
  82531. getReflectionTextureMatrix(): Matrix;
  82532. /**
  82533. * Get the underlying lower level texture from Babylon.
  82534. * @returns the insternal texture
  82535. */
  82536. getInternalTexture(): Nullable<InternalTexture>;
  82537. /**
  82538. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82539. * @returns true if ready or not blocking
  82540. */
  82541. isReadyOrNotBlocking(): boolean;
  82542. /**
  82543. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82544. * @returns true if fully ready
  82545. */
  82546. isReady(): boolean;
  82547. private _cachedSize;
  82548. /**
  82549. * Get the size of the texture.
  82550. * @returns the texture size.
  82551. */
  82552. getSize(): ISize;
  82553. /**
  82554. * Get the base size of the texture.
  82555. * It can be different from the size if the texture has been resized for POT for instance
  82556. * @returns the base size
  82557. */
  82558. getBaseSize(): ISize;
  82559. /**
  82560. * Update the sampling mode of the texture.
  82561. * Default is Trilinear mode.
  82562. *
  82563. * | Value | Type | Description |
  82564. * | ----- | ------------------ | ----------- |
  82565. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82566. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82567. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82568. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82569. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82570. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82571. * | 7 | NEAREST_LINEAR | |
  82572. * | 8 | NEAREST_NEAREST | |
  82573. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82574. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82575. * | 11 | LINEAR_LINEAR | |
  82576. * | 12 | LINEAR_NEAREST | |
  82577. *
  82578. * > _mag_: magnification filter (close to the viewer)
  82579. * > _min_: minification filter (far from the viewer)
  82580. * > _mip_: filter used between mip map levels
  82581. *@param samplingMode Define the new sampling mode of the texture
  82582. */
  82583. updateSamplingMode(samplingMode: number): void;
  82584. /**
  82585. * Scales the texture if is `canRescale()`
  82586. * @param ratio the resize factor we want to use to rescale
  82587. */
  82588. scale(ratio: number): void;
  82589. /**
  82590. * Get if the texture can rescale.
  82591. */
  82592. readonly canRescale: boolean;
  82593. /** @hidden */
  82594. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82595. /** @hidden */
  82596. _rebuild(): void;
  82597. /**
  82598. * Triggers the load sequence in delayed load mode.
  82599. */
  82600. delayLoad(): void;
  82601. /**
  82602. * Clones the texture.
  82603. * @returns the cloned texture
  82604. */
  82605. clone(): Nullable<BaseTexture>;
  82606. /**
  82607. * Get the texture underlying type (INT, FLOAT...)
  82608. */
  82609. readonly textureType: number;
  82610. /**
  82611. * Get the texture underlying format (RGB, RGBA...)
  82612. */
  82613. readonly textureFormat: number;
  82614. /**
  82615. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82616. * This will returns an RGBA array buffer containing either in values (0-255) or
  82617. * float values (0-1) depending of the underlying buffer type.
  82618. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82619. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82620. * @param buffer defines a user defined buffer to fill with data (can be null)
  82621. * @returns The Array buffer containing the pixels data.
  82622. */
  82623. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82624. /**
  82625. * Release and destroy the underlying lower level texture aka internalTexture.
  82626. */
  82627. releaseInternalTexture(): void;
  82628. /**
  82629. * Get the polynomial representation of the texture data.
  82630. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82631. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82632. */
  82633. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82634. /** @hidden */
  82635. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82636. /** @hidden */
  82637. readonly _lodTextureMid: Nullable<BaseTexture>;
  82638. /** @hidden */
  82639. readonly _lodTextureLow: Nullable<BaseTexture>;
  82640. /**
  82641. * Dispose the texture and release its associated resources.
  82642. */
  82643. dispose(): void;
  82644. /**
  82645. * Serialize the texture into a JSON representation that can be parsed later on.
  82646. * @returns the JSON representation of the texture
  82647. */
  82648. serialize(): any;
  82649. /**
  82650. * Helper function to be called back once a list of texture contains only ready textures.
  82651. * @param textures Define the list of textures to wait for
  82652. * @param callback Define the callback triggered once the entire list will be ready
  82653. */
  82654. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82655. }
  82656. }
  82657. declare module BABYLON {
  82658. /**
  82659. * Uniform buffer objects.
  82660. *
  82661. * Handles blocks of uniform on the GPU.
  82662. *
  82663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82664. *
  82665. * For more information, please refer to :
  82666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82667. */
  82668. export class UniformBuffer {
  82669. private _engine;
  82670. private _buffer;
  82671. private _data;
  82672. private _bufferData;
  82673. private _dynamic?;
  82674. private _uniformLocations;
  82675. private _uniformSizes;
  82676. private _uniformLocationPointer;
  82677. private _needSync;
  82678. private _noUBO;
  82679. private _currentEffect;
  82680. private static _MAX_UNIFORM_SIZE;
  82681. private static _tempBuffer;
  82682. /**
  82683. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82684. * This is dynamic to allow compat with webgl 1 and 2.
  82685. * You will need to pass the name of the uniform as well as the value.
  82686. */
  82687. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82688. /**
  82689. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82690. * This is dynamic to allow compat with webgl 1 and 2.
  82691. * You will need to pass the name of the uniform as well as the value.
  82692. */
  82693. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82694. /**
  82695. * Lambda to Update a single float in a uniform buffer.
  82696. * This is dynamic to allow compat with webgl 1 and 2.
  82697. * You will need to pass the name of the uniform as well as the value.
  82698. */
  82699. updateFloat: (name: string, x: number) => void;
  82700. /**
  82701. * Lambda to Update a vec2 of float in a uniform buffer.
  82702. * This is dynamic to allow compat with webgl 1 and 2.
  82703. * You will need to pass the name of the uniform as well as the value.
  82704. */
  82705. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82706. /**
  82707. * Lambda to Update a vec3 of float in a uniform buffer.
  82708. * This is dynamic to allow compat with webgl 1 and 2.
  82709. * You will need to pass the name of the uniform as well as the value.
  82710. */
  82711. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82712. /**
  82713. * Lambda to Update a vec4 of float in a uniform buffer.
  82714. * This is dynamic to allow compat with webgl 1 and 2.
  82715. * You will need to pass the name of the uniform as well as the value.
  82716. */
  82717. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82718. /**
  82719. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82720. * This is dynamic to allow compat with webgl 1 and 2.
  82721. * You will need to pass the name of the uniform as well as the value.
  82722. */
  82723. updateMatrix: (name: string, mat: Matrix) => void;
  82724. /**
  82725. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82726. * This is dynamic to allow compat with webgl 1 and 2.
  82727. * You will need to pass the name of the uniform as well as the value.
  82728. */
  82729. updateVector3: (name: string, vector: Vector3) => void;
  82730. /**
  82731. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82732. * This is dynamic to allow compat with webgl 1 and 2.
  82733. * You will need to pass the name of the uniform as well as the value.
  82734. */
  82735. updateVector4: (name: string, vector: Vector4) => void;
  82736. /**
  82737. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82738. * This is dynamic to allow compat with webgl 1 and 2.
  82739. * You will need to pass the name of the uniform as well as the value.
  82740. */
  82741. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82742. /**
  82743. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82744. * This is dynamic to allow compat with webgl 1 and 2.
  82745. * You will need to pass the name of the uniform as well as the value.
  82746. */
  82747. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82748. /**
  82749. * Instantiates a new Uniform buffer objects.
  82750. *
  82751. * Handles blocks of uniform on the GPU.
  82752. *
  82753. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82754. *
  82755. * For more information, please refer to :
  82756. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82757. * @param engine Define the engine the buffer is associated with
  82758. * @param data Define the data contained in the buffer
  82759. * @param dynamic Define if the buffer is updatable
  82760. */
  82761. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82762. /**
  82763. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82764. * or just falling back on setUniformXXX calls.
  82765. */
  82766. readonly useUbo: boolean;
  82767. /**
  82768. * Indicates if the WebGL underlying uniform buffer is in sync
  82769. * with the javascript cache data.
  82770. */
  82771. readonly isSync: boolean;
  82772. /**
  82773. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82774. * Also, a dynamic UniformBuffer will disable cache verification and always
  82775. * update the underlying WebGL uniform buffer to the GPU.
  82776. * @returns if Dynamic, otherwise false
  82777. */
  82778. isDynamic(): boolean;
  82779. /**
  82780. * The data cache on JS side.
  82781. * @returns the underlying data as a float array
  82782. */
  82783. getData(): Float32Array;
  82784. /**
  82785. * The underlying WebGL Uniform buffer.
  82786. * @returns the webgl buffer
  82787. */
  82788. getBuffer(): Nullable<WebGLBuffer>;
  82789. /**
  82790. * std140 layout specifies how to align data within an UBO structure.
  82791. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82792. * for specs.
  82793. */
  82794. private _fillAlignment;
  82795. /**
  82796. * Adds an uniform in the buffer.
  82797. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82798. * for the layout to be correct !
  82799. * @param name Name of the uniform, as used in the uniform block in the shader.
  82800. * @param size Data size, or data directly.
  82801. */
  82802. addUniform(name: string, size: number | number[]): void;
  82803. /**
  82804. * Adds a Matrix 4x4 to the uniform buffer.
  82805. * @param name Name of the uniform, as used in the uniform block in the shader.
  82806. * @param mat A 4x4 matrix.
  82807. */
  82808. addMatrix(name: string, mat: Matrix): void;
  82809. /**
  82810. * Adds a vec2 to the uniform buffer.
  82811. * @param name Name of the uniform, as used in the uniform block in the shader.
  82812. * @param x Define the x component value of the vec2
  82813. * @param y Define the y component value of the vec2
  82814. */
  82815. addFloat2(name: string, x: number, y: number): void;
  82816. /**
  82817. * Adds a vec3 to the uniform buffer.
  82818. * @param name Name of the uniform, as used in the uniform block in the shader.
  82819. * @param x Define the x component value of the vec3
  82820. * @param y Define the y component value of the vec3
  82821. * @param z Define the z component value of the vec3
  82822. */
  82823. addFloat3(name: string, x: number, y: number, z: number): void;
  82824. /**
  82825. * Adds a vec3 to the uniform buffer.
  82826. * @param name Name of the uniform, as used in the uniform block in the shader.
  82827. * @param color Define the vec3 from a Color
  82828. */
  82829. addColor3(name: string, color: Color3): void;
  82830. /**
  82831. * Adds a vec4 to the uniform buffer.
  82832. * @param name Name of the uniform, as used in the uniform block in the shader.
  82833. * @param color Define the rgb components from a Color
  82834. * @param alpha Define the a component of the vec4
  82835. */
  82836. addColor4(name: string, color: Color3, alpha: number): void;
  82837. /**
  82838. * Adds a vec3 to the uniform buffer.
  82839. * @param name Name of the uniform, as used in the uniform block in the shader.
  82840. * @param vector Define the vec3 components from a Vector
  82841. */
  82842. addVector3(name: string, vector: Vector3): void;
  82843. /**
  82844. * Adds a Matrix 3x3 to the uniform buffer.
  82845. * @param name Name of the uniform, as used in the uniform block in the shader.
  82846. */
  82847. addMatrix3x3(name: string): void;
  82848. /**
  82849. * Adds a Matrix 2x2 to the uniform buffer.
  82850. * @param name Name of the uniform, as used in the uniform block in the shader.
  82851. */
  82852. addMatrix2x2(name: string): void;
  82853. /**
  82854. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82855. */
  82856. create(): void;
  82857. /** @hidden */
  82858. _rebuild(): void;
  82859. /**
  82860. * Updates the WebGL Uniform Buffer on the GPU.
  82861. * If the `dynamic` flag is set to true, no cache comparison is done.
  82862. * Otherwise, the buffer will be updated only if the cache differs.
  82863. */
  82864. update(): void;
  82865. /**
  82866. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82868. * @param data Define the flattened data
  82869. * @param size Define the size of the data.
  82870. */
  82871. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82872. private _updateMatrix3x3ForUniform;
  82873. private _updateMatrix3x3ForEffect;
  82874. private _updateMatrix2x2ForEffect;
  82875. private _updateMatrix2x2ForUniform;
  82876. private _updateFloatForEffect;
  82877. private _updateFloatForUniform;
  82878. private _updateFloat2ForEffect;
  82879. private _updateFloat2ForUniform;
  82880. private _updateFloat3ForEffect;
  82881. private _updateFloat3ForUniform;
  82882. private _updateFloat4ForEffect;
  82883. private _updateFloat4ForUniform;
  82884. private _updateMatrixForEffect;
  82885. private _updateMatrixForUniform;
  82886. private _updateVector3ForEffect;
  82887. private _updateVector3ForUniform;
  82888. private _updateVector4ForEffect;
  82889. private _updateVector4ForUniform;
  82890. private _updateColor3ForEffect;
  82891. private _updateColor3ForUniform;
  82892. private _updateColor4ForEffect;
  82893. private _updateColor4ForUniform;
  82894. /**
  82895. * Sets a sampler uniform on the effect.
  82896. * @param name Define the name of the sampler.
  82897. * @param texture Define the texture to set in the sampler
  82898. */
  82899. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82900. /**
  82901. * Directly updates the value of the uniform in the cache AND on the GPU.
  82902. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82903. * @param data Define the flattened data
  82904. */
  82905. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82906. /**
  82907. * Binds this uniform buffer to an effect.
  82908. * @param effect Define the effect to bind the buffer to
  82909. * @param name Name of the uniform block in the shader.
  82910. */
  82911. bindToEffect(effect: Effect, name: string): void;
  82912. /**
  82913. * Disposes the uniform buffer.
  82914. */
  82915. dispose(): void;
  82916. }
  82917. }
  82918. declare module BABYLON {
  82919. /**
  82920. * This represents the required contract to create a new type of texture loader.
  82921. */
  82922. export interface IInternalTextureLoader {
  82923. /**
  82924. * Defines wether the loader supports cascade loading the different faces.
  82925. */
  82926. supportCascades: boolean;
  82927. /**
  82928. * This returns if the loader support the current file information.
  82929. * @param extension defines the file extension of the file being loaded
  82930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82931. * @param fallback defines the fallback internal texture if any
  82932. * @param isBase64 defines whether the texture is encoded as a base64
  82933. * @param isBuffer defines whether the texture data are stored as a buffer
  82934. * @returns true if the loader can load the specified file
  82935. */
  82936. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82937. /**
  82938. * Transform the url before loading if required.
  82939. * @param rootUrl the url of the texture
  82940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82941. * @returns the transformed texture
  82942. */
  82943. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82944. /**
  82945. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82946. * @param rootUrl the url of the texture
  82947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82948. * @returns the fallback texture
  82949. */
  82950. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82951. /**
  82952. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82953. * @param data contains the texture data
  82954. * @param texture defines the BabylonJS internal texture
  82955. * @param createPolynomials will be true if polynomials have been requested
  82956. * @param onLoad defines the callback to trigger once the texture is ready
  82957. * @param onError defines the callback to trigger in case of error
  82958. */
  82959. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82960. /**
  82961. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82962. * @param data contains the texture data
  82963. * @param texture defines the BabylonJS internal texture
  82964. * @param callback defines the method to call once ready to upload
  82965. */
  82966. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82967. }
  82968. }
  82969. declare module BABYLON {
  82970. /**
  82971. * Creation options of the multi render target texture.
  82972. */
  82973. export interface IMultiRenderTargetOptions {
  82974. /**
  82975. * Define if the texture needs to create mip maps after render.
  82976. */
  82977. generateMipMaps?: boolean;
  82978. /**
  82979. * Define the types of all the draw buffers we want to create
  82980. */
  82981. types?: number[];
  82982. /**
  82983. * Define the sampling modes of all the draw buffers we want to create
  82984. */
  82985. samplingModes?: number[];
  82986. /**
  82987. * Define if a depth buffer is required
  82988. */
  82989. generateDepthBuffer?: boolean;
  82990. /**
  82991. * Define if a stencil buffer is required
  82992. */
  82993. generateStencilBuffer?: boolean;
  82994. /**
  82995. * Define if a depth texture is required instead of a depth buffer
  82996. */
  82997. generateDepthTexture?: boolean;
  82998. /**
  82999. * Define the number of desired draw buffers
  83000. */
  83001. textureCount?: number;
  83002. /**
  83003. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83004. */
  83005. doNotChangeAspectRatio?: boolean;
  83006. /**
  83007. * Define the default type of the buffers we are creating
  83008. */
  83009. defaultType?: number;
  83010. }
  83011. /**
  83012. * A multi render target, like a render target provides the ability to render to a texture.
  83013. * Unlike the render target, it can render to several draw buffers in one draw.
  83014. * This is specially interesting in deferred rendering or for any effects requiring more than
  83015. * just one color from a single pass.
  83016. */
  83017. export class MultiRenderTarget extends RenderTargetTexture {
  83018. private _internalTextures;
  83019. private _textures;
  83020. private _multiRenderTargetOptions;
  83021. /**
  83022. * Get if draw buffers are currently supported by the used hardware and browser.
  83023. */
  83024. readonly isSupported: boolean;
  83025. /**
  83026. * Get the list of textures generated by the multi render target.
  83027. */
  83028. readonly textures: Texture[];
  83029. /**
  83030. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83031. */
  83032. readonly depthTexture: Texture;
  83033. /**
  83034. * Set the wrapping mode on U of all the textures we are rendering to.
  83035. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83036. */
  83037. wrapU: number;
  83038. /**
  83039. * Set the wrapping mode on V of all the textures we are rendering to.
  83040. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83041. */
  83042. wrapV: number;
  83043. /**
  83044. * Instantiate a new multi render target texture.
  83045. * A multi render target, like a render target provides the ability to render to a texture.
  83046. * Unlike the render target, it can render to several draw buffers in one draw.
  83047. * This is specially interesting in deferred rendering or for any effects requiring more than
  83048. * just one color from a single pass.
  83049. * @param name Define the name of the texture
  83050. * @param size Define the size of the buffers to render to
  83051. * @param count Define the number of target we are rendering into
  83052. * @param scene Define the scene the texture belongs to
  83053. * @param options Define the options used to create the multi render target
  83054. */
  83055. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83056. /** @hidden */
  83057. _rebuild(): void;
  83058. private _createInternalTextures;
  83059. private _createTextures;
  83060. /**
  83061. * Define the number of samples used if MSAA is enabled.
  83062. */
  83063. samples: number;
  83064. /**
  83065. * Resize all the textures in the multi render target.
  83066. * Be carrefull as it will recreate all the data in the new texture.
  83067. * @param size Define the new size
  83068. */
  83069. resize(size: any): void;
  83070. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83071. /**
  83072. * Dispose the render targets and their associated resources
  83073. */
  83074. dispose(): void;
  83075. /**
  83076. * Release all the underlying texture used as draw buffers.
  83077. */
  83078. releaseInternalTextures(): void;
  83079. }
  83080. }
  83081. declare module BABYLON {
  83082. /**
  83083. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83085. */
  83086. export class Analyser {
  83087. /**
  83088. * Gets or sets the smoothing
  83089. * @ignorenaming
  83090. */
  83091. SMOOTHING: number;
  83092. /**
  83093. * Gets or sets the FFT table size
  83094. * @ignorenaming
  83095. */
  83096. FFT_SIZE: number;
  83097. /**
  83098. * Gets or sets the bar graph amplitude
  83099. * @ignorenaming
  83100. */
  83101. BARGRAPHAMPLITUDE: number;
  83102. /**
  83103. * Gets or sets the position of the debug canvas
  83104. * @ignorenaming
  83105. */
  83106. DEBUGCANVASPOS: {
  83107. x: number;
  83108. y: number;
  83109. };
  83110. /**
  83111. * Gets or sets the debug canvas size
  83112. * @ignorenaming
  83113. */
  83114. DEBUGCANVASSIZE: {
  83115. width: number;
  83116. height: number;
  83117. };
  83118. private _byteFreqs;
  83119. private _byteTime;
  83120. private _floatFreqs;
  83121. private _webAudioAnalyser;
  83122. private _debugCanvas;
  83123. private _debugCanvasContext;
  83124. private _scene;
  83125. private _registerFunc;
  83126. private _audioEngine;
  83127. /**
  83128. * Creates a new analyser
  83129. * @param scene defines hosting scene
  83130. */
  83131. constructor(scene: Scene);
  83132. /**
  83133. * Get the number of data values you will have to play with for the visualization
  83134. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83135. * @returns a number
  83136. */
  83137. getFrequencyBinCount(): number;
  83138. /**
  83139. * Gets the current frequency data as a byte array
  83140. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83141. * @returns a Uint8Array
  83142. */
  83143. getByteFrequencyData(): Uint8Array;
  83144. /**
  83145. * Gets the current waveform as a byte array
  83146. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83147. * @returns a Uint8Array
  83148. */
  83149. getByteTimeDomainData(): Uint8Array;
  83150. /**
  83151. * Gets the current frequency data as a float array
  83152. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83153. * @returns a Float32Array
  83154. */
  83155. getFloatFrequencyData(): Float32Array;
  83156. /**
  83157. * Renders the debug canvas
  83158. */
  83159. drawDebugCanvas(): void;
  83160. /**
  83161. * Stops rendering the debug canvas and removes it
  83162. */
  83163. stopDebugCanvas(): void;
  83164. /**
  83165. * Connects two audio nodes
  83166. * @param inputAudioNode defines first node to connect
  83167. * @param outputAudioNode defines second node to connect
  83168. */
  83169. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83170. /**
  83171. * Releases all associated resources
  83172. */
  83173. dispose(): void;
  83174. }
  83175. }
  83176. declare module BABYLON {
  83177. /**
  83178. * This represents an audio engine and it is responsible
  83179. * to play, synchronize and analyse sounds throughout the application.
  83180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83181. */
  83182. export interface IAudioEngine extends IDisposable {
  83183. /**
  83184. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83185. */
  83186. readonly canUseWebAudio: boolean;
  83187. /**
  83188. * Gets the current AudioContext if available.
  83189. */
  83190. readonly audioContext: Nullable<AudioContext>;
  83191. /**
  83192. * The master gain node defines the global audio volume of your audio engine.
  83193. */
  83194. readonly masterGain: GainNode;
  83195. /**
  83196. * Gets whether or not mp3 are supported by your browser.
  83197. */
  83198. readonly isMP3supported: boolean;
  83199. /**
  83200. * Gets whether or not ogg are supported by your browser.
  83201. */
  83202. readonly isOGGsupported: boolean;
  83203. /**
  83204. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83205. * @ignoreNaming
  83206. */
  83207. WarnedWebAudioUnsupported: boolean;
  83208. /**
  83209. * Defines if the audio engine relies on a custom unlocked button.
  83210. * In this case, the embedded button will not be displayed.
  83211. */
  83212. useCustomUnlockedButton: boolean;
  83213. /**
  83214. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83215. */
  83216. readonly unlocked: boolean;
  83217. /**
  83218. * Event raised when audio has been unlocked on the browser.
  83219. */
  83220. onAudioUnlockedObservable: Observable<AudioEngine>;
  83221. /**
  83222. * Event raised when audio has been locked on the browser.
  83223. */
  83224. onAudioLockedObservable: Observable<AudioEngine>;
  83225. /**
  83226. * Flags the audio engine in Locked state.
  83227. * This happens due to new browser policies preventing audio to autoplay.
  83228. */
  83229. lock(): void;
  83230. /**
  83231. * Unlocks the audio engine once a user action has been done on the dom.
  83232. * This is helpful to resume play once browser policies have been satisfied.
  83233. */
  83234. unlock(): void;
  83235. }
  83236. /**
  83237. * This represents the default audio engine used in babylon.
  83238. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83240. */
  83241. export class AudioEngine implements IAudioEngine {
  83242. private _audioContext;
  83243. private _audioContextInitialized;
  83244. private _muteButton;
  83245. private _hostElement;
  83246. /**
  83247. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83248. */
  83249. canUseWebAudio: boolean;
  83250. /**
  83251. * The master gain node defines the global audio volume of your audio engine.
  83252. */
  83253. masterGain: GainNode;
  83254. /**
  83255. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83256. * @ignoreNaming
  83257. */
  83258. WarnedWebAudioUnsupported: boolean;
  83259. /**
  83260. * Gets whether or not mp3 are supported by your browser.
  83261. */
  83262. isMP3supported: boolean;
  83263. /**
  83264. * Gets whether or not ogg are supported by your browser.
  83265. */
  83266. isOGGsupported: boolean;
  83267. /**
  83268. * Gets whether audio has been unlocked on the device.
  83269. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83270. * a user interaction has happened.
  83271. */
  83272. unlocked: boolean;
  83273. /**
  83274. * Defines if the audio engine relies on a custom unlocked button.
  83275. * In this case, the embedded button will not be displayed.
  83276. */
  83277. useCustomUnlockedButton: boolean;
  83278. /**
  83279. * Event raised when audio has been unlocked on the browser.
  83280. */
  83281. onAudioUnlockedObservable: Observable<AudioEngine>;
  83282. /**
  83283. * Event raised when audio has been locked on the browser.
  83284. */
  83285. onAudioLockedObservable: Observable<AudioEngine>;
  83286. /**
  83287. * Gets the current AudioContext if available.
  83288. */
  83289. readonly audioContext: Nullable<AudioContext>;
  83290. private _connectedAnalyser;
  83291. /**
  83292. * Instantiates a new audio engine.
  83293. *
  83294. * There should be only one per page as some browsers restrict the number
  83295. * of audio contexts you can create.
  83296. * @param hostElement defines the host element where to display the mute icon if necessary
  83297. */
  83298. constructor(hostElement?: Nullable<HTMLElement>);
  83299. /**
  83300. * Flags the audio engine in Locked state.
  83301. * This happens due to new browser policies preventing audio to autoplay.
  83302. */
  83303. lock(): void;
  83304. /**
  83305. * Unlocks the audio engine once a user action has been done on the dom.
  83306. * This is helpful to resume play once browser policies have been satisfied.
  83307. */
  83308. unlock(): void;
  83309. private _resumeAudioContext;
  83310. private _initializeAudioContext;
  83311. private _tryToRun;
  83312. private _triggerRunningState;
  83313. private _triggerSuspendedState;
  83314. private _displayMuteButton;
  83315. private _moveButtonToTopLeft;
  83316. private _onResize;
  83317. private _hideMuteButton;
  83318. /**
  83319. * Destroy and release the resources associated with the audio ccontext.
  83320. */
  83321. dispose(): void;
  83322. /**
  83323. * Gets the global volume sets on the master gain.
  83324. * @returns the global volume if set or -1 otherwise
  83325. */
  83326. getGlobalVolume(): number;
  83327. /**
  83328. * Sets the global volume of your experience (sets on the master gain).
  83329. * @param newVolume Defines the new global volume of the application
  83330. */
  83331. setGlobalVolume(newVolume: number): void;
  83332. /**
  83333. * Connect the audio engine to an audio analyser allowing some amazing
  83334. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83336. * @param analyser The analyser to connect to the engine
  83337. */
  83338. connectToAnalyser(analyser: Analyser): void;
  83339. }
  83340. }
  83341. declare module BABYLON {
  83342. /**
  83343. * Interface used to present a loading screen while loading a scene
  83344. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83345. */
  83346. export interface ILoadingScreen {
  83347. /**
  83348. * Function called to display the loading screen
  83349. */
  83350. displayLoadingUI: () => void;
  83351. /**
  83352. * Function called to hide the loading screen
  83353. */
  83354. hideLoadingUI: () => void;
  83355. /**
  83356. * Gets or sets the color to use for the background
  83357. */
  83358. loadingUIBackgroundColor: string;
  83359. /**
  83360. * Gets or sets the text to display while loading
  83361. */
  83362. loadingUIText: string;
  83363. }
  83364. /**
  83365. * Class used for the default loading screen
  83366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83367. */
  83368. export class DefaultLoadingScreen implements ILoadingScreen {
  83369. private _renderingCanvas;
  83370. private _loadingText;
  83371. private _loadingDivBackgroundColor;
  83372. private _loadingDiv;
  83373. private _loadingTextDiv;
  83374. /**
  83375. * Creates a new default loading screen
  83376. * @param _renderingCanvas defines the canvas used to render the scene
  83377. * @param _loadingText defines the default text to display
  83378. * @param _loadingDivBackgroundColor defines the default background color
  83379. */
  83380. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83381. /**
  83382. * Function called to display the loading screen
  83383. */
  83384. displayLoadingUI(): void;
  83385. /**
  83386. * Function called to hide the loading screen
  83387. */
  83388. hideLoadingUI(): void;
  83389. /**
  83390. * Gets or sets the text to display while loading
  83391. */
  83392. loadingUIText: string;
  83393. /**
  83394. * Gets or sets the color to use for the background
  83395. */
  83396. loadingUIBackgroundColor: string;
  83397. private _resizeLoadingUI;
  83398. }
  83399. }
  83400. declare module BABYLON {
  83401. /**
  83402. * Settings for finer control over video usage
  83403. */
  83404. export interface VideoTextureSettings {
  83405. /**
  83406. * Applies `autoplay` to video, if specified
  83407. */
  83408. autoPlay?: boolean;
  83409. /**
  83410. * Applies `loop` to video, if specified
  83411. */
  83412. loop?: boolean;
  83413. /**
  83414. * Automatically updates internal texture from video at every frame in the render loop
  83415. */
  83416. autoUpdateTexture: boolean;
  83417. /**
  83418. * Image src displayed during the video loading or until the user interacts with the video.
  83419. */
  83420. poster?: string;
  83421. }
  83422. /**
  83423. * If you want to display a video in your scene, this is the special texture for that.
  83424. * This special texture works similar to other textures, with the exception of a few parameters.
  83425. * @see https://doc.babylonjs.com/how_to/video_texture
  83426. */
  83427. export class VideoTexture extends Texture {
  83428. /**
  83429. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83430. */
  83431. readonly autoUpdateTexture: boolean;
  83432. /**
  83433. * The video instance used by the texture internally
  83434. */
  83435. readonly video: HTMLVideoElement;
  83436. private _onUserActionRequestedObservable;
  83437. /**
  83438. * Event triggerd when a dom action is required by the user to play the video.
  83439. * This happens due to recent changes in browser policies preventing video to auto start.
  83440. */
  83441. readonly onUserActionRequestedObservable: Observable<Texture>;
  83442. private _generateMipMaps;
  83443. private _engine;
  83444. private _stillImageCaptured;
  83445. private _displayingPosterTexture;
  83446. private _settings;
  83447. private _createInternalTextureOnEvent;
  83448. /**
  83449. * Creates a video texture.
  83450. * If you want to display a video in your scene, this is the special texture for that.
  83451. * This special texture works similar to other textures, with the exception of a few parameters.
  83452. * @see https://doc.babylonjs.com/how_to/video_texture
  83453. * @param name optional name, will detect from video source, if not defined
  83454. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83455. * @param scene is obviously the current scene.
  83456. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83457. * @param invertY is false by default but can be used to invert video on Y axis
  83458. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83459. * @param settings allows finer control over video usage
  83460. */
  83461. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83462. private _getName;
  83463. private _getVideo;
  83464. private _createInternalTexture;
  83465. private reset;
  83466. /**
  83467. * @hidden Internal method to initiate `update`.
  83468. */
  83469. _rebuild(): void;
  83470. /**
  83471. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83472. */
  83473. update(): void;
  83474. /**
  83475. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83476. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83477. */
  83478. updateTexture(isVisible: boolean): void;
  83479. protected _updateInternalTexture: () => void;
  83480. /**
  83481. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83482. * @param url New url.
  83483. */
  83484. updateURL(url: string): void;
  83485. /**
  83486. * Dispose the texture and release its associated resources.
  83487. */
  83488. dispose(): void;
  83489. /**
  83490. * Creates a video texture straight from a stream.
  83491. * @param scene Define the scene the texture should be created in
  83492. * @param stream Define the stream the texture should be created from
  83493. * @returns The created video texture as a promise
  83494. */
  83495. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83496. /**
  83497. * Creates a video texture straight from your WebCam video feed.
  83498. * @param scene Define the scene the texture should be created in
  83499. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83500. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83501. * @returns The created video texture as a promise
  83502. */
  83503. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83504. minWidth: number;
  83505. maxWidth: number;
  83506. minHeight: number;
  83507. maxHeight: number;
  83508. deviceId: string;
  83509. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83510. /**
  83511. * Creates a video texture straight from your WebCam video feed.
  83512. * @param scene Define the scene the texture should be created in
  83513. * @param onReady Define a callback to triggered once the texture will be ready
  83514. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83515. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83516. */
  83517. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83518. minWidth: number;
  83519. maxWidth: number;
  83520. minHeight: number;
  83521. maxHeight: number;
  83522. deviceId: string;
  83523. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83524. }
  83525. }
  83526. declare module BABYLON {
  83527. /**
  83528. * Interface for attribute information associated with buffer instanciation
  83529. */
  83530. export class InstancingAttributeInfo {
  83531. /**
  83532. * Index/offset of the attribute in the vertex shader
  83533. */
  83534. index: number;
  83535. /**
  83536. * size of the attribute, 1, 2, 3 or 4
  83537. */
  83538. attributeSize: number;
  83539. /**
  83540. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83541. * default is FLOAT
  83542. */
  83543. attribyteType: number;
  83544. /**
  83545. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83546. */
  83547. normalized: boolean;
  83548. /**
  83549. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83550. */
  83551. offset: number;
  83552. /**
  83553. * Name of the GLSL attribute, for debugging purpose only
  83554. */
  83555. attributeName: string;
  83556. }
  83557. /**
  83558. * Define options used to create a depth texture
  83559. */
  83560. export class DepthTextureCreationOptions {
  83561. /** Specifies whether or not a stencil should be allocated in the texture */
  83562. generateStencil?: boolean;
  83563. /** Specifies whether or not bilinear filtering is enable on the texture */
  83564. bilinearFiltering?: boolean;
  83565. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83566. comparisonFunction?: number;
  83567. /** Specifies if the created texture is a cube texture */
  83568. isCube?: boolean;
  83569. }
  83570. /**
  83571. * Class used to describe the capabilities of the engine relatively to the current browser
  83572. */
  83573. export class EngineCapabilities {
  83574. /** Maximum textures units per fragment shader */
  83575. maxTexturesImageUnits: number;
  83576. /** Maximum texture units per vertex shader */
  83577. maxVertexTextureImageUnits: number;
  83578. /** Maximum textures units in the entire pipeline */
  83579. maxCombinedTexturesImageUnits: number;
  83580. /** Maximum texture size */
  83581. maxTextureSize: number;
  83582. /** Maximum cube texture size */
  83583. maxCubemapTextureSize: number;
  83584. /** Maximum render texture size */
  83585. maxRenderTextureSize: number;
  83586. /** Maximum number of vertex attributes */
  83587. maxVertexAttribs: number;
  83588. /** Maximum number of varyings */
  83589. maxVaryingVectors: number;
  83590. /** Maximum number of uniforms per vertex shader */
  83591. maxVertexUniformVectors: number;
  83592. /** Maximum number of uniforms per fragment shader */
  83593. maxFragmentUniformVectors: number;
  83594. /** Defines if standard derivates (dx/dy) are supported */
  83595. standardDerivatives: boolean;
  83596. /** Defines if s3tc texture compression is supported */
  83597. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83598. /** Defines if pvrtc texture compression is supported */
  83599. pvrtc: any;
  83600. /** Defines if etc1 texture compression is supported */
  83601. etc1: any;
  83602. /** Defines if etc2 texture compression is supported */
  83603. etc2: any;
  83604. /** Defines if astc texture compression is supported */
  83605. astc: any;
  83606. /** Defines if float textures are supported */
  83607. textureFloat: boolean;
  83608. /** Defines if vertex array objects are supported */
  83609. vertexArrayObject: boolean;
  83610. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83611. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83612. /** Gets the maximum level of anisotropy supported */
  83613. maxAnisotropy: number;
  83614. /** Defines if instancing is supported */
  83615. instancedArrays: boolean;
  83616. /** Defines if 32 bits indices are supported */
  83617. uintIndices: boolean;
  83618. /** Defines if high precision shaders are supported */
  83619. highPrecisionShaderSupported: boolean;
  83620. /** Defines if depth reading in the fragment shader is supported */
  83621. fragmentDepthSupported: boolean;
  83622. /** Defines if float texture linear filtering is supported*/
  83623. textureFloatLinearFiltering: boolean;
  83624. /** Defines if rendering to float textures is supported */
  83625. textureFloatRender: boolean;
  83626. /** Defines if half float textures are supported*/
  83627. textureHalfFloat: boolean;
  83628. /** Defines if half float texture linear filtering is supported*/
  83629. textureHalfFloatLinearFiltering: boolean;
  83630. /** Defines if rendering to half float textures is supported */
  83631. textureHalfFloatRender: boolean;
  83632. /** Defines if textureLOD shader command is supported */
  83633. textureLOD: boolean;
  83634. /** Defines if draw buffers extension is supported */
  83635. drawBuffersExtension: boolean;
  83636. /** Defines if depth textures are supported */
  83637. depthTextureExtension: boolean;
  83638. /** Defines if float color buffer are supported */
  83639. colorBufferFloat: boolean;
  83640. /** Gets disjoint timer query extension (null if not supported) */
  83641. timerQuery: EXT_disjoint_timer_query;
  83642. /** Defines if timestamp can be used with timer query */
  83643. canUseTimestampForTimerQuery: boolean;
  83644. /** Function used to let the system compiles shaders in background */
  83645. parallelShaderCompile: {
  83646. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83647. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83648. COMPLETION_STATUS_KHR: number;
  83649. };
  83650. }
  83651. /** Interface defining initialization parameters for Engine class */
  83652. export interface EngineOptions extends WebGLContextAttributes {
  83653. /**
  83654. * Defines if the engine should no exceed a specified device ratio
  83655. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83656. */
  83657. limitDeviceRatio?: number;
  83658. /**
  83659. * Defines if webvr should be enabled automatically
  83660. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83661. */
  83662. autoEnableWebVR?: boolean;
  83663. /**
  83664. * Defines if webgl2 should be turned off even if supported
  83665. * @see http://doc.babylonjs.com/features/webgl2
  83666. */
  83667. disableWebGL2Support?: boolean;
  83668. /**
  83669. * Defines if webaudio should be initialized as well
  83670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83671. */
  83672. audioEngine?: boolean;
  83673. /**
  83674. * Defines if animations should run using a deterministic lock step
  83675. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83676. */
  83677. deterministicLockstep?: boolean;
  83678. /** Defines the maximum steps to use with deterministic lock step mode */
  83679. lockstepMaxSteps?: number;
  83680. /**
  83681. * Defines that engine should ignore context lost events
  83682. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83683. */
  83684. doNotHandleContextLost?: boolean;
  83685. /**
  83686. * Defines that engine should ignore modifying touch action attribute and style
  83687. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83688. */
  83689. doNotHandleTouchAction?: boolean;
  83690. }
  83691. /**
  83692. * Defines the interface used by display changed events
  83693. */
  83694. export interface IDisplayChangedEventArgs {
  83695. /** Gets the vrDisplay object (if any) */
  83696. vrDisplay: Nullable<any>;
  83697. /** Gets a boolean indicating if webVR is supported */
  83698. vrSupported: boolean;
  83699. }
  83700. /**
  83701. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83702. */
  83703. export class Engine {
  83704. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83705. static ExceptionList: ({
  83706. key: string;
  83707. capture: string;
  83708. captureConstraint: number;
  83709. targets: string[];
  83710. } | {
  83711. key: string;
  83712. capture: null;
  83713. captureConstraint: null;
  83714. targets: string[];
  83715. })[];
  83716. /** Gets the list of created engines */
  83717. static readonly Instances: Engine[];
  83718. /**
  83719. * Gets the latest created engine
  83720. */
  83721. static readonly LastCreatedEngine: Nullable<Engine>;
  83722. /**
  83723. * Gets the latest created scene
  83724. */
  83725. static readonly LastCreatedScene: Nullable<Scene>;
  83726. /**
  83727. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83728. * @param flag defines which part of the materials must be marked as dirty
  83729. * @param predicate defines a predicate used to filter which materials should be affected
  83730. */
  83731. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83732. /**
  83733. * Hidden
  83734. */
  83735. static _TextureLoaders: IInternalTextureLoader[];
  83736. /** Defines that alpha blending is disabled */
  83737. static readonly ALPHA_DISABLE: number;
  83738. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83739. static readonly ALPHA_ADD: number;
  83740. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83741. static readonly ALPHA_COMBINE: number;
  83742. /** Defines that alpha blending to DEST - SRC * DEST */
  83743. static readonly ALPHA_SUBTRACT: number;
  83744. /** Defines that alpha blending to SRC * DEST */
  83745. static readonly ALPHA_MULTIPLY: number;
  83746. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83747. static readonly ALPHA_MAXIMIZED: number;
  83748. /** Defines that alpha blending to SRC + DEST */
  83749. static readonly ALPHA_ONEONE: number;
  83750. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83751. static readonly ALPHA_PREMULTIPLIED: number;
  83752. /**
  83753. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83754. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83755. */
  83756. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83757. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83758. static readonly ALPHA_INTERPOLATE: number;
  83759. /**
  83760. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83761. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83762. */
  83763. static readonly ALPHA_SCREENMODE: number;
  83764. /** Defines that the ressource is not delayed*/
  83765. static readonly DELAYLOADSTATE_NONE: number;
  83766. /** Defines that the ressource was successfully delay loaded */
  83767. static readonly DELAYLOADSTATE_LOADED: number;
  83768. /** Defines that the ressource is currently delay loading */
  83769. static readonly DELAYLOADSTATE_LOADING: number;
  83770. /** Defines that the ressource is delayed and has not started loading */
  83771. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83772. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83773. static readonly NEVER: number;
  83774. /** 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 */
  83775. static readonly ALWAYS: number;
  83776. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83777. static readonly LESS: number;
  83778. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83779. static readonly EQUAL: number;
  83780. /** 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 */
  83781. static readonly LEQUAL: number;
  83782. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83783. static readonly GREATER: number;
  83784. /** 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 */
  83785. static readonly GEQUAL: number;
  83786. /** 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 */
  83787. static readonly NOTEQUAL: number;
  83788. /** Passed to stencilOperation to specify that stencil value must be kept */
  83789. static readonly KEEP: number;
  83790. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83791. static readonly REPLACE: number;
  83792. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83793. static readonly INCR: number;
  83794. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83795. static readonly DECR: number;
  83796. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83797. static readonly INVERT: number;
  83798. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83799. static readonly INCR_WRAP: number;
  83800. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83801. static readonly DECR_WRAP: number;
  83802. /** Texture is not repeating outside of 0..1 UVs */
  83803. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83804. /** Texture is repeating outside of 0..1 UVs */
  83805. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83806. /** Texture is repeating and mirrored */
  83807. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83808. /** ALPHA */
  83809. static readonly TEXTUREFORMAT_ALPHA: number;
  83810. /** LUMINANCE */
  83811. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83812. /** LUMINANCE_ALPHA */
  83813. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83814. /** RGB */
  83815. static readonly TEXTUREFORMAT_RGB: number;
  83816. /** RGBA */
  83817. static readonly TEXTUREFORMAT_RGBA: number;
  83818. /** RED */
  83819. static readonly TEXTUREFORMAT_RED: number;
  83820. /** RED (2nd reference) */
  83821. static readonly TEXTUREFORMAT_R: number;
  83822. /** RG */
  83823. static readonly TEXTUREFORMAT_RG: number;
  83824. /** RED_INTEGER */
  83825. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83826. /** RED_INTEGER (2nd reference) */
  83827. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83828. /** RG_INTEGER */
  83829. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83830. /** RGB_INTEGER */
  83831. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83832. /** RGBA_INTEGER */
  83833. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83834. /** UNSIGNED_BYTE */
  83835. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83836. /** UNSIGNED_BYTE (2nd reference) */
  83837. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83838. /** FLOAT */
  83839. static readonly TEXTURETYPE_FLOAT: number;
  83840. /** HALF_FLOAT */
  83841. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83842. /** BYTE */
  83843. static readonly TEXTURETYPE_BYTE: number;
  83844. /** SHORT */
  83845. static readonly TEXTURETYPE_SHORT: number;
  83846. /** UNSIGNED_SHORT */
  83847. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83848. /** INT */
  83849. static readonly TEXTURETYPE_INT: number;
  83850. /** UNSIGNED_INT */
  83851. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83852. /** UNSIGNED_SHORT_4_4_4_4 */
  83853. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83854. /** UNSIGNED_SHORT_5_5_5_1 */
  83855. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83856. /** UNSIGNED_SHORT_5_6_5 */
  83857. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83858. /** UNSIGNED_INT_2_10_10_10_REV */
  83859. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83860. /** UNSIGNED_INT_24_8 */
  83861. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83862. /** UNSIGNED_INT_10F_11F_11F_REV */
  83863. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83864. /** UNSIGNED_INT_5_9_9_9_REV */
  83865. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83866. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83867. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83868. /** nearest is mag = nearest and min = nearest and mip = linear */
  83869. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83870. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83871. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83872. /** Trilinear is mag = linear and min = linear and mip = linear */
  83873. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83874. /** nearest is mag = nearest and min = nearest and mip = linear */
  83875. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83876. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83877. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83878. /** Trilinear is mag = linear and min = linear and mip = linear */
  83879. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83880. /** mag = nearest and min = nearest and mip = nearest */
  83881. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83882. /** mag = nearest and min = linear and mip = nearest */
  83883. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83884. /** mag = nearest and min = linear and mip = linear */
  83885. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83886. /** mag = nearest and min = linear and mip = none */
  83887. static readonly TEXTURE_NEAREST_LINEAR: number;
  83888. /** mag = nearest and min = nearest and mip = none */
  83889. static readonly TEXTURE_NEAREST_NEAREST: number;
  83890. /** mag = linear and min = nearest and mip = nearest */
  83891. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83892. /** mag = linear and min = nearest and mip = linear */
  83893. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83894. /** mag = linear and min = linear and mip = none */
  83895. static readonly TEXTURE_LINEAR_LINEAR: number;
  83896. /** mag = linear and min = nearest and mip = none */
  83897. static readonly TEXTURE_LINEAR_NEAREST: number;
  83898. /** Explicit coordinates mode */
  83899. static readonly TEXTURE_EXPLICIT_MODE: number;
  83900. /** Spherical coordinates mode */
  83901. static readonly TEXTURE_SPHERICAL_MODE: number;
  83902. /** Planar coordinates mode */
  83903. static readonly TEXTURE_PLANAR_MODE: number;
  83904. /** Cubic coordinates mode */
  83905. static readonly TEXTURE_CUBIC_MODE: number;
  83906. /** Projection coordinates mode */
  83907. static readonly TEXTURE_PROJECTION_MODE: number;
  83908. /** Skybox coordinates mode */
  83909. static readonly TEXTURE_SKYBOX_MODE: number;
  83910. /** Inverse Cubic coordinates mode */
  83911. static readonly TEXTURE_INVCUBIC_MODE: number;
  83912. /** Equirectangular coordinates mode */
  83913. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83914. /** Equirectangular Fixed coordinates mode */
  83915. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83916. /** Equirectangular Fixed Mirrored coordinates mode */
  83917. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83918. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83919. static readonly SCALEMODE_FLOOR: number;
  83920. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83921. static readonly SCALEMODE_NEAREST: number;
  83922. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83923. static readonly SCALEMODE_CEILING: number;
  83924. /**
  83925. * Returns the current version of the framework
  83926. */
  83927. static readonly Version: string;
  83928. /**
  83929. * Returns a string describing the current engine
  83930. */
  83931. readonly description: string;
  83932. /**
  83933. * Gets or sets the epsilon value used by collision engine
  83934. */
  83935. static CollisionsEpsilon: number;
  83936. /**
  83937. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83938. */
  83939. static ShadersRepository: string;
  83940. /**
  83941. * Method called to create the default loading screen.
  83942. * This can be overriden in your own app.
  83943. * @param canvas The rendering canvas element
  83944. * @returns The loading screen
  83945. */
  83946. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83947. /**
  83948. * Method called to create the default rescale post process on each engine.
  83949. */
  83950. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83951. /**
  83952. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83953. */
  83954. forcePOTTextures: boolean;
  83955. /**
  83956. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83957. */
  83958. isFullscreen: boolean;
  83959. /**
  83960. * Gets a boolean indicating if the pointer is currently locked
  83961. */
  83962. isPointerLock: boolean;
  83963. /**
  83964. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83965. */
  83966. cullBackFaces: boolean;
  83967. /**
  83968. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83969. */
  83970. renderEvenInBackground: boolean;
  83971. /**
  83972. * Gets or sets a boolean indicating that cache can be kept between frames
  83973. */
  83974. preventCacheWipeBetweenFrames: boolean;
  83975. /**
  83976. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83977. **/
  83978. enableOfflineSupport: boolean;
  83979. /**
  83980. * 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)
  83981. **/
  83982. disableManifestCheck: boolean;
  83983. /**
  83984. * Gets the list of created scenes
  83985. */
  83986. scenes: Scene[];
  83987. /**
  83988. * Event raised when a new scene is created
  83989. */
  83990. onNewSceneAddedObservable: Observable<Scene>;
  83991. /**
  83992. * Gets the list of created postprocesses
  83993. */
  83994. postProcesses: PostProcess[];
  83995. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83996. validateShaderPrograms: boolean;
  83997. /**
  83998. * Observable event triggered each time the rendering canvas is resized
  83999. */
  84000. onResizeObservable: Observable<Engine>;
  84001. /**
  84002. * Observable event triggered each time the canvas loses focus
  84003. */
  84004. onCanvasBlurObservable: Observable<Engine>;
  84005. /**
  84006. * Observable event triggered each time the canvas gains focus
  84007. */
  84008. onCanvasFocusObservable: Observable<Engine>;
  84009. /**
  84010. * Observable event triggered each time the canvas receives pointerout event
  84011. */
  84012. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84013. /**
  84014. * Observable event triggered before each texture is initialized
  84015. */
  84016. onBeforeTextureInitObservable: Observable<Texture>;
  84017. private _vrDisplay;
  84018. private _vrSupported;
  84019. private _oldSize;
  84020. private _oldHardwareScaleFactor;
  84021. private _vrExclusivePointerMode;
  84022. private _webVRInitPromise;
  84023. /**
  84024. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84025. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84026. */
  84027. readonly isInVRExclusivePointerMode: boolean;
  84028. /**
  84029. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84030. */
  84031. disableUniformBuffers: boolean;
  84032. /** @hidden */
  84033. _uniformBuffers: UniformBuffer[];
  84034. /**
  84035. * Gets a boolean indicating that the engine supports uniform buffers
  84036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84037. */
  84038. readonly supportsUniformBuffers: boolean;
  84039. /**
  84040. * Observable raised when the engine begins a new frame
  84041. */
  84042. onBeginFrameObservable: Observable<Engine>;
  84043. /**
  84044. * If set, will be used to request the next animation frame for the render loop
  84045. */
  84046. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84047. /**
  84048. * Observable raised when the engine ends the current frame
  84049. */
  84050. onEndFrameObservable: Observable<Engine>;
  84051. /**
  84052. * Observable raised when the engine is about to compile a shader
  84053. */
  84054. onBeforeShaderCompilationObservable: Observable<Engine>;
  84055. /**
  84056. * Observable raised when the engine has jsut compiled a shader
  84057. */
  84058. onAfterShaderCompilationObservable: Observable<Engine>;
  84059. /** @hidden */
  84060. _gl: WebGLRenderingContext;
  84061. private _renderingCanvas;
  84062. private _windowIsBackground;
  84063. private _webGLVersion;
  84064. /**
  84065. * Gets a boolean indicating that only power of 2 textures are supported
  84066. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84067. */
  84068. readonly needPOTTextures: boolean;
  84069. /** @hidden */
  84070. _badOS: boolean;
  84071. /** @hidden */
  84072. _badDesktopOS: boolean;
  84073. /**
  84074. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84075. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84076. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84077. */
  84078. disableTextureBindingOptimization: boolean;
  84079. /**
  84080. * Gets the audio engine
  84081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84082. * @ignorenaming
  84083. */
  84084. static audioEngine: IAudioEngine;
  84085. /**
  84086. * Default AudioEngine factory responsible of creating the Audio Engine.
  84087. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84088. */
  84089. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84090. /**
  84091. * Default offline support factory responsible of creating a tool used to store data locally.
  84092. * By default, this will create a Database object if the workload has been embedded.
  84093. */
  84094. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84095. private _onFocus;
  84096. private _onBlur;
  84097. private _onCanvasPointerOut;
  84098. private _onCanvasBlur;
  84099. private _onCanvasFocus;
  84100. private _onFullscreenChange;
  84101. private _onPointerLockChange;
  84102. private _onVRDisplayPointerRestricted;
  84103. private _onVRDisplayPointerUnrestricted;
  84104. private _onVrDisplayConnect;
  84105. private _onVrDisplayDisconnect;
  84106. private _onVrDisplayPresentChange;
  84107. /**
  84108. * Observable signaled when VR display mode changes
  84109. */
  84110. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84111. /**
  84112. * Observable signaled when VR request present is complete
  84113. */
  84114. onVRRequestPresentComplete: Observable<boolean>;
  84115. /**
  84116. * Observable signaled when VR request present starts
  84117. */
  84118. onVRRequestPresentStart: Observable<Engine>;
  84119. private _hardwareScalingLevel;
  84120. /** @hidden */
  84121. protected _caps: EngineCapabilities;
  84122. private _pointerLockRequested;
  84123. private _isStencilEnable;
  84124. private _colorWrite;
  84125. private _loadingScreen;
  84126. /** @hidden */
  84127. _drawCalls: PerfCounter;
  84128. /** @hidden */
  84129. _textureCollisions: PerfCounter;
  84130. private _glVersion;
  84131. private _glRenderer;
  84132. private _glVendor;
  84133. private _videoTextureSupported;
  84134. private _renderingQueueLaunched;
  84135. private _activeRenderLoops;
  84136. private _deterministicLockstep;
  84137. private _lockstepMaxSteps;
  84138. /**
  84139. * Observable signaled when a context lost event is raised
  84140. */
  84141. onContextLostObservable: Observable<Engine>;
  84142. /**
  84143. * Observable signaled when a context restored event is raised
  84144. */
  84145. onContextRestoredObservable: Observable<Engine>;
  84146. private _onContextLost;
  84147. private _onContextRestored;
  84148. private _contextWasLost;
  84149. private _doNotHandleContextLost;
  84150. /**
  84151. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84153. */
  84154. doNotHandleContextLost: boolean;
  84155. private _performanceMonitor;
  84156. private _fps;
  84157. private _deltaTime;
  84158. /**
  84159. * Turn this value on if you want to pause FPS computation when in background
  84160. */
  84161. disablePerformanceMonitorInBackground: boolean;
  84162. /**
  84163. * Gets the performance monitor attached to this engine
  84164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84165. */
  84166. readonly performanceMonitor: PerformanceMonitor;
  84167. /** @hidden */
  84168. protected _depthCullingState: _DepthCullingState;
  84169. /** @hidden */
  84170. protected _stencilState: _StencilState;
  84171. /** @hidden */
  84172. protected _alphaState: _AlphaState;
  84173. /** @hidden */
  84174. protected _alphaMode: number;
  84175. protected _internalTexturesCache: InternalTexture[];
  84176. /** @hidden */
  84177. protected _activeChannel: number;
  84178. private _currentTextureChannel;
  84179. /** @hidden */
  84180. protected _boundTexturesCache: {
  84181. [key: string]: Nullable<InternalTexture>;
  84182. };
  84183. /** @hidden */
  84184. protected _currentEffect: Nullable<Effect>;
  84185. /** @hidden */
  84186. protected _currentProgram: Nullable<WebGLProgram>;
  84187. private _compiledEffects;
  84188. private _vertexAttribArraysEnabled;
  84189. /** @hidden */
  84190. protected _cachedViewport: Nullable<Viewport>;
  84191. private _cachedVertexArrayObject;
  84192. /** @hidden */
  84193. protected _cachedVertexBuffers: any;
  84194. /** @hidden */
  84195. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84196. /** @hidden */
  84197. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84198. /** @hidden */
  84199. protected _currentRenderTarget: Nullable<InternalTexture>;
  84200. private _uintIndicesCurrentlySet;
  84201. private _currentBoundBuffer;
  84202. /** @hidden */
  84203. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84204. private _currentBufferPointers;
  84205. private _currentInstanceLocations;
  84206. private _currentInstanceBuffers;
  84207. private _textureUnits;
  84208. private _firstBoundInternalTextureTracker;
  84209. private _lastBoundInternalTextureTracker;
  84210. private _workingCanvas;
  84211. private _workingContext;
  84212. private _rescalePostProcess;
  84213. private _dummyFramebuffer;
  84214. private _externalData;
  84215. private _bindedRenderFunction;
  84216. private _vaoRecordInProgress;
  84217. private _mustWipeVertexAttributes;
  84218. private _emptyTexture;
  84219. private _emptyCubeTexture;
  84220. private _emptyTexture3D;
  84221. /** @hidden */
  84222. _frameHandler: number;
  84223. private _nextFreeTextureSlots;
  84224. private _maxSimultaneousTextures;
  84225. private _activeRequests;
  84226. private _texturesSupported;
  84227. private _textureFormatInUse;
  84228. /**
  84229. * Gets the list of texture formats supported
  84230. */
  84231. readonly texturesSupported: Array<string>;
  84232. /**
  84233. * Gets the list of texture formats in use
  84234. */
  84235. readonly textureFormatInUse: Nullable<string>;
  84236. /**
  84237. * Gets the current viewport
  84238. */
  84239. readonly currentViewport: Nullable<Viewport>;
  84240. /**
  84241. * Gets the default empty texture
  84242. */
  84243. readonly emptyTexture: InternalTexture;
  84244. /**
  84245. * Gets the default empty 3D texture
  84246. */
  84247. readonly emptyTexture3D: InternalTexture;
  84248. /**
  84249. * Gets the default empty cube texture
  84250. */
  84251. readonly emptyCubeTexture: InternalTexture;
  84252. /**
  84253. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84254. */
  84255. readonly premultipliedAlpha: boolean;
  84256. /**
  84257. * Creates a new engine
  84258. * @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
  84259. * @param antialias defines enable antialiasing (default: false)
  84260. * @param options defines further options to be sent to the getContext() function
  84261. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84262. */
  84263. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84264. private _disableTouchAction;
  84265. private _rebuildInternalTextures;
  84266. private _rebuildEffects;
  84267. /**
  84268. * Gets a boolean indicating if all created effects are ready
  84269. * @returns true if all effects are ready
  84270. */
  84271. areAllEffectsReady(): boolean;
  84272. private _rebuildBuffers;
  84273. private _initGLContext;
  84274. /**
  84275. * Gets version of the current webGL context
  84276. */
  84277. readonly webGLVersion: number;
  84278. /**
  84279. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84280. */
  84281. readonly isStencilEnable: boolean;
  84282. private _prepareWorkingCanvas;
  84283. /**
  84284. * Reset the texture cache to empty state
  84285. */
  84286. resetTextureCache(): void;
  84287. /**
  84288. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84290. * @returns true if engine is in deterministic lock step mode
  84291. */
  84292. isDeterministicLockStep(): boolean;
  84293. /**
  84294. * Gets the max steps when engine is running in deterministic lock step
  84295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84296. * @returns the max steps
  84297. */
  84298. getLockstepMaxSteps(): number;
  84299. /**
  84300. * Gets an object containing information about the current webGL context
  84301. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84302. */
  84303. getGlInfo(): {
  84304. vendor: string;
  84305. renderer: string;
  84306. version: string;
  84307. };
  84308. /**
  84309. * Gets current aspect ratio
  84310. * @param camera defines the camera to use to get the aspect ratio
  84311. * @param useScreen defines if screen size must be used (or the current render target if any)
  84312. * @returns a number defining the aspect ratio
  84313. */
  84314. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84315. /**
  84316. * Gets current screen aspect ratio
  84317. * @returns a number defining the aspect ratio
  84318. */
  84319. getScreenAspectRatio(): number;
  84320. /**
  84321. * Gets the current render width
  84322. * @param useScreen defines if screen size must be used (or the current render target if any)
  84323. * @returns a number defining the current render width
  84324. */
  84325. getRenderWidth(useScreen?: boolean): number;
  84326. /**
  84327. * Gets the current render height
  84328. * @param useScreen defines if screen size must be used (or the current render target if any)
  84329. * @returns a number defining the current render height
  84330. */
  84331. getRenderHeight(useScreen?: boolean): number;
  84332. /**
  84333. * Gets the HTML canvas attached with the current webGL context
  84334. * @returns a HTML canvas
  84335. */
  84336. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84337. /**
  84338. * Gets the client rect of the HTML canvas attached with the current webGL context
  84339. * @returns a client rectanglee
  84340. */
  84341. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84342. /**
  84343. * Defines the hardware scaling level.
  84344. * By default the hardware scaling level is computed from the window device ratio.
  84345. * 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.
  84346. * @param level defines the level to use
  84347. */
  84348. setHardwareScalingLevel(level: number): void;
  84349. /**
  84350. * Gets the current hardware scaling level.
  84351. * By default the hardware scaling level is computed from the window device ratio.
  84352. * 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.
  84353. * @returns a number indicating the current hardware scaling level
  84354. */
  84355. getHardwareScalingLevel(): number;
  84356. /**
  84357. * Gets the list of loaded textures
  84358. * @returns an array containing all loaded textures
  84359. */
  84360. getLoadedTexturesCache(): InternalTexture[];
  84361. /**
  84362. * Gets the object containing all engine capabilities
  84363. * @returns the EngineCapabilities object
  84364. */
  84365. getCaps(): EngineCapabilities;
  84366. /**
  84367. * Gets the current depth function
  84368. * @returns a number defining the depth function
  84369. */
  84370. getDepthFunction(): Nullable<number>;
  84371. /**
  84372. * Sets the current depth function
  84373. * @param depthFunc defines the function to use
  84374. */
  84375. setDepthFunction(depthFunc: number): void;
  84376. /**
  84377. * Sets the current depth function to GREATER
  84378. */
  84379. setDepthFunctionToGreater(): void;
  84380. /**
  84381. * Sets the current depth function to GEQUAL
  84382. */
  84383. setDepthFunctionToGreaterOrEqual(): void;
  84384. /**
  84385. * Sets the current depth function to LESS
  84386. */
  84387. setDepthFunctionToLess(): void;
  84388. /**
  84389. * Sets the current depth function to LEQUAL
  84390. */
  84391. setDepthFunctionToLessOrEqual(): void;
  84392. /**
  84393. * Gets a boolean indicating if stencil buffer is enabled
  84394. * @returns the current stencil buffer state
  84395. */
  84396. getStencilBuffer(): boolean;
  84397. /**
  84398. * Enable or disable the stencil buffer
  84399. * @param enable defines if the stencil buffer must be enabled or disabled
  84400. */
  84401. setStencilBuffer(enable: boolean): void;
  84402. /**
  84403. * Gets the current stencil mask
  84404. * @returns a number defining the new stencil mask to use
  84405. */
  84406. getStencilMask(): number;
  84407. /**
  84408. * Sets the current stencil mask
  84409. * @param mask defines the new stencil mask to use
  84410. */
  84411. setStencilMask(mask: number): void;
  84412. /**
  84413. * Gets the current stencil function
  84414. * @returns a number defining the stencil function to use
  84415. */
  84416. getStencilFunction(): number;
  84417. /**
  84418. * Gets the current stencil reference value
  84419. * @returns a number defining the stencil reference value to use
  84420. */
  84421. getStencilFunctionReference(): number;
  84422. /**
  84423. * Gets the current stencil mask
  84424. * @returns a number defining the stencil mask to use
  84425. */
  84426. getStencilFunctionMask(): number;
  84427. /**
  84428. * Sets the current stencil function
  84429. * @param stencilFunc defines the new stencil function to use
  84430. */
  84431. setStencilFunction(stencilFunc: number): void;
  84432. /**
  84433. * Sets the current stencil reference
  84434. * @param reference defines the new stencil reference to use
  84435. */
  84436. setStencilFunctionReference(reference: number): void;
  84437. /**
  84438. * Sets the current stencil mask
  84439. * @param mask defines the new stencil mask to use
  84440. */
  84441. setStencilFunctionMask(mask: number): void;
  84442. /**
  84443. * Gets the current stencil operation when stencil fails
  84444. * @returns a number defining stencil operation to use when stencil fails
  84445. */
  84446. getStencilOperationFail(): number;
  84447. /**
  84448. * Gets the current stencil operation when depth fails
  84449. * @returns a number defining stencil operation to use when depth fails
  84450. */
  84451. getStencilOperationDepthFail(): number;
  84452. /**
  84453. * Gets the current stencil operation when stencil passes
  84454. * @returns a number defining stencil operation to use when stencil passes
  84455. */
  84456. getStencilOperationPass(): number;
  84457. /**
  84458. * Sets the stencil operation to use when stencil fails
  84459. * @param operation defines the stencil operation to use when stencil fails
  84460. */
  84461. setStencilOperationFail(operation: number): void;
  84462. /**
  84463. * Sets the stencil operation to use when depth fails
  84464. * @param operation defines the stencil operation to use when depth fails
  84465. */
  84466. setStencilOperationDepthFail(operation: number): void;
  84467. /**
  84468. * Sets the stencil operation to use when stencil passes
  84469. * @param operation defines the stencil operation to use when stencil passes
  84470. */
  84471. setStencilOperationPass(operation: number): void;
  84472. /**
  84473. * Sets a boolean indicating if the dithering state is enabled or disabled
  84474. * @param value defines the dithering state
  84475. */
  84476. setDitheringState(value: boolean): void;
  84477. /**
  84478. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84479. * @param value defines the rasterizer state
  84480. */
  84481. setRasterizerState(value: boolean): void;
  84482. /**
  84483. * stop executing a render loop function and remove it from the execution array
  84484. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84485. */
  84486. stopRenderLoop(renderFunction?: () => void): void;
  84487. /** @hidden */
  84488. _renderLoop(): void;
  84489. /**
  84490. * Register and execute a render loop. The engine can have more than one render function
  84491. * @param renderFunction defines the function to continuously execute
  84492. */
  84493. runRenderLoop(renderFunction: () => void): void;
  84494. /**
  84495. * Toggle full screen mode
  84496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84497. */
  84498. switchFullscreen(requestPointerLock: boolean): void;
  84499. /**
  84500. * Enters full screen mode
  84501. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84502. */
  84503. enterFullscreen(requestPointerLock: boolean): void;
  84504. /**
  84505. * Exits full screen mode
  84506. */
  84507. exitFullscreen(): void;
  84508. /**
  84509. * Clear the current render buffer or the current render target (if any is set up)
  84510. * @param color defines the color to use
  84511. * @param backBuffer defines if the back buffer must be cleared
  84512. * @param depth defines if the depth buffer must be cleared
  84513. * @param stencil defines if the stencil buffer must be cleared
  84514. */
  84515. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84516. /**
  84517. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84518. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84519. * @param y defines the y-coordinate of the corner of the clear rectangle
  84520. * @param width defines the width of the clear rectangle
  84521. * @param height defines the height of the clear rectangle
  84522. * @param clearColor defines the clear color
  84523. */
  84524. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84525. /**
  84526. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84527. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84528. * @param y defines the y-coordinate of the corner of the clear rectangle
  84529. * @param width defines the width of the clear rectangle
  84530. * @param height defines the height of the clear rectangle
  84531. */
  84532. enableScissor(x: number, y: number, width: number, height: number): void;
  84533. /**
  84534. * Disable previously set scissor test rectangle
  84535. */
  84536. disableScissor(): void;
  84537. private _viewportCached;
  84538. /** @hidden */
  84539. _viewport(x: number, y: number, width: number, height: number): void;
  84540. /**
  84541. * Set the WebGL's viewport
  84542. * @param viewport defines the viewport element to be used
  84543. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84544. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84545. */
  84546. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84547. /**
  84548. * Directly set the WebGL Viewport
  84549. * @param x defines the x coordinate of the viewport (in screen space)
  84550. * @param y defines the y coordinate of the viewport (in screen space)
  84551. * @param width defines the width of the viewport (in screen space)
  84552. * @param height defines the height of the viewport (in screen space)
  84553. * @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
  84554. */
  84555. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84556. /**
  84557. * Begin a new frame
  84558. */
  84559. beginFrame(): void;
  84560. /**
  84561. * Enf the current frame
  84562. */
  84563. endFrame(): void;
  84564. /**
  84565. * Resize the view according to the canvas' size
  84566. */
  84567. resize(): void;
  84568. /**
  84569. * Force a specific size of the canvas
  84570. * @param width defines the new canvas' width
  84571. * @param height defines the new canvas' height
  84572. */
  84573. setSize(width: number, height: number): void;
  84574. /**
  84575. * Gets a boolean indicating if a webVR device was detected
  84576. * @returns true if a webVR device was detected
  84577. */
  84578. isVRDevicePresent(): boolean;
  84579. /**
  84580. * Gets the current webVR device
  84581. * @returns the current webVR device (or null)
  84582. */
  84583. getVRDevice(): any;
  84584. /**
  84585. * Initializes a webVR display and starts listening to display change events
  84586. * The onVRDisplayChangedObservable will be notified upon these changes
  84587. * @returns The onVRDisplayChangedObservable
  84588. */
  84589. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84590. /**
  84591. * Initializes a webVR display and starts listening to display change events
  84592. * The onVRDisplayChangedObservable will be notified upon these changes
  84593. * @returns A promise containing a VRDisplay and if vr is supported
  84594. */
  84595. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84596. /**
  84597. * Call this function to switch to webVR mode
  84598. * Will do nothing if webVR is not supported or if there is no webVR device
  84599. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84600. */
  84601. enableVR(): void;
  84602. /**
  84603. * Call this function to leave webVR mode
  84604. * Will do nothing if webVR is not supported or if there is no webVR device
  84605. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84606. */
  84607. disableVR(): void;
  84608. private _onVRFullScreenTriggered;
  84609. private _getVRDisplaysAsync;
  84610. /**
  84611. * Binds the frame buffer to the specified texture.
  84612. * @param texture The texture to render to or null for the default canvas
  84613. * @param faceIndex The face of the texture to render to in case of cube texture
  84614. * @param requiredWidth The width of the target to render to
  84615. * @param requiredHeight The height of the target to render to
  84616. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84617. * @param depthStencilTexture The depth stencil texture to use to render
  84618. * @param lodLevel defines le lod level to bind to the frame buffer
  84619. */
  84620. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84621. private bindUnboundFramebuffer;
  84622. /**
  84623. * Unbind the current render target texture from the webGL context
  84624. * @param texture defines the render target texture to unbind
  84625. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84626. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84627. */
  84628. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84629. /**
  84630. * Unbind a list of render target textures from the webGL context
  84631. * This is used only when drawBuffer extension or webGL2 are active
  84632. * @param textures defines the render target textures to unbind
  84633. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84634. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84635. */
  84636. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84637. /**
  84638. * Force the mipmap generation for the given render target texture
  84639. * @param texture defines the render target texture to use
  84640. */
  84641. generateMipMapsForCubemap(texture: InternalTexture): void;
  84642. /**
  84643. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84644. */
  84645. flushFramebuffer(): void;
  84646. /**
  84647. * Unbind the current render target and bind the default framebuffer
  84648. */
  84649. restoreDefaultFramebuffer(): void;
  84650. /**
  84651. * Create an uniform buffer
  84652. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84653. * @param elements defines the content of the uniform buffer
  84654. * @returns the webGL uniform buffer
  84655. */
  84656. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84657. /**
  84658. * Create a dynamic uniform buffer
  84659. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84660. * @param elements defines the content of the uniform buffer
  84661. * @returns the webGL uniform buffer
  84662. */
  84663. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84664. /**
  84665. * Update an existing uniform buffer
  84666. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84667. * @param uniformBuffer defines the target uniform buffer
  84668. * @param elements defines the content to update
  84669. * @param offset defines the offset in the uniform buffer where update should start
  84670. * @param count defines the size of the data to update
  84671. */
  84672. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84673. private _resetVertexBufferBinding;
  84674. /**
  84675. * Creates a vertex buffer
  84676. * @param data the data for the vertex buffer
  84677. * @returns the new WebGL static buffer
  84678. */
  84679. createVertexBuffer(data: DataArray): WebGLBuffer;
  84680. /**
  84681. * Creates a dynamic vertex buffer
  84682. * @param data the data for the dynamic vertex buffer
  84683. * @returns the new WebGL dynamic buffer
  84684. */
  84685. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84686. /**
  84687. * Update a dynamic index buffer
  84688. * @param indexBuffer defines the target index buffer
  84689. * @param indices defines the data to update
  84690. * @param offset defines the offset in the target index buffer where update should start
  84691. */
  84692. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84693. /**
  84694. * Updates a dynamic vertex buffer.
  84695. * @param vertexBuffer the vertex buffer to update
  84696. * @param data the data used to update the vertex buffer
  84697. * @param byteOffset the byte offset of the data
  84698. * @param byteLength the byte length of the data
  84699. */
  84700. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84701. private _resetIndexBufferBinding;
  84702. /**
  84703. * Creates a new index buffer
  84704. * @param indices defines the content of the index buffer
  84705. * @param updatable defines if the index buffer must be updatable
  84706. * @returns a new webGL buffer
  84707. */
  84708. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84709. /**
  84710. * Bind a webGL buffer to the webGL context
  84711. * @param buffer defines the buffer to bind
  84712. */
  84713. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84714. /**
  84715. * Bind an uniform buffer to the current webGL context
  84716. * @param buffer defines the buffer to bind
  84717. */
  84718. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84719. /**
  84720. * Bind a buffer to the current webGL context at a given location
  84721. * @param buffer defines the buffer to bind
  84722. * @param location defines the index where to bind the buffer
  84723. */
  84724. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84725. /**
  84726. * Bind a specific block at a given index in a specific shader program
  84727. * @param shaderProgram defines the shader program
  84728. * @param blockName defines the block name
  84729. * @param index defines the index where to bind the block
  84730. */
  84731. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84732. private bindIndexBuffer;
  84733. private bindBuffer;
  84734. /**
  84735. * update the bound buffer with the given data
  84736. * @param data defines the data to update
  84737. */
  84738. updateArrayBuffer(data: Float32Array): void;
  84739. private _vertexAttribPointer;
  84740. private _bindIndexBufferWithCache;
  84741. private _bindVertexBuffersAttributes;
  84742. /**
  84743. * Records a vertex array object
  84744. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84745. * @param vertexBuffers defines the list of vertex buffers to store
  84746. * @param indexBuffer defines the index buffer to store
  84747. * @param effect defines the effect to store
  84748. * @returns the new vertex array object
  84749. */
  84750. recordVertexArrayObject(vertexBuffers: {
  84751. [key: string]: VertexBuffer;
  84752. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84753. /**
  84754. * Bind a specific vertex array object
  84755. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84756. * @param vertexArrayObject defines the vertex array object to bind
  84757. * @param indexBuffer defines the index buffer to bind
  84758. */
  84759. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84760. /**
  84761. * Bind webGl buffers directly to the webGL context
  84762. * @param vertexBuffer defines the vertex buffer to bind
  84763. * @param indexBuffer defines the index buffer to bind
  84764. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84765. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84766. * @param effect defines the effect associated with the vertex buffer
  84767. */
  84768. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84769. private _unbindVertexArrayObject;
  84770. /**
  84771. * Bind a list of vertex buffers to the webGL context
  84772. * @param vertexBuffers defines the list of vertex buffers to bind
  84773. * @param indexBuffer defines the index buffer to bind
  84774. * @param effect defines the effect associated with the vertex buffers
  84775. */
  84776. bindBuffers(vertexBuffers: {
  84777. [key: string]: Nullable<VertexBuffer>;
  84778. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84779. /**
  84780. * Unbind all instance attributes
  84781. */
  84782. unbindInstanceAttributes(): void;
  84783. /**
  84784. * Release and free the memory of a vertex array object
  84785. * @param vao defines the vertex array object to delete
  84786. */
  84787. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84788. /** @hidden */
  84789. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84790. /**
  84791. * Creates a webGL buffer to use with instanciation
  84792. * @param capacity defines the size of the buffer
  84793. * @returns the webGL buffer
  84794. */
  84795. createInstancesBuffer(capacity: number): WebGLBuffer;
  84796. /**
  84797. * Delete a webGL buffer used with instanciation
  84798. * @param buffer defines the webGL buffer to delete
  84799. */
  84800. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84801. /**
  84802. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84803. * @param instancesBuffer defines the webGL buffer to update and bind
  84804. * @param data defines the data to store in the buffer
  84805. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84806. */
  84807. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84808. /**
  84809. * Apply all cached states (depth, culling, stencil and alpha)
  84810. */
  84811. applyStates(): void;
  84812. /**
  84813. * Send a draw order
  84814. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84815. * @param indexStart defines the starting index
  84816. * @param indexCount defines the number of index to draw
  84817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84818. */
  84819. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84820. /**
  84821. * Draw a list of points
  84822. * @param verticesStart defines the index of first vertex to draw
  84823. * @param verticesCount defines the count of vertices to draw
  84824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84825. */
  84826. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84827. /**
  84828. * Draw a list of unindexed primitives
  84829. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84830. * @param verticesStart defines the index of first vertex to draw
  84831. * @param verticesCount defines the count of vertices to draw
  84832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84833. */
  84834. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84835. /**
  84836. * Draw a list of indexed primitives
  84837. * @param fillMode defines the primitive to use
  84838. * @param indexStart defines the starting index
  84839. * @param indexCount defines the number of index to draw
  84840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84841. */
  84842. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84843. /**
  84844. * Draw a list of unindexed primitives
  84845. * @param fillMode defines the primitive to use
  84846. * @param verticesStart defines the index of first vertex to draw
  84847. * @param verticesCount defines the count of vertices to draw
  84848. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84849. */
  84850. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84851. private _drawMode;
  84852. /** @hidden */
  84853. _releaseEffect(effect: Effect): void;
  84854. /** @hidden */
  84855. _deleteProgram(program: WebGLProgram): void;
  84856. /**
  84857. * Create a new effect (used to store vertex/fragment shaders)
  84858. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84859. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84860. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84861. * @param samplers defines an array of string used to represent textures
  84862. * @param defines defines the string containing the defines to use to compile the shaders
  84863. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84864. * @param onCompiled defines a function to call when the effect creation is successful
  84865. * @param onError defines a function to call when the effect creation has failed
  84866. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84867. * @returns the new Effect
  84868. */
  84869. 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;
  84870. private _compileShader;
  84871. private _compileRawShader;
  84872. /**
  84873. * Directly creates a webGL program
  84874. * @param vertexCode defines the vertex shader code to use
  84875. * @param fragmentCode defines the fragment shader code to use
  84876. * @param context defines the webGL context to use (if not set, the current one will be used)
  84877. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84878. * @returns the new webGL program
  84879. */
  84880. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84881. /**
  84882. * Creates a webGL program
  84883. * @param vertexCode defines the vertex shader code to use
  84884. * @param fragmentCode defines the fragment shader code to use
  84885. * @param defines defines the string containing the defines to use to compile the shaders
  84886. * @param context defines the webGL context to use (if not set, the current one will be used)
  84887. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84888. * @returns the new webGL program
  84889. */
  84890. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84891. private _createShaderProgram;
  84892. private _finalizeProgram;
  84893. /** @hidden */
  84894. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84895. /** @hidden */
  84896. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84897. /**
  84898. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84899. * @param shaderProgram defines the webGL program to use
  84900. * @param uniformsNames defines the list of uniform names
  84901. * @returns an array of webGL uniform locations
  84902. */
  84903. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84904. /**
  84905. * Gets the lsit of active attributes for a given webGL program
  84906. * @param shaderProgram defines the webGL program to use
  84907. * @param attributesNames defines the list of attribute names to get
  84908. * @returns an array of indices indicating the offset of each attribute
  84909. */
  84910. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84911. /**
  84912. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84913. * @param effect defines the effect to activate
  84914. */
  84915. enableEffect(effect: Nullable<Effect>): void;
  84916. /**
  84917. * Set the value of an uniform to an array of int32
  84918. * @param uniform defines the webGL uniform location where to store the value
  84919. * @param array defines the array of int32 to store
  84920. */
  84921. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84922. /**
  84923. * Set the value of an uniform to an array of int32 (stored as vec2)
  84924. * @param uniform defines the webGL uniform location where to store the value
  84925. * @param array defines the array of int32 to store
  84926. */
  84927. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84928. /**
  84929. * Set the value of an uniform to an array of int32 (stored as vec3)
  84930. * @param uniform defines the webGL uniform location where to store the value
  84931. * @param array defines the array of int32 to store
  84932. */
  84933. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84934. /**
  84935. * Set the value of an uniform to an array of int32 (stored as vec4)
  84936. * @param uniform defines the webGL uniform location where to store the value
  84937. * @param array defines the array of int32 to store
  84938. */
  84939. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84940. /**
  84941. * Set the value of an uniform to an array of float32
  84942. * @param uniform defines the webGL uniform location where to store the value
  84943. * @param array defines the array of float32 to store
  84944. */
  84945. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84946. /**
  84947. * Set the value of an uniform to an array of float32 (stored as vec2)
  84948. * @param uniform defines the webGL uniform location where to store the value
  84949. * @param array defines the array of float32 to store
  84950. */
  84951. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84952. /**
  84953. * Set the value of an uniform to an array of float32 (stored as vec3)
  84954. * @param uniform defines the webGL uniform location where to store the value
  84955. * @param array defines the array of float32 to store
  84956. */
  84957. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84958. /**
  84959. * Set the value of an uniform to an array of float32 (stored as vec4)
  84960. * @param uniform defines the webGL uniform location where to store the value
  84961. * @param array defines the array of float32 to store
  84962. */
  84963. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84964. /**
  84965. * Set the value of an uniform to an array of number
  84966. * @param uniform defines the webGL uniform location where to store the value
  84967. * @param array defines the array of number to store
  84968. */
  84969. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84970. /**
  84971. * Set the value of an uniform to an array of number (stored as vec2)
  84972. * @param uniform defines the webGL uniform location where to store the value
  84973. * @param array defines the array of number to store
  84974. */
  84975. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84976. /**
  84977. * Set the value of an uniform to an array of number (stored as vec3)
  84978. * @param uniform defines the webGL uniform location where to store the value
  84979. * @param array defines the array of number to store
  84980. */
  84981. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84982. /**
  84983. * Set the value of an uniform to an array of number (stored as vec4)
  84984. * @param uniform defines the webGL uniform location where to store the value
  84985. * @param array defines the array of number to store
  84986. */
  84987. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84988. /**
  84989. * Set the value of an uniform to an array of float32 (stored as matrices)
  84990. * @param uniform defines the webGL uniform location where to store the value
  84991. * @param matrices defines the array of float32 to store
  84992. */
  84993. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84994. /**
  84995. * Set the value of an uniform to a matrix
  84996. * @param uniform defines the webGL uniform location where to store the value
  84997. * @param matrix defines the matrix to store
  84998. */
  84999. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85000. /**
  85001. * Set the value of an uniform to a matrix (3x3)
  85002. * @param uniform defines the webGL uniform location where to store the value
  85003. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85004. */
  85005. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85006. /**
  85007. * Set the value of an uniform to a matrix (2x2)
  85008. * @param uniform defines the webGL uniform location where to store the value
  85009. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85010. */
  85011. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85012. /**
  85013. * Set the value of an uniform to a number (int)
  85014. * @param uniform defines the webGL uniform location where to store the value
  85015. * @param value defines the int number to store
  85016. */
  85017. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85018. /**
  85019. * Set the value of an uniform to a number (float)
  85020. * @param uniform defines the webGL uniform location where to store the value
  85021. * @param value defines the float number to store
  85022. */
  85023. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85024. /**
  85025. * Set the value of an uniform to a vec2
  85026. * @param uniform defines the webGL uniform location where to store the value
  85027. * @param x defines the 1st component of the value
  85028. * @param y defines the 2nd component of the value
  85029. */
  85030. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85031. /**
  85032. * Set the value of an uniform to a vec3
  85033. * @param uniform defines the webGL uniform location where to store the value
  85034. * @param x defines the 1st component of the value
  85035. * @param y defines the 2nd component of the value
  85036. * @param z defines the 3rd component of the value
  85037. */
  85038. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85039. /**
  85040. * Set the value of an uniform to a boolean
  85041. * @param uniform defines the webGL uniform location where to store the value
  85042. * @param bool defines the boolean to store
  85043. */
  85044. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85045. /**
  85046. * Set the value of an uniform to a vec4
  85047. * @param uniform defines the webGL uniform location where to store the value
  85048. * @param x defines the 1st component of the value
  85049. * @param y defines the 2nd component of the value
  85050. * @param z defines the 3rd component of the value
  85051. * @param w defines the 4th component of the value
  85052. */
  85053. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85054. /**
  85055. * Set the value of an uniform to a Color3
  85056. * @param uniform defines the webGL uniform location where to store the value
  85057. * @param color3 defines the color to store
  85058. */
  85059. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85060. /**
  85061. * Set the value of an uniform to a Color3 and an alpha value
  85062. * @param uniform defines the webGL uniform location where to store the value
  85063. * @param color3 defines the color to store
  85064. * @param alpha defines the alpha component to store
  85065. */
  85066. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85067. /**
  85068. * Sets a Color4 on a uniform variable
  85069. * @param uniform defines the uniform location
  85070. * @param color4 defines the value to be set
  85071. */
  85072. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85073. /**
  85074. * Set various states to the webGL context
  85075. * @param culling defines backface culling state
  85076. * @param zOffset defines the value to apply to zOffset (0 by default)
  85077. * @param force defines if states must be applied even if cache is up to date
  85078. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85079. */
  85080. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85081. /**
  85082. * Set the z offset to apply to current rendering
  85083. * @param value defines the offset to apply
  85084. */
  85085. setZOffset(value: number): void;
  85086. /**
  85087. * Gets the current value of the zOffset
  85088. * @returns the current zOffset state
  85089. */
  85090. getZOffset(): number;
  85091. /**
  85092. * Enable or disable depth buffering
  85093. * @param enable defines the state to set
  85094. */
  85095. setDepthBuffer(enable: boolean): void;
  85096. /**
  85097. * Gets a boolean indicating if depth writing is enabled
  85098. * @returns the current depth writing state
  85099. */
  85100. getDepthWrite(): boolean;
  85101. /**
  85102. * Enable or disable depth writing
  85103. * @param enable defines the state to set
  85104. */
  85105. setDepthWrite(enable: boolean): void;
  85106. /**
  85107. * Enable or disable color writing
  85108. * @param enable defines the state to set
  85109. */
  85110. setColorWrite(enable: boolean): void;
  85111. /**
  85112. * Gets a boolean indicating if color writing is enabled
  85113. * @returns the current color writing state
  85114. */
  85115. getColorWrite(): boolean;
  85116. /**
  85117. * Sets alpha constants used by some alpha blending modes
  85118. * @param r defines the red component
  85119. * @param g defines the green component
  85120. * @param b defines the blue component
  85121. * @param a defines the alpha component
  85122. */
  85123. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85124. /**
  85125. * Sets the current alpha mode
  85126. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85127. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85128. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85129. */
  85130. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85131. /**
  85132. * Gets the current alpha mode
  85133. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85134. * @returns the current alpha mode
  85135. */
  85136. getAlphaMode(): number;
  85137. /**
  85138. * Clears the list of texture accessible through engine.
  85139. * This can help preventing texture load conflict due to name collision.
  85140. */
  85141. clearInternalTexturesCache(): void;
  85142. /**
  85143. * Force the entire cache to be cleared
  85144. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85145. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85146. */
  85147. wipeCaches(bruteForce?: boolean): void;
  85148. /**
  85149. * Set the compressed texture format to use, based on the formats you have, and the formats
  85150. * supported by the hardware / browser.
  85151. *
  85152. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85153. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85154. * to API arguments needed to compressed textures. This puts the burden on the container
  85155. * generator to house the arcane code for determining these for current & future formats.
  85156. *
  85157. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85158. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85159. *
  85160. * Note: The result of this call is not taken into account when a texture is base64.
  85161. *
  85162. * @param formatsAvailable defines the list of those format families you have created
  85163. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85164. *
  85165. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85166. * @returns The extension selected.
  85167. */
  85168. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85169. private _getSamplingParameters;
  85170. private _partialLoadImg;
  85171. private _cascadeLoadImgs;
  85172. /** @hidden */
  85173. _createTexture(): WebGLTexture;
  85174. /**
  85175. * Usually called from Texture.ts.
  85176. * Passed information to create a WebGLTexture
  85177. * @param urlArg defines a value which contains one of the following:
  85178. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85179. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85180. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85181. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85182. * @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)
  85183. * @param scene needed for loading to the correct scene
  85184. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85185. * @param onLoad optional callback to be called upon successful completion
  85186. * @param onError optional callback to be called upon failure
  85187. * @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
  85188. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85189. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85190. * @param forcedExtension defines the extension to use to pick the right loader
  85191. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85192. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85193. */
  85194. 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;
  85195. private _rescaleTexture;
  85196. /**
  85197. * Update a raw texture
  85198. * @param texture defines the texture to update
  85199. * @param data defines the data to store in the texture
  85200. * @param format defines the format of the data
  85201. * @param invertY defines if data must be stored with Y axis inverted
  85202. * @param compression defines the compression used (null by default)
  85203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85204. */
  85205. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85206. /**
  85207. * Creates a raw texture
  85208. * @param data defines the data to store in the texture
  85209. * @param width defines the width of the texture
  85210. * @param height defines the height of the texture
  85211. * @param format defines the format of the data
  85212. * @param generateMipMaps defines if the engine should generate the mip levels
  85213. * @param invertY defines if data must be stored with Y axis inverted
  85214. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85215. * @param compression defines the compression used (null by default)
  85216. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85217. * @returns the raw texture inside an InternalTexture
  85218. */
  85219. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85220. private _unpackFlipYCached;
  85221. /**
  85222. * In case you are sharing the context with other applications, it might
  85223. * be interested to not cache the unpack flip y state to ensure a consistent
  85224. * value would be set.
  85225. */
  85226. enableUnpackFlipYCached: boolean;
  85227. /** @hidden */
  85228. _unpackFlipY(value: boolean): void;
  85229. /** @hidden */
  85230. _getUnpackAlignement(): number;
  85231. /**
  85232. * Creates a dynamic texture
  85233. * @param width defines the width of the texture
  85234. * @param height defines the height of the texture
  85235. * @param generateMipMaps defines if the engine should generate the mip levels
  85236. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85237. * @returns the dynamic texture inside an InternalTexture
  85238. */
  85239. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85240. /**
  85241. * Update the sampling mode of a given texture
  85242. * @param samplingMode defines the required sampling mode
  85243. * @param texture defines the texture to update
  85244. */
  85245. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85246. /**
  85247. * Update the content of a dynamic texture
  85248. * @param texture defines the texture to update
  85249. * @param canvas defines the canvas containing the source
  85250. * @param invertY defines if data must be stored with Y axis inverted
  85251. * @param premulAlpha defines if alpha is stored as premultiplied
  85252. * @param format defines the format of the data
  85253. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85254. */
  85255. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85256. /**
  85257. * Update a video texture
  85258. * @param texture defines the texture to update
  85259. * @param video defines the video element to use
  85260. * @param invertY defines if data must be stored with Y axis inverted
  85261. */
  85262. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85263. /**
  85264. * Updates a depth texture Comparison Mode and Function.
  85265. * If the comparison Function is equal to 0, the mode will be set to none.
  85266. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85267. * @param texture The texture to set the comparison function for
  85268. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85269. */
  85270. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85271. private _setupDepthStencilTexture;
  85272. /**
  85273. * Creates a depth stencil texture.
  85274. * This is only available in WebGL 2 or with the depth texture extension available.
  85275. * @param size The size of face edge in the texture.
  85276. * @param options The options defining the texture.
  85277. * @returns The texture
  85278. */
  85279. createDepthStencilTexture(size: number | {
  85280. width: number;
  85281. height: number;
  85282. }, options: DepthTextureCreationOptions): InternalTexture;
  85283. /**
  85284. * Creates a depth stencil texture.
  85285. * This is only available in WebGL 2 or with the depth texture extension available.
  85286. * @param size The size of face edge in the texture.
  85287. * @param options The options defining the texture.
  85288. * @returns The texture
  85289. */
  85290. private _createDepthStencilTexture;
  85291. /**
  85292. * Creates a depth stencil cube texture.
  85293. * This is only available in WebGL 2.
  85294. * @param size The size of face edge in the cube texture.
  85295. * @param options The options defining the cube texture.
  85296. * @returns The cube texture
  85297. */
  85298. private _createDepthStencilCubeTexture;
  85299. /**
  85300. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85301. * @param renderTarget The render target to set the frame buffer for
  85302. */
  85303. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85304. /**
  85305. * Creates a new render target texture
  85306. * @param size defines the size of the texture
  85307. * @param options defines the options used to create the texture
  85308. * @returns a new render target texture stored in an InternalTexture
  85309. */
  85310. createRenderTargetTexture(size: number | {
  85311. width: number;
  85312. height: number;
  85313. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85314. /**
  85315. * Create a multi render target texture
  85316. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85317. * @param size defines the size of the texture
  85318. * @param options defines the creation options
  85319. * @returns the cube texture as an InternalTexture
  85320. */
  85321. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85322. private _setupFramebufferDepthAttachments;
  85323. /**
  85324. * Updates the sample count of a render target texture
  85325. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85326. * @param texture defines the texture to update
  85327. * @param samples defines the sample count to set
  85328. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85329. */
  85330. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85331. /**
  85332. * Update the sample count for a given multiple render target texture
  85333. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85334. * @param textures defines the textures to update
  85335. * @param samples defines the sample count to set
  85336. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85337. */
  85338. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85339. /** @hidden */
  85340. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85341. /** @hidden */
  85342. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85343. /** @hidden */
  85344. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85345. /** @hidden */
  85346. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85347. /**
  85348. * Creates a new render target cube texture
  85349. * @param size defines the size of the texture
  85350. * @param options defines the options used to create the texture
  85351. * @returns a new render target cube texture stored in an InternalTexture
  85352. */
  85353. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85354. /**
  85355. * Creates a cube texture
  85356. * @param rootUrl defines the url where the files to load is located
  85357. * @param scene defines the current scene
  85358. * @param files defines the list of files to load (1 per face)
  85359. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85360. * @param onLoad defines an optional callback raised when the texture is loaded
  85361. * @param onError defines an optional callback raised if there is an issue to load the texture
  85362. * @param format defines the format of the data
  85363. * @param forcedExtension defines the extension to use to pick the right loader
  85364. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85365. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85366. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85367. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85368. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85369. * @returns the cube texture as an InternalTexture
  85370. */
  85371. 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;
  85372. /**
  85373. * @hidden
  85374. */
  85375. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85376. /**
  85377. * Update a raw cube texture
  85378. * @param texture defines the texture to udpdate
  85379. * @param data defines the data to store
  85380. * @param format defines the data format
  85381. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85382. * @param invertY defines if data must be stored with Y axis inverted
  85383. * @param compression defines the compression used (null by default)
  85384. * @param level defines which level of the texture to update
  85385. */
  85386. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85387. /**
  85388. * Creates a new raw cube texture
  85389. * @param data defines the array of data to use to create each face
  85390. * @param size defines the size of the textures
  85391. * @param format defines the format of the data
  85392. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85393. * @param generateMipMaps defines if the engine should generate the mip levels
  85394. * @param invertY defines if data must be stored with Y axis inverted
  85395. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85396. * @param compression defines the compression used (null by default)
  85397. * @returns the cube texture as an InternalTexture
  85398. */
  85399. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85400. /**
  85401. * Creates a new raw cube texture from a specified url
  85402. * @param url defines the url where the data is located
  85403. * @param scene defines the current scene
  85404. * @param size defines the size of the textures
  85405. * @param format defines the format of the data
  85406. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85407. * @param noMipmap defines if the engine should avoid generating the mip levels
  85408. * @param callback defines a callback used to extract texture data from loaded data
  85409. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85410. * @param onLoad defines a callback called when texture is loaded
  85411. * @param onError defines a callback called if there is an error
  85412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85413. * @param invertY defines if data must be stored with Y axis inverted
  85414. * @returns the cube texture as an InternalTexture
  85415. */
  85416. 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;
  85417. /**
  85418. * Update a raw 3D texture
  85419. * @param texture defines the texture to update
  85420. * @param data defines the data to store
  85421. * @param format defines the data format
  85422. * @param invertY defines if data must be stored with Y axis inverted
  85423. * @param compression defines the used compression (can be null)
  85424. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85425. */
  85426. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85427. /**
  85428. * Creates a new raw 3D texture
  85429. * @param data defines the data used to create the texture
  85430. * @param width defines the width of the texture
  85431. * @param height defines the height of the texture
  85432. * @param depth defines the depth of the texture
  85433. * @param format defines the format of the texture
  85434. * @param generateMipMaps defines if the engine must generate mip levels
  85435. * @param invertY defines if data must be stored with Y axis inverted
  85436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85437. * @param compression defines the compressed used (can be null)
  85438. * @param textureType defines the compressed used (can be null)
  85439. * @returns a new raw 3D texture (stored in an InternalTexture)
  85440. */
  85441. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85442. private _prepareWebGLTextureContinuation;
  85443. private _prepareWebGLTexture;
  85444. private _convertRGBtoRGBATextureData;
  85445. /** @hidden */
  85446. _releaseFramebufferObjects(texture: InternalTexture): void;
  85447. /** @hidden */
  85448. _releaseTexture(texture: InternalTexture): void;
  85449. private setProgram;
  85450. private _boundUniforms;
  85451. /**
  85452. * Binds an effect to the webGL context
  85453. * @param effect defines the effect to bind
  85454. */
  85455. bindSamplers(effect: Effect): void;
  85456. private _moveBoundTextureOnTop;
  85457. private _getCorrectTextureChannel;
  85458. private _linkTrackers;
  85459. private _removeDesignatedSlot;
  85460. private _activateCurrentTexture;
  85461. /** @hidden */
  85462. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85463. /** @hidden */
  85464. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85465. /**
  85466. * Sets a texture to the webGL context from a postprocess
  85467. * @param channel defines the channel to use
  85468. * @param postProcess defines the source postprocess
  85469. */
  85470. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85471. /**
  85472. * Binds the output of the passed in post process to the texture channel specified
  85473. * @param channel The channel the texture should be bound to
  85474. * @param postProcess The post process which's output should be bound
  85475. */
  85476. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85477. /**
  85478. * Unbind all textures from the webGL context
  85479. */
  85480. unbindAllTextures(): void;
  85481. /**
  85482. * Sets a texture to the according uniform.
  85483. * @param channel The texture channel
  85484. * @param uniform The uniform to set
  85485. * @param texture The texture to apply
  85486. */
  85487. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85488. /**
  85489. * Sets a depth stencil texture from a render target to the according uniform.
  85490. * @param channel The texture channel
  85491. * @param uniform The uniform to set
  85492. * @param texture The render target texture containing the depth stencil texture to apply
  85493. */
  85494. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85495. private _bindSamplerUniformToChannel;
  85496. private _getTextureWrapMode;
  85497. private _setTexture;
  85498. /**
  85499. * Sets an array of texture to the webGL context
  85500. * @param channel defines the channel where the texture array must be set
  85501. * @param uniform defines the associated uniform location
  85502. * @param textures defines the array of textures to bind
  85503. */
  85504. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85505. /** @hidden */
  85506. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85507. private _setTextureParameterFloat;
  85508. private _setTextureParameterInteger;
  85509. /**
  85510. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85511. * @param x defines the x coordinate of the rectangle where pixels must be read
  85512. * @param y defines the y coordinate of the rectangle where pixels must be read
  85513. * @param width defines the width of the rectangle where pixels must be read
  85514. * @param height defines the height of the rectangle where pixels must be read
  85515. * @returns a Uint8Array containing RGBA colors
  85516. */
  85517. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85518. /**
  85519. * Add an externaly attached data from its key.
  85520. * This method call will fail and return false, if such key already exists.
  85521. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85522. * @param key the unique key that identifies the data
  85523. * @param data the data object to associate to the key for this Engine instance
  85524. * @return true if no such key were already present and the data was added successfully, false otherwise
  85525. */
  85526. addExternalData<T>(key: string, data: T): boolean;
  85527. /**
  85528. * Get an externaly attached data from its key
  85529. * @param key the unique key that identifies the data
  85530. * @return the associated data, if present (can be null), or undefined if not present
  85531. */
  85532. getExternalData<T>(key: string): T;
  85533. /**
  85534. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85535. * @param key the unique key that identifies the data
  85536. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85537. * @return the associated data, can be null if the factory returned null.
  85538. */
  85539. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85540. /**
  85541. * Remove an externaly attached data from the Engine instance
  85542. * @param key the unique key that identifies the data
  85543. * @return true if the data was successfully removed, false if it doesn't exist
  85544. */
  85545. removeExternalData(key: string): boolean;
  85546. /**
  85547. * Unbind all vertex attributes from the webGL context
  85548. */
  85549. unbindAllAttributes(): void;
  85550. /**
  85551. * 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
  85552. */
  85553. releaseEffects(): void;
  85554. /**
  85555. * Dispose and release all associated resources
  85556. */
  85557. dispose(): void;
  85558. /**
  85559. * Display the loading screen
  85560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85561. */
  85562. displayLoadingUI(): void;
  85563. /**
  85564. * Hide the loading screen
  85565. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85566. */
  85567. hideLoadingUI(): void;
  85568. /**
  85569. * Gets the current loading screen object
  85570. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85571. */
  85572. /**
  85573. * Sets the current loading screen object
  85574. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85575. */
  85576. loadingScreen: ILoadingScreen;
  85577. /**
  85578. * Sets the current loading screen text
  85579. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85580. */
  85581. loadingUIText: string;
  85582. /**
  85583. * Sets the current loading screen background color
  85584. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85585. */
  85586. loadingUIBackgroundColor: string;
  85587. /**
  85588. * Attach a new callback raised when context lost event is fired
  85589. * @param callback defines the callback to call
  85590. */
  85591. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85592. /**
  85593. * Attach a new callback raised when context restored event is fired
  85594. * @param callback defines the callback to call
  85595. */
  85596. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85597. /**
  85598. * Gets the source code of the vertex shader associated with a specific webGL program
  85599. * @param program defines the program to use
  85600. * @returns a string containing the source code of the vertex shader associated with the program
  85601. */
  85602. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85603. /**
  85604. * Gets the source code of the fragment shader associated with a specific webGL program
  85605. * @param program defines the program to use
  85606. * @returns a string containing the source code of the fragment shader associated with the program
  85607. */
  85608. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85609. /**
  85610. * Get the current error code of the webGL context
  85611. * @returns the error code
  85612. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85613. */
  85614. getError(): number;
  85615. /**
  85616. * Gets the current framerate
  85617. * @returns a number representing the framerate
  85618. */
  85619. getFps(): number;
  85620. /**
  85621. * Gets the time spent between current and previous frame
  85622. * @returns a number representing the delta time in ms
  85623. */
  85624. getDeltaTime(): number;
  85625. private _measureFps;
  85626. /** @hidden */
  85627. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85628. private _canRenderToFloatFramebuffer;
  85629. private _canRenderToHalfFloatFramebuffer;
  85630. private _canRenderToFramebuffer;
  85631. /** @hidden */
  85632. _getWebGLTextureType(type: number): number;
  85633. private _getInternalFormat;
  85634. /** @hidden */
  85635. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85636. /** @hidden */
  85637. _getRGBAMultiSampleBufferFormat(type: number): number;
  85638. /** @hidden */
  85639. _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;
  85640. /** @hidden */
  85641. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85642. private _partialLoadFile;
  85643. private _cascadeLoadFiles;
  85644. /**
  85645. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85646. * @returns true if the engine can be created
  85647. * @ignorenaming
  85648. */
  85649. static isSupported(): boolean;
  85650. }
  85651. }
  85652. declare module BABYLON {
  85653. /**
  85654. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85655. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85656. */
  85657. export class EffectFallbacks {
  85658. private _defines;
  85659. private _currentRank;
  85660. private _maxRank;
  85661. private _mesh;
  85662. /**
  85663. * Removes the fallback from the bound mesh.
  85664. */
  85665. unBindMesh(): void;
  85666. /**
  85667. * Adds a fallback on the specified property.
  85668. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85669. * @param define The name of the define in the shader
  85670. */
  85671. addFallback(rank: number, define: string): void;
  85672. /**
  85673. * Sets the mesh to use CPU skinning when needing to fallback.
  85674. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85675. * @param mesh The mesh to use the fallbacks.
  85676. */
  85677. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85678. /**
  85679. * Checks to see if more fallbacks are still availible.
  85680. */
  85681. readonly isMoreFallbacks: boolean;
  85682. /**
  85683. * Removes the defines that shoould be removed when falling back.
  85684. * @param currentDefines defines the current define statements for the shader.
  85685. * @param effect defines the current effect we try to compile
  85686. * @returns The resulting defines with defines of the current rank removed.
  85687. */
  85688. reduce(currentDefines: string, effect: Effect): string;
  85689. }
  85690. /**
  85691. * Options to be used when creating an effect.
  85692. */
  85693. export class EffectCreationOptions {
  85694. /**
  85695. * Atrributes that will be used in the shader.
  85696. */
  85697. attributes: string[];
  85698. /**
  85699. * Uniform varible names that will be set in the shader.
  85700. */
  85701. uniformsNames: string[];
  85702. /**
  85703. * Uniform buffer varible names that will be set in the shader.
  85704. */
  85705. uniformBuffersNames: string[];
  85706. /**
  85707. * Sampler texture variable names that will be set in the shader.
  85708. */
  85709. samplers: string[];
  85710. /**
  85711. * Define statements that will be set in the shader.
  85712. */
  85713. defines: any;
  85714. /**
  85715. * Possible fallbacks for this effect to improve performance when needed.
  85716. */
  85717. fallbacks: Nullable<EffectFallbacks>;
  85718. /**
  85719. * Callback that will be called when the shader is compiled.
  85720. */
  85721. onCompiled: Nullable<(effect: Effect) => void>;
  85722. /**
  85723. * Callback that will be called if an error occurs during shader compilation.
  85724. */
  85725. onError: Nullable<(effect: Effect, errors: string) => void>;
  85726. /**
  85727. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85728. */
  85729. indexParameters: any;
  85730. /**
  85731. * Max number of lights that can be used in the shader.
  85732. */
  85733. maxSimultaneousLights: number;
  85734. /**
  85735. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85736. */
  85737. transformFeedbackVaryings: Nullable<string[]>;
  85738. }
  85739. /**
  85740. * Effect containing vertex and fragment shader that can be executed on an object.
  85741. */
  85742. export class Effect {
  85743. /**
  85744. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85745. */
  85746. static ShadersRepository: string;
  85747. /**
  85748. * Name of the effect.
  85749. */
  85750. name: any;
  85751. /**
  85752. * String container all the define statements that should be set on the shader.
  85753. */
  85754. defines: string;
  85755. /**
  85756. * Callback that will be called when the shader is compiled.
  85757. */
  85758. onCompiled: Nullable<(effect: Effect) => void>;
  85759. /**
  85760. * Callback that will be called if an error occurs during shader compilation.
  85761. */
  85762. onError: Nullable<(effect: Effect, errors: string) => void>;
  85763. /**
  85764. * Callback that will be called when effect is bound.
  85765. */
  85766. onBind: Nullable<(effect: Effect) => void>;
  85767. /**
  85768. * Unique ID of the effect.
  85769. */
  85770. uniqueId: number;
  85771. /**
  85772. * Observable that will be called when the shader is compiled.
  85773. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85774. */
  85775. onCompileObservable: Observable<Effect>;
  85776. /**
  85777. * Observable that will be called if an error occurs during shader compilation.
  85778. */
  85779. onErrorObservable: Observable<Effect>;
  85780. /** @hidden */
  85781. _onBindObservable: Nullable<Observable<Effect>>;
  85782. /**
  85783. * Observable that will be called when effect is bound.
  85784. */
  85785. readonly onBindObservable: Observable<Effect>;
  85786. /** @hidden */
  85787. _bonesComputationForcedToCPU: boolean;
  85788. private static _uniqueIdSeed;
  85789. private _engine;
  85790. private _uniformBuffersNames;
  85791. private _uniformsNames;
  85792. private _samplers;
  85793. private _isReady;
  85794. private _compilationError;
  85795. private _attributesNames;
  85796. private _attributes;
  85797. private _uniforms;
  85798. /**
  85799. * Key for the effect.
  85800. * @hidden
  85801. */
  85802. _key: string;
  85803. private _indexParameters;
  85804. private _fallbacks;
  85805. private _vertexSourceCode;
  85806. private _fragmentSourceCode;
  85807. private _vertexSourceCodeOverride;
  85808. private _fragmentSourceCodeOverride;
  85809. private _transformFeedbackVaryings;
  85810. /**
  85811. * Compiled shader to webGL program.
  85812. * @hidden
  85813. */
  85814. _program: WebGLProgram;
  85815. private _valueCache;
  85816. private static _baseCache;
  85817. /**
  85818. * Instantiates an effect.
  85819. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85820. * @param baseName Name of the effect.
  85821. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85822. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85823. * @param samplers List of sampler variables that will be passed to the shader.
  85824. * @param engine Engine to be used to render the effect
  85825. * @param defines Define statements to be added to the shader.
  85826. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85827. * @param onCompiled Callback that will be called when the shader is compiled.
  85828. * @param onError Callback that will be called if an error occurs during shader compilation.
  85829. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85830. */
  85831. 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);
  85832. /**
  85833. * Unique key for this effect
  85834. */
  85835. readonly key: string;
  85836. /**
  85837. * If the effect has been compiled and prepared.
  85838. * @returns if the effect is compiled and prepared.
  85839. */
  85840. isReady(): boolean;
  85841. /**
  85842. * The engine the effect was initialized with.
  85843. * @returns the engine.
  85844. */
  85845. getEngine(): Engine;
  85846. /**
  85847. * The compiled webGL program for the effect
  85848. * @returns the webGL program.
  85849. */
  85850. getProgram(): WebGLProgram;
  85851. /**
  85852. * The set of names of attribute variables for the shader.
  85853. * @returns An array of attribute names.
  85854. */
  85855. getAttributesNames(): string[];
  85856. /**
  85857. * Returns the attribute at the given index.
  85858. * @param index The index of the attribute.
  85859. * @returns The location of the attribute.
  85860. */
  85861. getAttributeLocation(index: number): number;
  85862. /**
  85863. * Returns the attribute based on the name of the variable.
  85864. * @param name of the attribute to look up.
  85865. * @returns the attribute location.
  85866. */
  85867. getAttributeLocationByName(name: string): number;
  85868. /**
  85869. * The number of attributes.
  85870. * @returns the numnber of attributes.
  85871. */
  85872. getAttributesCount(): number;
  85873. /**
  85874. * Gets the index of a uniform variable.
  85875. * @param uniformName of the uniform to look up.
  85876. * @returns the index.
  85877. */
  85878. getUniformIndex(uniformName: string): number;
  85879. /**
  85880. * Returns the attribute based on the name of the variable.
  85881. * @param uniformName of the uniform to look up.
  85882. * @returns the location of the uniform.
  85883. */
  85884. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85885. /**
  85886. * Returns an array of sampler variable names
  85887. * @returns The array of sampler variable neames.
  85888. */
  85889. getSamplers(): string[];
  85890. /**
  85891. * The error from the last compilation.
  85892. * @returns the error string.
  85893. */
  85894. getCompilationError(): string;
  85895. /**
  85896. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85897. * @param func The callback to be used.
  85898. */
  85899. executeWhenCompiled(func: (effect: Effect) => void): void;
  85900. private _checkIsReady;
  85901. /** @hidden */
  85902. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85903. /** @hidden */
  85904. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85905. /** @hidden */
  85906. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85907. private _processShaderConversion;
  85908. private _processIncludes;
  85909. private _processPrecision;
  85910. /**
  85911. * Recompiles the webGL program
  85912. * @param vertexSourceCode The source code for the vertex shader.
  85913. * @param fragmentSourceCode The source code for the fragment shader.
  85914. * @param onCompiled Callback called when completed.
  85915. * @param onError Callback called on error.
  85916. * @hidden
  85917. */
  85918. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85919. /**
  85920. * Gets the uniform locations of the the specified variable names
  85921. * @param names THe names of the variables to lookup.
  85922. * @returns Array of locations in the same order as variable names.
  85923. */
  85924. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85925. /**
  85926. * Prepares the effect
  85927. * @hidden
  85928. */
  85929. _prepareEffect(): void;
  85930. /**
  85931. * Checks if the effect is supported. (Must be called after compilation)
  85932. */
  85933. readonly isSupported: boolean;
  85934. /**
  85935. * Binds a texture to the engine to be used as output of the shader.
  85936. * @param channel Name of the output variable.
  85937. * @param texture Texture to bind.
  85938. * @hidden
  85939. */
  85940. _bindTexture(channel: string, texture: InternalTexture): void;
  85941. /**
  85942. * Sets a texture on the engine to be used in the shader.
  85943. * @param channel Name of the sampler variable.
  85944. * @param texture Texture to set.
  85945. */
  85946. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85947. /**
  85948. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85949. * @param channel Name of the sampler variable.
  85950. * @param texture Texture to set.
  85951. */
  85952. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85953. /**
  85954. * Sets an array of textures on the engine to be used in the shader.
  85955. * @param channel Name of the variable.
  85956. * @param textures Textures to set.
  85957. */
  85958. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85959. /**
  85960. * 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)
  85961. * @param channel Name of the sampler variable.
  85962. * @param postProcess Post process to get the input texture from.
  85963. */
  85964. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85965. /**
  85966. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85967. * 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)
  85968. * @param channel Name of the sampler variable.
  85969. * @param postProcess Post process to get the output texture from.
  85970. */
  85971. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85972. /** @hidden */
  85973. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85974. /** @hidden */
  85975. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85976. /** @hidden */
  85977. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85978. /** @hidden */
  85979. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85980. /**
  85981. * Binds a buffer to a uniform.
  85982. * @param buffer Buffer to bind.
  85983. * @param name Name of the uniform variable to bind to.
  85984. */
  85985. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85986. /**
  85987. * Binds block to a uniform.
  85988. * @param blockName Name of the block to bind.
  85989. * @param index Index to bind.
  85990. */
  85991. bindUniformBlock(blockName: string, index: number): void;
  85992. /**
  85993. * Sets an interger value on a uniform variable.
  85994. * @param uniformName Name of the variable.
  85995. * @param value Value to be set.
  85996. * @returns this effect.
  85997. */
  85998. setInt(uniformName: string, value: number): Effect;
  85999. /**
  86000. * Sets an int array on a uniform variable.
  86001. * @param uniformName Name of the variable.
  86002. * @param array array to be set.
  86003. * @returns this effect.
  86004. */
  86005. setIntArray(uniformName: string, array: Int32Array): Effect;
  86006. /**
  86007. * 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)
  86008. * @param uniformName Name of the variable.
  86009. * @param array array to be set.
  86010. * @returns this effect.
  86011. */
  86012. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86013. /**
  86014. * 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)
  86015. * @param uniformName Name of the variable.
  86016. * @param array array to be set.
  86017. * @returns this effect.
  86018. */
  86019. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86020. /**
  86021. * 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)
  86022. * @param uniformName Name of the variable.
  86023. * @param array array to be set.
  86024. * @returns this effect.
  86025. */
  86026. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86027. /**
  86028. * Sets an float array on a uniform variable.
  86029. * @param uniformName Name of the variable.
  86030. * @param array array to be set.
  86031. * @returns this effect.
  86032. */
  86033. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86034. /**
  86035. * 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)
  86036. * @param uniformName Name of the variable.
  86037. * @param array array to be set.
  86038. * @returns this effect.
  86039. */
  86040. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86041. /**
  86042. * 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)
  86043. * @param uniformName Name of the variable.
  86044. * @param array array to be set.
  86045. * @returns this effect.
  86046. */
  86047. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86048. /**
  86049. * 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)
  86050. * @param uniformName Name of the variable.
  86051. * @param array array to be set.
  86052. * @returns this effect.
  86053. */
  86054. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86055. /**
  86056. * Sets an array on a uniform variable.
  86057. * @param uniformName Name of the variable.
  86058. * @param array array to be set.
  86059. * @returns this effect.
  86060. */
  86061. setArray(uniformName: string, array: number[]): Effect;
  86062. /**
  86063. * 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)
  86064. * @param uniformName Name of the variable.
  86065. * @param array array to be set.
  86066. * @returns this effect.
  86067. */
  86068. setArray2(uniformName: string, array: number[]): Effect;
  86069. /**
  86070. * 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)
  86071. * @param uniformName Name of the variable.
  86072. * @param array array to be set.
  86073. * @returns this effect.
  86074. */
  86075. setArray3(uniformName: string, array: number[]): Effect;
  86076. /**
  86077. * 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)
  86078. * @param uniformName Name of the variable.
  86079. * @param array array to be set.
  86080. * @returns this effect.
  86081. */
  86082. setArray4(uniformName: string, array: number[]): Effect;
  86083. /**
  86084. * Sets matrices on a uniform variable.
  86085. * @param uniformName Name of the variable.
  86086. * @param matrices matrices to be set.
  86087. * @returns this effect.
  86088. */
  86089. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86090. /**
  86091. * Sets matrix on a uniform variable.
  86092. * @param uniformName Name of the variable.
  86093. * @param matrix matrix to be set.
  86094. * @returns this effect.
  86095. */
  86096. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86097. /**
  86098. * 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)
  86099. * @param uniformName Name of the variable.
  86100. * @param matrix matrix to be set.
  86101. * @returns this effect.
  86102. */
  86103. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86104. /**
  86105. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86106. * @param uniformName Name of the variable.
  86107. * @param matrix matrix to be set.
  86108. * @returns this effect.
  86109. */
  86110. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86111. /**
  86112. * Sets a float on a uniform variable.
  86113. * @param uniformName Name of the variable.
  86114. * @param value value to be set.
  86115. * @returns this effect.
  86116. */
  86117. setFloat(uniformName: string, value: number): Effect;
  86118. /**
  86119. * Sets a boolean on a uniform variable.
  86120. * @param uniformName Name of the variable.
  86121. * @param bool value to be set.
  86122. * @returns this effect.
  86123. */
  86124. setBool(uniformName: string, bool: boolean): Effect;
  86125. /**
  86126. * Sets a Vector2 on a uniform variable.
  86127. * @param uniformName Name of the variable.
  86128. * @param vector2 vector2 to be set.
  86129. * @returns this effect.
  86130. */
  86131. setVector2(uniformName: string, vector2: Vector2): Effect;
  86132. /**
  86133. * Sets a float2 on a uniform variable.
  86134. * @param uniformName Name of the variable.
  86135. * @param x First float in float2.
  86136. * @param y Second float in float2.
  86137. * @returns this effect.
  86138. */
  86139. setFloat2(uniformName: string, x: number, y: number): Effect;
  86140. /**
  86141. * Sets a Vector3 on a uniform variable.
  86142. * @param uniformName Name of the variable.
  86143. * @param vector3 Value to be set.
  86144. * @returns this effect.
  86145. */
  86146. setVector3(uniformName: string, vector3: Vector3): Effect;
  86147. /**
  86148. * Sets a float3 on a uniform variable.
  86149. * @param uniformName Name of the variable.
  86150. * @param x First float in float3.
  86151. * @param y Second float in float3.
  86152. * @param z Third float in float3.
  86153. * @returns this effect.
  86154. */
  86155. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86156. /**
  86157. * Sets a Vector4 on a uniform variable.
  86158. * @param uniformName Name of the variable.
  86159. * @param vector4 Value to be set.
  86160. * @returns this effect.
  86161. */
  86162. setVector4(uniformName: string, vector4: Vector4): Effect;
  86163. /**
  86164. * Sets a float4 on a uniform variable.
  86165. * @param uniformName Name of the variable.
  86166. * @param x First float in float4.
  86167. * @param y Second float in float4.
  86168. * @param z Third float in float4.
  86169. * @param w Fourth float in float4.
  86170. * @returns this effect.
  86171. */
  86172. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86173. /**
  86174. * Sets a Color3 on a uniform variable.
  86175. * @param uniformName Name of the variable.
  86176. * @param color3 Value to be set.
  86177. * @returns this effect.
  86178. */
  86179. setColor3(uniformName: string, color3: Color3): Effect;
  86180. /**
  86181. * Sets a Color4 on a uniform variable.
  86182. * @param uniformName Name of the variable.
  86183. * @param color3 Value to be set.
  86184. * @param alpha Alpha value to be set.
  86185. * @returns this effect.
  86186. */
  86187. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86188. /**
  86189. * Sets a Color4 on a uniform variable
  86190. * @param uniformName defines the name of the variable
  86191. * @param color4 defines the value to be set
  86192. * @returns this effect.
  86193. */
  86194. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86195. /**
  86196. * This function will add a new shader to the shader store
  86197. * @param name the name of the shader
  86198. * @param pixelShader optional pixel shader content
  86199. * @param vertexShader optional vertex shader content
  86200. */
  86201. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86202. /**
  86203. * Store of each shader (The can be looked up using effect.key)
  86204. */
  86205. static ShadersStore: {
  86206. [key: string]: string;
  86207. };
  86208. /**
  86209. * Store of each included file for a shader (The can be looked up using effect.key)
  86210. */
  86211. static IncludesShadersStore: {
  86212. [key: string]: string;
  86213. };
  86214. /**
  86215. * Resets the cache of effects.
  86216. */
  86217. static ResetCache(): void;
  86218. }
  86219. }
  86220. declare module BABYLON {
  86221. /**
  86222. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86223. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86224. * 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;
  86225. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86226. */
  86227. export class ColorCurves {
  86228. private _dirty;
  86229. private _tempColor;
  86230. private _globalCurve;
  86231. private _highlightsCurve;
  86232. private _midtonesCurve;
  86233. private _shadowsCurve;
  86234. private _positiveCurve;
  86235. private _negativeCurve;
  86236. private _globalHue;
  86237. private _globalDensity;
  86238. private _globalSaturation;
  86239. private _globalExposure;
  86240. /**
  86241. * Gets the global Hue value.
  86242. * 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).
  86243. */
  86244. /**
  86245. * Sets the global Hue value.
  86246. * 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).
  86247. */
  86248. globalHue: number;
  86249. /**
  86250. * Gets 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. /**
  86255. * Sets the global Density value.
  86256. * 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.
  86257. * Values less than zero provide a filter of opposite hue.
  86258. */
  86259. globalDensity: number;
  86260. /**
  86261. * Gets the global Saturation value.
  86262. * 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.
  86263. */
  86264. /**
  86265. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  86267. */
  86268. globalSaturation: number;
  86269. /**
  86270. * Gets the global Exposure value.
  86271. * 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.
  86272. */
  86273. /**
  86274. * Sets the global Exposure value.
  86275. * 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.
  86276. */
  86277. globalExposure: number;
  86278. private _highlightsHue;
  86279. private _highlightsDensity;
  86280. private _highlightsSaturation;
  86281. private _highlightsExposure;
  86282. /**
  86283. * Gets the highlights Hue value.
  86284. * 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).
  86285. */
  86286. /**
  86287. * Sets the highlights Hue value.
  86288. * 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).
  86289. */
  86290. highlightsHue: number;
  86291. /**
  86292. * Gets 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. /**
  86297. * Sets the highlights Density value.
  86298. * 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.
  86299. * Values less than zero provide a filter of opposite hue.
  86300. */
  86301. highlightsDensity: number;
  86302. /**
  86303. * Gets the highlights Saturation value.
  86304. * 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.
  86305. */
  86306. /**
  86307. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  86309. */
  86310. highlightsSaturation: number;
  86311. /**
  86312. * Gets the highlights Exposure value.
  86313. * 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.
  86314. */
  86315. /**
  86316. * Sets the highlights Exposure value.
  86317. * 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.
  86318. */
  86319. highlightsExposure: number;
  86320. private _midtonesHue;
  86321. private _midtonesDensity;
  86322. private _midtonesSaturation;
  86323. private _midtonesExposure;
  86324. /**
  86325. * Gets the midtones Hue value.
  86326. * 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).
  86327. */
  86328. /**
  86329. * Sets the midtones Hue value.
  86330. * 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).
  86331. */
  86332. midtonesHue: number;
  86333. /**
  86334. * Gets 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. /**
  86339. * Sets the midtones Density value.
  86340. * 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.
  86341. * Values less than zero provide a filter of opposite hue.
  86342. */
  86343. midtonesDensity: number;
  86344. /**
  86345. * Gets the midtones Saturation value.
  86346. * 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.
  86347. */
  86348. /**
  86349. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  86351. */
  86352. midtonesSaturation: number;
  86353. /**
  86354. * Gets the midtones Exposure value.
  86355. * 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.
  86356. */
  86357. /**
  86358. * Sets the midtones Exposure value.
  86359. * 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.
  86360. */
  86361. midtonesExposure: number;
  86362. private _shadowsHue;
  86363. private _shadowsDensity;
  86364. private _shadowsSaturation;
  86365. private _shadowsExposure;
  86366. /**
  86367. * Gets the shadows Hue value.
  86368. * 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).
  86369. */
  86370. /**
  86371. * Sets the shadows Hue value.
  86372. * 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).
  86373. */
  86374. shadowsHue: number;
  86375. /**
  86376. * Gets 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. /**
  86381. * Sets the shadows Density value.
  86382. * 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.
  86383. * Values less than zero provide a filter of opposite hue.
  86384. */
  86385. shadowsDensity: number;
  86386. /**
  86387. * Gets the shadows Saturation value.
  86388. * 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.
  86389. */
  86390. /**
  86391. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  86393. */
  86394. shadowsSaturation: number;
  86395. /**
  86396. * Gets the shadows Exposure value.
  86397. * 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.
  86398. */
  86399. /**
  86400. * Sets the shadows Exposure value.
  86401. * 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.
  86402. */
  86403. shadowsExposure: number;
  86404. /**
  86405. * Returns the class name
  86406. * @returns The class name
  86407. */
  86408. getClassName(): string;
  86409. /**
  86410. * Binds the color curves to the shader.
  86411. * @param colorCurves The color curve to bind
  86412. * @param effect The effect to bind to
  86413. * @param positiveUniform The positive uniform shader parameter
  86414. * @param neutralUniform The neutral uniform shader parameter
  86415. * @param negativeUniform The negative uniform shader parameter
  86416. */
  86417. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86418. /**
  86419. * Prepare the list of uniforms associated with the ColorCurves effects.
  86420. * @param uniformsList The list of uniforms used in the effect
  86421. */
  86422. static PrepareUniforms(uniformsList: string[]): void;
  86423. /**
  86424. * Returns color grading data based on a hue, density, saturation and exposure value.
  86425. * @param filterHue The hue of the color filter.
  86426. * @param filterDensity The density of the color filter.
  86427. * @param saturation The saturation.
  86428. * @param exposure The exposure.
  86429. * @param result The result data container.
  86430. */
  86431. private getColorGradingDataToRef;
  86432. /**
  86433. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86434. * @param value The input slider value in range [-100,100].
  86435. * @returns Adjusted value.
  86436. */
  86437. private static applyColorGradingSliderNonlinear;
  86438. /**
  86439. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86440. * @param hue The hue (H) input.
  86441. * @param saturation The saturation (S) input.
  86442. * @param brightness The brightness (B) input.
  86443. * @result An RGBA color represented as Vector4.
  86444. */
  86445. private static fromHSBToRef;
  86446. /**
  86447. * Returns a value clamped between min and max
  86448. * @param value The value to clamp
  86449. * @param min The minimum of value
  86450. * @param max The maximum of value
  86451. * @returns The clamped value.
  86452. */
  86453. private static clamp;
  86454. /**
  86455. * Clones the current color curve instance.
  86456. * @return The cloned curves
  86457. */
  86458. clone(): ColorCurves;
  86459. /**
  86460. * Serializes the current color curve instance to a json representation.
  86461. * @return a JSON representation
  86462. */
  86463. serialize(): any;
  86464. /**
  86465. * Parses the color curve from a json representation.
  86466. * @param source the JSON source to parse
  86467. * @return The parsed curves
  86468. */
  86469. static Parse(source: any): ColorCurves;
  86470. }
  86471. }
  86472. declare module BABYLON {
  86473. /**
  86474. * Interface to follow in your material defines to integrate easily the
  86475. * Image proccessing functions.
  86476. * @hidden
  86477. */
  86478. export interface IImageProcessingConfigurationDefines {
  86479. IMAGEPROCESSING: boolean;
  86480. VIGNETTE: boolean;
  86481. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86482. VIGNETTEBLENDMODEOPAQUE: boolean;
  86483. TONEMAPPING: boolean;
  86484. TONEMAPPING_ACES: boolean;
  86485. CONTRAST: boolean;
  86486. EXPOSURE: boolean;
  86487. COLORCURVES: boolean;
  86488. COLORGRADING: boolean;
  86489. COLORGRADING3D: boolean;
  86490. SAMPLER3DGREENDEPTH: boolean;
  86491. SAMPLER3DBGRMAP: boolean;
  86492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86493. }
  86494. /**
  86495. * @hidden
  86496. */
  86497. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86498. IMAGEPROCESSING: boolean;
  86499. VIGNETTE: boolean;
  86500. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86501. VIGNETTEBLENDMODEOPAQUE: boolean;
  86502. TONEMAPPING: boolean;
  86503. TONEMAPPING_ACES: boolean;
  86504. CONTRAST: boolean;
  86505. COLORCURVES: boolean;
  86506. COLORGRADING: boolean;
  86507. COLORGRADING3D: boolean;
  86508. SAMPLER3DGREENDEPTH: boolean;
  86509. SAMPLER3DBGRMAP: boolean;
  86510. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86511. EXPOSURE: boolean;
  86512. constructor();
  86513. }
  86514. /**
  86515. * This groups together the common properties used for image processing either in direct forward pass
  86516. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86517. * or not.
  86518. */
  86519. export class ImageProcessingConfiguration {
  86520. /**
  86521. * Default tone mapping applied in BabylonJS.
  86522. */
  86523. static readonly TONEMAPPING_STANDARD: number;
  86524. /**
  86525. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86526. * to other engines rendering to increase portability.
  86527. */
  86528. static readonly TONEMAPPING_ACES: number;
  86529. /**
  86530. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86531. */
  86532. colorCurves: Nullable<ColorCurves>;
  86533. private _colorCurvesEnabled;
  86534. /**
  86535. * Gets wether the color curves effect is enabled.
  86536. */
  86537. /**
  86538. * Sets wether the color curves effect is enabled.
  86539. */
  86540. colorCurvesEnabled: boolean;
  86541. private _colorGradingTexture;
  86542. /**
  86543. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86544. */
  86545. /**
  86546. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86547. */
  86548. colorGradingTexture: Nullable<BaseTexture>;
  86549. private _colorGradingEnabled;
  86550. /**
  86551. * Gets wether the color grading effect is enabled.
  86552. */
  86553. /**
  86554. * Sets wether the color grading effect is enabled.
  86555. */
  86556. colorGradingEnabled: boolean;
  86557. private _colorGradingWithGreenDepth;
  86558. /**
  86559. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86560. */
  86561. /**
  86562. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86563. */
  86564. colorGradingWithGreenDepth: boolean;
  86565. private _colorGradingBGR;
  86566. /**
  86567. * Gets wether the color grading texture contains BGR values.
  86568. */
  86569. /**
  86570. * Sets wether the color grading texture contains BGR values.
  86571. */
  86572. colorGradingBGR: boolean;
  86573. /** @hidden */
  86574. _exposure: number;
  86575. /**
  86576. * Gets the Exposure used in the effect.
  86577. */
  86578. /**
  86579. * Sets the Exposure used in the effect.
  86580. */
  86581. exposure: number;
  86582. private _toneMappingEnabled;
  86583. /**
  86584. * Gets wether the tone mapping effect is enabled.
  86585. */
  86586. /**
  86587. * Sets wether the tone mapping effect is enabled.
  86588. */
  86589. toneMappingEnabled: boolean;
  86590. private _toneMappingType;
  86591. /**
  86592. * Gets the type of tone mapping effect.
  86593. */
  86594. /**
  86595. * Sets the type of tone mapping effect used in BabylonJS.
  86596. */
  86597. toneMappingType: number;
  86598. protected _contrast: number;
  86599. /**
  86600. * Gets the contrast used in the effect.
  86601. */
  86602. /**
  86603. * Sets the contrast used in the effect.
  86604. */
  86605. contrast: number;
  86606. /**
  86607. * Vignette stretch size.
  86608. */
  86609. vignetteStretch: number;
  86610. /**
  86611. * Vignette centre X Offset.
  86612. */
  86613. vignetteCentreX: number;
  86614. /**
  86615. * Vignette centre Y Offset.
  86616. */
  86617. vignetteCentreY: number;
  86618. /**
  86619. * Vignette weight or intensity of the vignette effect.
  86620. */
  86621. vignetteWeight: number;
  86622. /**
  86623. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86624. * if vignetteEnabled is set to true.
  86625. */
  86626. vignetteColor: Color4;
  86627. /**
  86628. * Camera field of view used by the Vignette effect.
  86629. */
  86630. vignetteCameraFov: number;
  86631. private _vignetteBlendMode;
  86632. /**
  86633. * Gets the vignette blend mode allowing different kind of effect.
  86634. */
  86635. /**
  86636. * Sets the vignette blend mode allowing different kind of effect.
  86637. */
  86638. vignetteBlendMode: number;
  86639. private _vignetteEnabled;
  86640. /**
  86641. * Gets wether the vignette effect is enabled.
  86642. */
  86643. /**
  86644. * Sets wether the vignette effect is enabled.
  86645. */
  86646. vignetteEnabled: boolean;
  86647. private _applyByPostProcess;
  86648. /**
  86649. * Gets wether the image processing is applied through a post process or not.
  86650. */
  86651. /**
  86652. * Sets wether the image processing is applied through a post process or not.
  86653. */
  86654. applyByPostProcess: boolean;
  86655. private _isEnabled;
  86656. /**
  86657. * Gets wether the image processing is enabled or not.
  86658. */
  86659. /**
  86660. * Sets wether the image processing is enabled or not.
  86661. */
  86662. isEnabled: boolean;
  86663. /**
  86664. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86665. */
  86666. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86667. /**
  86668. * Method called each time the image processing information changes requires to recompile the effect.
  86669. */
  86670. protected _updateParameters(): void;
  86671. /**
  86672. * Gets the current class name.
  86673. * @return "ImageProcessingConfiguration"
  86674. */
  86675. getClassName(): string;
  86676. /**
  86677. * Prepare the list of uniforms associated with the Image Processing effects.
  86678. * @param uniforms The list of uniforms used in the effect
  86679. * @param defines the list of defines currently in use
  86680. */
  86681. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86682. /**
  86683. * Prepare the list of samplers associated with the Image Processing effects.
  86684. * @param samplersList The list of uniforms used in the effect
  86685. * @param defines the list of defines currently in use
  86686. */
  86687. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86688. /**
  86689. * Prepare the list of defines associated to the shader.
  86690. * @param defines the list of defines to complete
  86691. * @param forPostProcess Define if we are currently in post process mode or not
  86692. */
  86693. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86694. /**
  86695. * Returns true if all the image processing information are ready.
  86696. * @returns True if ready, otherwise, false
  86697. */
  86698. isReady(): boolean;
  86699. /**
  86700. * Binds the image processing to the shader.
  86701. * @param effect The effect to bind to
  86702. * @param aspectRatio Define the current aspect ratio of the effect
  86703. */
  86704. bind(effect: Effect, aspectRatio?: number): void;
  86705. /**
  86706. * Clones the current image processing instance.
  86707. * @return The cloned image processing
  86708. */
  86709. clone(): ImageProcessingConfiguration;
  86710. /**
  86711. * Serializes the current image processing instance to a json representation.
  86712. * @return a JSON representation
  86713. */
  86714. serialize(): any;
  86715. /**
  86716. * Parses the image processing from a json representation.
  86717. * @param source the JSON source to parse
  86718. * @return The parsed image processing
  86719. */
  86720. static Parse(source: any): ImageProcessingConfiguration;
  86721. private static _VIGNETTEMODE_MULTIPLY;
  86722. private static _VIGNETTEMODE_OPAQUE;
  86723. /**
  86724. * Used to apply the vignette as a mix with the pixel color.
  86725. */
  86726. static readonly VIGNETTEMODE_MULTIPLY: number;
  86727. /**
  86728. * Used to apply the vignette as a replacement of the pixel color.
  86729. */
  86730. static readonly VIGNETTEMODE_OPAQUE: number;
  86731. }
  86732. }
  86733. declare module BABYLON {
  86734. /**
  86735. * This represents all the required information to add a fresnel effect on a material:
  86736. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86737. */
  86738. export class FresnelParameters {
  86739. private _isEnabled;
  86740. /**
  86741. * Define if the fresnel effect is enable or not.
  86742. */
  86743. isEnabled: boolean;
  86744. /**
  86745. * Define the color used on edges (grazing angle)
  86746. */
  86747. leftColor: Color3;
  86748. /**
  86749. * Define the color used on center
  86750. */
  86751. rightColor: Color3;
  86752. /**
  86753. * Define bias applied to computed fresnel term
  86754. */
  86755. bias: number;
  86756. /**
  86757. * Defined the power exponent applied to fresnel term
  86758. */
  86759. power: number;
  86760. /**
  86761. * Clones the current fresnel and its valuues
  86762. * @returns a clone fresnel configuration
  86763. */
  86764. clone(): FresnelParameters;
  86765. /**
  86766. * Serializes the current fresnel parameters to a JSON representation.
  86767. * @return the JSON serialization
  86768. */
  86769. serialize(): any;
  86770. /**
  86771. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86772. * @param parsedFresnelParameters Define the JSON representation
  86773. * @returns the parsed parameters
  86774. */
  86775. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86776. }
  86777. }
  86778. declare module BABYLON {
  86779. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86780. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86781. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86782. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86783. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86784. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86785. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86786. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86787. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86788. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86789. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86790. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86791. /**
  86792. * Decorator used to define property that can be serialized as reference to a camera
  86793. * @param sourceName defines the name of the property to decorate
  86794. */
  86795. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86796. /**
  86797. * Class used to help serialization objects
  86798. */
  86799. export class SerializationHelper {
  86800. /** hidden */
  86801. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86802. /** hidden */
  86803. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86804. /** hidden */
  86805. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86806. /** hidden */
  86807. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86808. /**
  86809. * Appends the serialized animations from the source animations
  86810. * @param source Source containing the animations
  86811. * @param destination Target to store the animations
  86812. */
  86813. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86814. /**
  86815. * Static function used to serialized a specific entity
  86816. * @param entity defines the entity to serialize
  86817. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86818. * @returns a JSON compatible object representing the serialization of the entity
  86819. */
  86820. static Serialize<T>(entity: T, serializationObject?: any): any;
  86821. /**
  86822. * Creates a new entity from a serialization data object
  86823. * @param creationFunction defines a function used to instanciated the new entity
  86824. * @param source defines the source serialization data
  86825. * @param scene defines the hosting scene
  86826. * @param rootUrl defines the root url for resources
  86827. * @returns a new entity
  86828. */
  86829. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86830. /**
  86831. * Clones an object
  86832. * @param creationFunction defines the function used to instanciate the new object
  86833. * @param source defines the source object
  86834. * @returns the cloned object
  86835. */
  86836. static Clone<T>(creationFunction: () => T, source: T): T;
  86837. /**
  86838. * Instanciates a new object based on a source one (some data will be shared between both object)
  86839. * @param creationFunction defines the function used to instanciate the new object
  86840. * @param source defines the source object
  86841. * @returns the new object
  86842. */
  86843. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86844. }
  86845. }
  86846. declare module BABYLON {
  86847. /**
  86848. * This is the base class of all the camera used in the application.
  86849. * @see http://doc.babylonjs.com/features/cameras
  86850. */
  86851. export class Camera extends Node {
  86852. /** @hidden */
  86853. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86854. /**
  86855. * This is the default projection mode used by the cameras.
  86856. * It helps recreating a feeling of perspective and better appreciate depth.
  86857. * This is the best way to simulate real life cameras.
  86858. */
  86859. static readonly PERSPECTIVE_CAMERA: number;
  86860. /**
  86861. * This helps creating camera with an orthographic mode.
  86862. * 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.
  86863. */
  86864. static readonly ORTHOGRAPHIC_CAMERA: number;
  86865. /**
  86866. * This is the default FOV mode for perspective cameras.
  86867. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86868. */
  86869. static readonly FOVMODE_VERTICAL_FIXED: number;
  86870. /**
  86871. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86872. */
  86873. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86874. /**
  86875. * This specifies ther is no need for a camera rig.
  86876. * Basically only one eye is rendered corresponding to the camera.
  86877. */
  86878. static readonly RIG_MODE_NONE: number;
  86879. /**
  86880. * Simulates a camera Rig with one blue eye and one red eye.
  86881. * This can be use with 3d blue and red glasses.
  86882. */
  86883. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86884. /**
  86885. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86886. */
  86887. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86888. /**
  86889. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86890. */
  86891. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86892. /**
  86893. * Defines that both eyes of the camera will be rendered over under each other.
  86894. */
  86895. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86896. /**
  86897. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86898. */
  86899. static readonly RIG_MODE_VR: number;
  86900. /**
  86901. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86902. */
  86903. static readonly RIG_MODE_WEBVR: number;
  86904. /**
  86905. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86906. */
  86907. static readonly RIG_MODE_CUSTOM: number;
  86908. /**
  86909. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86910. */
  86911. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86912. /**
  86913. * @hidden
  86914. * Might be removed once multiview will be a thing
  86915. */
  86916. static UseAlternateWebVRRendering: boolean;
  86917. /**
  86918. * Define the input manager associated with the camera.
  86919. */
  86920. inputs: CameraInputsManager<Camera>;
  86921. /** @hidden */
  86922. _position: Vector3;
  86923. /**
  86924. * Define the current local position of the camera in the scene
  86925. */
  86926. position: Vector3;
  86927. /**
  86928. * The vector the camera should consider as up.
  86929. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86930. */
  86931. upVector: Vector3;
  86932. /**
  86933. * Define the current limit on the left side for an orthographic camera
  86934. * In scene unit
  86935. */
  86936. orthoLeft: Nullable<number>;
  86937. /**
  86938. * Define the current limit on the right side for an orthographic camera
  86939. * In scene unit
  86940. */
  86941. orthoRight: Nullable<number>;
  86942. /**
  86943. * Define the current limit on the bottom side for an orthographic camera
  86944. * In scene unit
  86945. */
  86946. orthoBottom: Nullable<number>;
  86947. /**
  86948. * Define the current limit on the top side for an orthographic camera
  86949. * In scene unit
  86950. */
  86951. orthoTop: Nullable<number>;
  86952. /**
  86953. * Field Of View is set in Radians. (default is 0.8)
  86954. */
  86955. fov: number;
  86956. /**
  86957. * Define the minimum distance the camera can see from.
  86958. * This is important to note that the depth buffer are not infinite and the closer it starts
  86959. * the more your scene might encounter depth fighting issue.
  86960. */
  86961. minZ: number;
  86962. /**
  86963. * Define the maximum distance the camera can see to.
  86964. * This is important to note that the depth buffer are not infinite and the further it end
  86965. * the more your scene might encounter depth fighting issue.
  86966. */
  86967. maxZ: number;
  86968. /**
  86969. * Define the default inertia of the camera.
  86970. * This helps giving a smooth feeling to the camera movement.
  86971. */
  86972. inertia: number;
  86973. /**
  86974. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86975. */
  86976. mode: number;
  86977. /**
  86978. * Define wether the camera is intermediate.
  86979. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86980. */
  86981. isIntermediate: boolean;
  86982. /**
  86983. * Define the viewport of the camera.
  86984. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86985. */
  86986. viewport: Viewport;
  86987. /**
  86988. * Restricts the camera to viewing objects with the same layerMask.
  86989. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86990. */
  86991. layerMask: number;
  86992. /**
  86993. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86994. */
  86995. fovMode: number;
  86996. /**
  86997. * Rig mode of the camera.
  86998. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86999. * This is normally controlled byt the camera themselves as internal use.
  87000. */
  87001. cameraRigMode: number;
  87002. /**
  87003. * Defines the distance between both "eyes" in case of a RIG
  87004. */
  87005. interaxialDistance: number;
  87006. /**
  87007. * Defines if stereoscopic rendering is done side by side or over under.
  87008. */
  87009. isStereoscopicSideBySide: boolean;
  87010. /**
  87011. * 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
  87012. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87013. * else in the scene.
  87014. */
  87015. customRenderTargets: RenderTargetTexture[];
  87016. /**
  87017. * When set, the camera will render to this render target instead of the default canvas
  87018. */
  87019. outputRenderTarget: Nullable<RenderTargetTexture>;
  87020. /**
  87021. * Observable triggered when the camera view matrix has changed.
  87022. */
  87023. onViewMatrixChangedObservable: Observable<Camera>;
  87024. /**
  87025. * Observable triggered when the camera Projection matrix has changed.
  87026. */
  87027. onProjectionMatrixChangedObservable: Observable<Camera>;
  87028. /**
  87029. * Observable triggered when the inputs have been processed.
  87030. */
  87031. onAfterCheckInputsObservable: Observable<Camera>;
  87032. /**
  87033. * Observable triggered when reset has been called and applied to the camera.
  87034. */
  87035. onRestoreStateObservable: Observable<Camera>;
  87036. /** @hidden */
  87037. _cameraRigParams: any;
  87038. /** @hidden */
  87039. _rigCameras: Camera[];
  87040. /** @hidden */
  87041. _rigPostProcess: Nullable<PostProcess>;
  87042. protected _webvrViewMatrix: Matrix;
  87043. /** @hidden */
  87044. _skipRendering: boolean;
  87045. /** @hidden */
  87046. _alternateCamera: Camera;
  87047. /** @hidden */
  87048. _projectionMatrix: Matrix;
  87049. /** @hidden */
  87050. _postProcesses: Nullable<PostProcess>[];
  87051. /** @hidden */
  87052. _activeMeshes: SmartArray<AbstractMesh>;
  87053. protected _globalPosition: Vector3;
  87054. /** hidden */
  87055. _computedViewMatrix: Matrix;
  87056. private _doNotComputeProjectionMatrix;
  87057. private _transformMatrix;
  87058. private _frustumPlanes;
  87059. private _refreshFrustumPlanes;
  87060. private _storedFov;
  87061. private _stateStored;
  87062. /**
  87063. * Instantiates a new camera object.
  87064. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87065. * @see http://doc.babylonjs.com/features/cameras
  87066. * @param name Defines the name of the camera in the scene
  87067. * @param position Defines the position of the camera
  87068. * @param scene Defines the scene the camera belongs too
  87069. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87070. */
  87071. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87072. /**
  87073. * Store current camera state (fov, position, etc..)
  87074. * @returns the camera
  87075. */
  87076. storeState(): Camera;
  87077. /**
  87078. * Restores the camera state values if it has been stored. You must call storeState() first
  87079. */
  87080. protected _restoreStateValues(): boolean;
  87081. /**
  87082. * Restored camera state. You must call storeState() first.
  87083. * @returns true if restored and false otherwise
  87084. */
  87085. restoreState(): boolean;
  87086. /**
  87087. * Gets the class name of the camera.
  87088. * @returns the class name
  87089. */
  87090. getClassName(): string;
  87091. /** @hidden */
  87092. readonly _isCamera: boolean;
  87093. /**
  87094. * Gets a string representation of the camera useful for debug purpose.
  87095. * @param fullDetails Defines that a more verboe level of logging is required
  87096. * @returns the string representation
  87097. */
  87098. toString(fullDetails?: boolean): string;
  87099. /**
  87100. * Gets the current world space position of the camera.
  87101. */
  87102. readonly globalPosition: Vector3;
  87103. /**
  87104. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87105. * @returns the active meshe list
  87106. */
  87107. getActiveMeshes(): SmartArray<AbstractMesh>;
  87108. /**
  87109. * Check wether a mesh is part of the current active mesh list of the camera
  87110. * @param mesh Defines the mesh to check
  87111. * @returns true if active, false otherwise
  87112. */
  87113. isActiveMesh(mesh: Mesh): boolean;
  87114. /**
  87115. * Is this camera ready to be used/rendered
  87116. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87117. * @return true if the camera is ready
  87118. */
  87119. isReady(completeCheck?: boolean): boolean;
  87120. /** @hidden */
  87121. _initCache(): void;
  87122. /** @hidden */
  87123. _updateCache(ignoreParentClass?: boolean): void;
  87124. /** @hidden */
  87125. _isSynchronized(): boolean;
  87126. /** @hidden */
  87127. _isSynchronizedViewMatrix(): boolean;
  87128. /** @hidden */
  87129. _isSynchronizedProjectionMatrix(): boolean;
  87130. /**
  87131. * Attach the input controls to a specific dom element to get the input from.
  87132. * @param element Defines the element the controls should be listened from
  87133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87134. */
  87135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87136. /**
  87137. * Detach the current controls from the specified dom element.
  87138. * @param element Defines the element to stop listening the inputs from
  87139. */
  87140. detachControl(element: HTMLElement): void;
  87141. /**
  87142. * Update the camera state according to the different inputs gathered during the frame.
  87143. */
  87144. update(): void;
  87145. /** @hidden */
  87146. _checkInputs(): void;
  87147. /** @hidden */
  87148. readonly rigCameras: Camera[];
  87149. /**
  87150. * Gets the post process used by the rig cameras
  87151. */
  87152. readonly rigPostProcess: Nullable<PostProcess>;
  87153. /**
  87154. * Internal, gets the first post proces.
  87155. * @returns the first post process to be run on this camera.
  87156. */
  87157. _getFirstPostProcess(): Nullable<PostProcess>;
  87158. private _cascadePostProcessesToRigCams;
  87159. /**
  87160. * Attach a post process to the camera.
  87161. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87162. * @param postProcess The post process to attach to the camera
  87163. * @param insertAt The position of the post process in case several of them are in use in the scene
  87164. * @returns the position the post process has been inserted at
  87165. */
  87166. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87167. /**
  87168. * Detach a post process to the camera.
  87169. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87170. * @param postProcess The post process to detach from the camera
  87171. */
  87172. detachPostProcess(postProcess: PostProcess): void;
  87173. /**
  87174. * Gets the current world matrix of the camera
  87175. */
  87176. getWorldMatrix(): Matrix;
  87177. /** @hidden */
  87178. _getViewMatrix(): Matrix;
  87179. /**
  87180. * Gets the current view matrix of the camera.
  87181. * @param force forces the camera to recompute the matrix without looking at the cached state
  87182. * @returns the view matrix
  87183. */
  87184. getViewMatrix(force?: boolean): Matrix;
  87185. /**
  87186. * Freeze the projection matrix.
  87187. * It will prevent the cache check of the camera projection compute and can speed up perf
  87188. * if no parameter of the camera are meant to change
  87189. * @param projection Defines manually a projection if necessary
  87190. */
  87191. freezeProjectionMatrix(projection?: Matrix): void;
  87192. /**
  87193. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87194. */
  87195. unfreezeProjectionMatrix(): void;
  87196. /**
  87197. * Gets the current projection matrix of the camera.
  87198. * @param force forces the camera to recompute the matrix without looking at the cached state
  87199. * @returns the projection matrix
  87200. */
  87201. getProjectionMatrix(force?: boolean): Matrix;
  87202. /**
  87203. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87204. * @returns a Matrix
  87205. */
  87206. getTransformationMatrix(): Matrix;
  87207. private _updateFrustumPlanes;
  87208. /**
  87209. * Checks if a cullable object (mesh...) is in the camera frustum
  87210. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87211. * @param target The object to check
  87212. * @returns true if the object is in frustum otherwise false
  87213. */
  87214. isInFrustum(target: ICullable): boolean;
  87215. /**
  87216. * Checks if a cullable object (mesh...) is in the camera frustum
  87217. * Unlike isInFrustum this cheks the full bounding box
  87218. * @param target The object to check
  87219. * @returns true if the object is in frustum otherwise false
  87220. */
  87221. isCompletelyInFrustum(target: ICullable): boolean;
  87222. /**
  87223. * Gets a ray in the forward direction from the camera.
  87224. * @param length Defines the length of the ray to create
  87225. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87226. * @param origin Defines the start point of the ray which defaults to the camera position
  87227. * @returns the forward ray
  87228. */
  87229. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87230. /**
  87231. * Releases resources associated with this node.
  87232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87234. */
  87235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87236. /** @hidden */
  87237. _isLeftCamera: boolean;
  87238. /**
  87239. * Gets the left camera of a rig setup in case of Rigged Camera
  87240. */
  87241. readonly isLeftCamera: boolean;
  87242. /** @hidden */
  87243. _isRightCamera: boolean;
  87244. /**
  87245. * Gets the right camera of a rig setup in case of Rigged Camera
  87246. */
  87247. readonly isRightCamera: boolean;
  87248. /**
  87249. * Gets the left camera of a rig setup in case of Rigged Camera
  87250. */
  87251. readonly leftCamera: Nullable<FreeCamera>;
  87252. /**
  87253. * Gets the right camera of a rig setup in case of Rigged Camera
  87254. */
  87255. readonly rightCamera: Nullable<FreeCamera>;
  87256. /**
  87257. * Gets the left camera target of a rig setup in case of Rigged Camera
  87258. * @returns the target position
  87259. */
  87260. getLeftTarget(): Nullable<Vector3>;
  87261. /**
  87262. * Gets the right camera target of a rig setup in case of Rigged Camera
  87263. * @returns the target position
  87264. */
  87265. getRightTarget(): Nullable<Vector3>;
  87266. /**
  87267. * @hidden
  87268. */
  87269. setCameraRigMode(mode: number, rigParams: any): void;
  87270. /** @hidden */
  87271. static _setStereoscopicRigMode(camera: Camera): void;
  87272. /** @hidden */
  87273. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87274. /** @hidden */
  87275. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87276. /** @hidden */
  87277. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87278. /** @hidden */
  87279. _getVRProjectionMatrix(): Matrix;
  87280. protected _updateCameraRotationMatrix(): void;
  87281. protected _updateWebVRCameraRotationMatrix(): void;
  87282. /**
  87283. * This function MUST be overwritten by the different WebVR cameras available.
  87284. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87285. * @hidden
  87286. */
  87287. _getWebVRProjectionMatrix(): Matrix;
  87288. /**
  87289. * This function MUST be overwritten by the different WebVR cameras available.
  87290. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87291. * @hidden
  87292. */
  87293. _getWebVRViewMatrix(): Matrix;
  87294. /** @hidden */
  87295. setCameraRigParameter(name: string, value: any): void;
  87296. /**
  87297. * needs to be overridden by children so sub has required properties to be copied
  87298. * @hidden
  87299. */
  87300. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87301. /**
  87302. * May need to be overridden by children
  87303. * @hidden
  87304. */
  87305. _updateRigCameras(): void;
  87306. /** @hidden */
  87307. _setupInputs(): void;
  87308. /**
  87309. * Serialiaze the camera setup to a json represention
  87310. * @returns the JSON representation
  87311. */
  87312. serialize(): any;
  87313. /**
  87314. * Clones the current camera.
  87315. * @param name The cloned camera name
  87316. * @returns the cloned camera
  87317. */
  87318. clone(name: string): Camera;
  87319. /**
  87320. * Gets the direction of the camera relative to a given local axis.
  87321. * @param localAxis Defines the reference axis to provide a relative direction.
  87322. * @return the direction
  87323. */
  87324. getDirection(localAxis: Vector3): Vector3;
  87325. /**
  87326. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87327. * @param localAxis Defines the reference axis to provide a relative direction.
  87328. * @param result Defines the vector to store the result in
  87329. */
  87330. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87331. /**
  87332. * Gets a camera constructor for a given camera type
  87333. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87334. * @param name The name of the camera the result will be able to instantiate
  87335. * @param scene The scene the result will construct the camera in
  87336. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87337. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87338. * @returns a factory method to construc the camera
  87339. */
  87340. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87341. /**
  87342. * Compute the world matrix of the camera.
  87343. * @returns the camera workd matrix
  87344. */
  87345. computeWorldMatrix(): Matrix;
  87346. /**
  87347. * Parse a JSON and creates the camera from the parsed information
  87348. * @param parsedCamera The JSON to parse
  87349. * @param scene The scene to instantiate the camera in
  87350. * @returns the newly constructed camera
  87351. */
  87352. static Parse(parsedCamera: any, scene: Scene): Camera;
  87353. }
  87354. }
  87355. declare module BABYLON {
  87356. /**
  87357. * Interface for any object that can request an animation frame
  87358. */
  87359. export interface ICustomAnimationFrameRequester {
  87360. /**
  87361. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87362. */
  87363. renderFunction?: Function;
  87364. /**
  87365. * Called to request the next frame to render to
  87366. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87367. */
  87368. requestAnimationFrame: Function;
  87369. /**
  87370. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87371. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87372. */
  87373. requestID?: number;
  87374. }
  87375. /**
  87376. * Interface containing an array of animations
  87377. */
  87378. export interface IAnimatable {
  87379. /**
  87380. * Array of animations
  87381. */
  87382. animations: Array<Animation>;
  87383. }
  87384. /** Interface used by value gradients (color, factor, ...) */
  87385. export interface IValueGradient {
  87386. /**
  87387. * Gets or sets the gradient value (between 0 and 1)
  87388. */
  87389. gradient: number;
  87390. }
  87391. /** Class used to store color4 gradient */
  87392. export class ColorGradient implements IValueGradient {
  87393. /**
  87394. * Gets or sets the gradient value (between 0 and 1)
  87395. */
  87396. gradient: number;
  87397. /**
  87398. * Gets or sets first associated color
  87399. */
  87400. color1: Color4;
  87401. /**
  87402. * Gets or sets second associated color
  87403. */
  87404. color2?: Color4;
  87405. /**
  87406. * Will get a color picked randomly between color1 and color2.
  87407. * If color2 is undefined then color1 will be used
  87408. * @param result defines the target Color4 to store the result in
  87409. */
  87410. getColorToRef(result: Color4): void;
  87411. }
  87412. /** Class used to store color 3 gradient */
  87413. export class Color3Gradient implements IValueGradient {
  87414. /**
  87415. * Gets or sets the gradient value (between 0 and 1)
  87416. */
  87417. gradient: number;
  87418. /**
  87419. * Gets or sets the associated color
  87420. */
  87421. color: Color3;
  87422. }
  87423. /** Class used to store factor gradient */
  87424. export class FactorGradient implements IValueGradient {
  87425. /**
  87426. * Gets or sets the gradient value (between 0 and 1)
  87427. */
  87428. gradient: number;
  87429. /**
  87430. * Gets or sets first associated factor
  87431. */
  87432. factor1: number;
  87433. /**
  87434. * Gets or sets second associated factor
  87435. */
  87436. factor2?: number;
  87437. /**
  87438. * Will get a number picked randomly between factor1 and factor2.
  87439. * If factor2 is undefined then factor1 will be used
  87440. * @returns the picked number
  87441. */
  87442. getFactor(): number;
  87443. }
  87444. /**
  87445. * @ignore
  87446. * Application error to support additional information when loading a file
  87447. */
  87448. export class LoadFileError extends Error {
  87449. /** defines the optional XHR request */
  87450. request?: XMLHttpRequest | undefined;
  87451. private static _setPrototypeOf;
  87452. /**
  87453. * Creates a new LoadFileError
  87454. * @param message defines the message of the error
  87455. * @param request defines the optional XHR request
  87456. */
  87457. constructor(message: string,
  87458. /** defines the optional XHR request */
  87459. request?: XMLHttpRequest | undefined);
  87460. }
  87461. /**
  87462. * Class used to define a retry strategy when error happens while loading assets
  87463. */
  87464. export class RetryStrategy {
  87465. /**
  87466. * Function used to defines an exponential back off strategy
  87467. * @param maxRetries defines the maximum number of retries (3 by default)
  87468. * @param baseInterval defines the interval between retries
  87469. * @returns the strategy function to use
  87470. */
  87471. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87472. }
  87473. /**
  87474. * File request interface
  87475. */
  87476. export interface IFileRequest {
  87477. /**
  87478. * Raised when the request is complete (success or error).
  87479. */
  87480. onCompleteObservable: Observable<IFileRequest>;
  87481. /**
  87482. * Aborts the request for a file.
  87483. */
  87484. abort: () => void;
  87485. }
  87486. /**
  87487. * Class containing a set of static utilities functions
  87488. */
  87489. export class Tools {
  87490. /**
  87491. * Gets or sets the base URL to use to load assets
  87492. */
  87493. static BaseUrl: string;
  87494. /**
  87495. * Enable/Disable Custom HTTP Request Headers globally.
  87496. * default = false
  87497. * @see CustomRequestHeaders
  87498. */
  87499. static UseCustomRequestHeaders: boolean;
  87500. /**
  87501. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87502. * i.e. when loading files, where the server/service expects an Authorization header.
  87503. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87504. */
  87505. static CustomRequestHeaders: {
  87506. [key: string]: string;
  87507. };
  87508. /**
  87509. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87510. */
  87511. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87512. /**
  87513. * Default behaviour for cors in the application.
  87514. * It can be a string if the expected behavior is identical in the entire app.
  87515. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87516. */
  87517. static CorsBehavior: string | ((url: string | string[]) => string);
  87518. /**
  87519. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87520. * @ignorenaming
  87521. */
  87522. static UseFallbackTexture: boolean;
  87523. /**
  87524. * Use this object to register external classes like custom textures or material
  87525. * to allow the laoders to instantiate them
  87526. */
  87527. static RegisteredExternalClasses: {
  87528. [key: string]: Object;
  87529. };
  87530. /**
  87531. * Texture content used if a texture cannot loaded
  87532. * @ignorenaming
  87533. */
  87534. static fallbackTexture: string;
  87535. /**
  87536. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87537. * @param u defines the coordinate on X axis
  87538. * @param v defines the coordinate on Y axis
  87539. * @param width defines the width of the source data
  87540. * @param height defines the height of the source data
  87541. * @param pixels defines the source byte array
  87542. * @param color defines the output color
  87543. */
  87544. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87545. /**
  87546. * Interpolates between a and b via alpha
  87547. * @param a The lower value (returned when alpha = 0)
  87548. * @param b The upper value (returned when alpha = 1)
  87549. * @param alpha The interpolation-factor
  87550. * @return The mixed value
  87551. */
  87552. static Mix(a: number, b: number, alpha: number): number;
  87553. /**
  87554. * Tries to instantiate a new object from a given class name
  87555. * @param className defines the class name to instantiate
  87556. * @returns the new object or null if the system was not able to do the instantiation
  87557. */
  87558. static Instantiate(className: string): any;
  87559. /**
  87560. * Provides a slice function that will work even on IE
  87561. * @param data defines the array to slice
  87562. * @param start defines the start of the data (optional)
  87563. * @param end defines the end of the data (optional)
  87564. * @returns the new sliced array
  87565. */
  87566. static Slice<T>(data: T, start?: number, end?: number): T;
  87567. /**
  87568. * Polyfill for setImmediate
  87569. * @param action defines the action to execute after the current execution block
  87570. */
  87571. static SetImmediate(action: () => void): void;
  87572. /**
  87573. * Function indicating if a number is an exponent of 2
  87574. * @param value defines the value to test
  87575. * @returns true if the value is an exponent of 2
  87576. */
  87577. static IsExponentOfTwo(value: number): boolean;
  87578. private static _tmpFloatArray;
  87579. /**
  87580. * Returns the nearest 32-bit single precision float representation of a Number
  87581. * @param value A Number. If the parameter is of a different type, it will get converted
  87582. * to a number or to NaN if it cannot be converted
  87583. * @returns number
  87584. */
  87585. static FloatRound(value: number): number;
  87586. /**
  87587. * Find the next highest power of two.
  87588. * @param x Number to start search from.
  87589. * @return Next highest power of two.
  87590. */
  87591. static CeilingPOT(x: number): number;
  87592. /**
  87593. * Find the next lowest power of two.
  87594. * @param x Number to start search from.
  87595. * @return Next lowest power of two.
  87596. */
  87597. static FloorPOT(x: number): number;
  87598. /**
  87599. * Find the nearest power of two.
  87600. * @param x Number to start search from.
  87601. * @return Next nearest power of two.
  87602. */
  87603. static NearestPOT(x: number): number;
  87604. /**
  87605. * Get the closest exponent of two
  87606. * @param value defines the value to approximate
  87607. * @param max defines the maximum value to return
  87608. * @param mode defines how to define the closest value
  87609. * @returns closest exponent of two of the given value
  87610. */
  87611. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87612. /**
  87613. * Extracts the filename from a path
  87614. * @param path defines the path to use
  87615. * @returns the filename
  87616. */
  87617. static GetFilename(path: string): string;
  87618. /**
  87619. * Extracts the "folder" part of a path (everything before the filename).
  87620. * @param uri The URI to extract the info from
  87621. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87622. * @returns The "folder" part of the path
  87623. */
  87624. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87625. /**
  87626. * Extracts text content from a DOM element hierarchy
  87627. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87628. */
  87629. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87630. /**
  87631. * Convert an angle in radians to degrees
  87632. * @param angle defines the angle to convert
  87633. * @returns the angle in degrees
  87634. */
  87635. static ToDegrees(angle: number): number;
  87636. /**
  87637. * Convert an angle in degrees to radians
  87638. * @param angle defines the angle to convert
  87639. * @returns the angle in radians
  87640. */
  87641. static ToRadians(angle: number): number;
  87642. /**
  87643. * Encode a buffer to a base64 string
  87644. * @param buffer defines the buffer to encode
  87645. * @returns the encoded string
  87646. */
  87647. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87648. /**
  87649. * Extracts minimum and maximum values from a list of indexed positions
  87650. * @param positions defines the positions to use
  87651. * @param indices defines the indices to the positions
  87652. * @param indexStart defines the start index
  87653. * @param indexCount defines the end index
  87654. * @param bias defines bias value to add to the result
  87655. * @return minimum and maximum values
  87656. */
  87657. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87658. minimum: Vector3;
  87659. maximum: Vector3;
  87660. };
  87661. /**
  87662. * Extracts minimum and maximum values from a list of positions
  87663. * @param positions defines the positions to use
  87664. * @param start defines the start index in the positions array
  87665. * @param count defines the number of positions to handle
  87666. * @param bias defines bias value to add to the result
  87667. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87668. * @return minimum and maximum values
  87669. */
  87670. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87671. minimum: Vector3;
  87672. maximum: Vector3;
  87673. };
  87674. /**
  87675. * Returns an array if obj is not an array
  87676. * @param obj defines the object to evaluate as an array
  87677. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87678. * @returns either obj directly if obj is an array or a new array containing obj
  87679. */
  87680. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87681. /**
  87682. * Gets the pointer prefix to use
  87683. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87684. */
  87685. static GetPointerPrefix(): string;
  87686. /**
  87687. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87688. * @param func - the function to be called
  87689. * @param requester - the object that will request the next frame. Falls back to window.
  87690. * @returns frame number
  87691. */
  87692. static QueueNewFrame(func: () => void, requester?: any): number;
  87693. /**
  87694. * Ask the browser to promote the current element to fullscreen rendering mode
  87695. * @param element defines the DOM element to promote
  87696. */
  87697. static RequestFullscreen(element: HTMLElement): void;
  87698. /**
  87699. * Asks the browser to exit fullscreen mode
  87700. */
  87701. static ExitFullscreen(): void;
  87702. /**
  87703. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87704. * @param url define the url we are trying
  87705. * @param element define the dom element where to configure the cors policy
  87706. */
  87707. static SetCorsBehavior(url: string | string[], element: {
  87708. crossOrigin: string | null;
  87709. }): void;
  87710. /**
  87711. * Removes unwanted characters from an url
  87712. * @param url defines the url to clean
  87713. * @returns the cleaned url
  87714. */
  87715. static CleanUrl(url: string): string;
  87716. /**
  87717. * Gets or sets a function used to pre-process url before using them to load assets
  87718. */
  87719. static PreprocessUrl: (url: string) => string;
  87720. /**
  87721. * Loads an image as an HTMLImageElement.
  87722. * @param input url string, ArrayBuffer, or Blob to load
  87723. * @param onLoad callback called when the image successfully loads
  87724. * @param onError callback called when the image fails to load
  87725. * @param offlineProvider offline provider for caching
  87726. * @returns the HTMLImageElement of the loaded image
  87727. */
  87728. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87729. /**
  87730. * Loads a file
  87731. * @param url url string, ArrayBuffer, or Blob to load
  87732. * @param onSuccess callback called when the file successfully loads
  87733. * @param onProgress callback called while file is loading (if the server supports this mode)
  87734. * @param offlineProvider defines the offline provider for caching
  87735. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87736. * @param onError callback called when the file fails to load
  87737. * @returns a file request object
  87738. */
  87739. 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;
  87740. /**
  87741. * Load a script (identified by an url). When the url returns, the
  87742. * content of this file is added into a new script element, attached to the DOM (body element)
  87743. * @param scriptUrl defines the url of the script to laod
  87744. * @param onSuccess defines the callback called when the script is loaded
  87745. * @param onError defines the callback to call if an error occurs
  87746. */
  87747. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87748. /**
  87749. * Loads a file from a blob
  87750. * @param fileToLoad defines the blob to use
  87751. * @param callback defines the callback to call when data is loaded
  87752. * @param progressCallback defines the callback to call during loading process
  87753. * @returns a file request object
  87754. */
  87755. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87756. /**
  87757. * Loads a file
  87758. * @param fileToLoad defines the file to load
  87759. * @param callback defines the callback to call when data is loaded
  87760. * @param progressCallBack defines the callback to call during loading process
  87761. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87762. * @returns a file request object
  87763. */
  87764. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87765. /**
  87766. * Creates a data url from a given string content
  87767. * @param content defines the content to convert
  87768. * @returns the new data url link
  87769. */
  87770. static FileAsURL(content: string): string;
  87771. /**
  87772. * Format the given number to a specific decimal format
  87773. * @param value defines the number to format
  87774. * @param decimals defines the number of decimals to use
  87775. * @returns the formatted string
  87776. */
  87777. static Format(value: number, decimals?: number): string;
  87778. /**
  87779. * Checks if a given vector is inside a specific range
  87780. * @param v defines the vector to test
  87781. * @param min defines the minimum range
  87782. * @param max defines the maximum range
  87783. */
  87784. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87785. /**
  87786. * Tries to copy an object by duplicating every property
  87787. * @param source defines the source object
  87788. * @param destination defines the target object
  87789. * @param doNotCopyList defines a list of properties to avoid
  87790. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87791. */
  87792. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87793. /**
  87794. * Gets a boolean indicating if the given object has no own property
  87795. * @param obj defines the object to test
  87796. * @returns true if object has no own property
  87797. */
  87798. static IsEmpty(obj: any): boolean;
  87799. /**
  87800. * Function used to register events at window level
  87801. * @param events defines the events to register
  87802. */
  87803. static RegisterTopRootEvents(events: {
  87804. name: string;
  87805. handler: Nullable<(e: FocusEvent) => any>;
  87806. }[]): void;
  87807. /**
  87808. * Function used to unregister events from window level
  87809. * @param events defines the events to unregister
  87810. */
  87811. static UnregisterTopRootEvents(events: {
  87812. name: string;
  87813. handler: Nullable<(e: FocusEvent) => any>;
  87814. }[]): void;
  87815. /**
  87816. * @ignore
  87817. */
  87818. static _ScreenshotCanvas: HTMLCanvasElement;
  87819. /**
  87820. * Dumps the current bound framebuffer
  87821. * @param width defines the rendering width
  87822. * @param height defines the rendering height
  87823. * @param engine defines the hosting engine
  87824. * @param successCallback defines the callback triggered once the data are available
  87825. * @param mimeType defines the mime type of the result
  87826. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87827. */
  87828. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87829. /**
  87830. * Converts the canvas data to blob.
  87831. * This acts as a polyfill for browsers not supporting the to blob function.
  87832. * @param canvas Defines the canvas to extract the data from
  87833. * @param successCallback Defines the callback triggered once the data are available
  87834. * @param mimeType Defines the mime type of the result
  87835. */
  87836. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87837. /**
  87838. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87839. * @param successCallback defines the callback triggered once the data are available
  87840. * @param mimeType defines the mime type of the result
  87841. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87842. */
  87843. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87844. /**
  87845. * Downloads a blob in the browser
  87846. * @param blob defines the blob to download
  87847. * @param fileName defines the name of the downloaded file
  87848. */
  87849. static Download(blob: Blob, fileName: string): void;
  87850. /**
  87851. * Captures a screenshot of the current rendering
  87852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87853. * @param engine defines the rendering engine
  87854. * @param camera defines the source camera
  87855. * @param size This parameter can be set to a single number or to an object with the
  87856. * following (optional) properties: precision, width, height. If a single number is passed,
  87857. * it will be used for both width and height. If an object is passed, the screenshot size
  87858. * will be derived from the parameters. The precision property is a multiplier allowing
  87859. * rendering at a higher or lower resolution
  87860. * @param successCallback defines the callback receives a single parameter which contains the
  87861. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87862. * src parameter of an <img> to display it
  87863. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87864. * Check your browser for supported MIME types
  87865. */
  87866. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87867. /**
  87868. * Generates an image screenshot from the specified camera.
  87869. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87870. * @param engine The engine to use for rendering
  87871. * @param camera The camera to use for rendering
  87872. * @param size This parameter can be set to a single number or to an object with the
  87873. * following (optional) properties: precision, width, height. If a single number is passed,
  87874. * it will be used for both width and height. If an object is passed, the screenshot size
  87875. * will be derived from the parameters. The precision property is a multiplier allowing
  87876. * rendering at a higher or lower resolution
  87877. * @param successCallback The callback receives a single parameter which contains the
  87878. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87879. * src parameter of an <img> to display it
  87880. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87881. * Check your browser for supported MIME types
  87882. * @param samples Texture samples (default: 1)
  87883. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87884. * @param fileName A name for for the downloaded file.
  87885. */
  87886. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87887. /**
  87888. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87889. * Be aware Math.random() could cause collisions, but:
  87890. * "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"
  87891. * @returns a pseudo random id
  87892. */
  87893. static RandomId(): string;
  87894. /**
  87895. * Test if the given uri is a base64 string
  87896. * @param uri The uri to test
  87897. * @return True if the uri is a base64 string or false otherwise
  87898. */
  87899. static IsBase64(uri: string): boolean;
  87900. /**
  87901. * Decode the given base64 uri.
  87902. * @param uri The uri to decode
  87903. * @return The decoded base64 data.
  87904. */
  87905. static DecodeBase64(uri: string): ArrayBuffer;
  87906. /**
  87907. * No log
  87908. */
  87909. static readonly NoneLogLevel: number;
  87910. /**
  87911. * Only message logs
  87912. */
  87913. static readonly MessageLogLevel: number;
  87914. /**
  87915. * Only warning logs
  87916. */
  87917. static readonly WarningLogLevel: number;
  87918. /**
  87919. * Only error logs
  87920. */
  87921. static readonly ErrorLogLevel: number;
  87922. /**
  87923. * All logs
  87924. */
  87925. static readonly AllLogLevel: number;
  87926. /**
  87927. * Gets a value indicating the number of loading errors
  87928. * @ignorenaming
  87929. */
  87930. static readonly errorsCount: number;
  87931. /**
  87932. * Callback called when a new log is added
  87933. */
  87934. static OnNewCacheEntry: (entry: string) => void;
  87935. /**
  87936. * Log a message to the console
  87937. * @param message defines the message to log
  87938. */
  87939. static Log(message: string): void;
  87940. /**
  87941. * Write a warning message to the console
  87942. * @param message defines the message to log
  87943. */
  87944. static Warn(message: string): void;
  87945. /**
  87946. * Write an error message to the console
  87947. * @param message defines the message to log
  87948. */
  87949. static Error(message: string): void;
  87950. /**
  87951. * Gets current log cache (list of logs)
  87952. */
  87953. static readonly LogCache: string;
  87954. /**
  87955. * Clears the log cache
  87956. */
  87957. static ClearLogCache(): void;
  87958. /**
  87959. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87960. */
  87961. static LogLevels: number;
  87962. /**
  87963. * Checks if the loaded document was accessed via `file:`-Protocol.
  87964. * @returns boolean
  87965. */
  87966. static IsFileURL(): boolean;
  87967. /**
  87968. * Checks if the window object exists
  87969. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87970. */
  87971. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87972. /**
  87973. * No performance log
  87974. */
  87975. static readonly PerformanceNoneLogLevel: number;
  87976. /**
  87977. * Use user marks to log performance
  87978. */
  87979. static readonly PerformanceUserMarkLogLevel: number;
  87980. /**
  87981. * Log performance to the console
  87982. */
  87983. static readonly PerformanceConsoleLogLevel: number;
  87984. private static _performance;
  87985. /**
  87986. * Sets the current performance log level
  87987. */
  87988. static PerformanceLogLevel: number;
  87989. private static _StartPerformanceCounterDisabled;
  87990. private static _EndPerformanceCounterDisabled;
  87991. private static _StartUserMark;
  87992. private static _EndUserMark;
  87993. private static _StartPerformanceConsole;
  87994. private static _EndPerformanceConsole;
  87995. /**
  87996. * Injects the @see CustomRequestHeaders into the given request
  87997. * @param request the request that should be used for injection
  87998. */
  87999. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  88000. /**
  88001. * Starts a performance counter
  88002. */
  88003. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88004. /**
  88005. * Ends a specific performance coutner
  88006. */
  88007. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88008. /**
  88009. * Gets either window.performance.now() if supported or Date.now() else
  88010. */
  88011. static readonly Now: number;
  88012. /**
  88013. * This method will return the name of the class used to create the instance of the given object.
  88014. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88015. * @param object the object to get the class name from
  88016. * @param isType defines if the object is actually a type
  88017. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88018. */
  88019. static GetClassName(object: any, isType?: boolean): string;
  88020. /**
  88021. * Gets the first element of an array satisfying a given predicate
  88022. * @param array defines the array to browse
  88023. * @param predicate defines the predicate to use
  88024. * @returns null if not found or the element
  88025. */
  88026. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88027. /**
  88028. * This method will return the name of the full name of the class, including its owning module (if any).
  88029. * 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).
  88030. * @param object the object to get the class name from
  88031. * @param isType defines if the object is actually a type
  88032. * @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.
  88033. * @ignorenaming
  88034. */
  88035. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88036. /**
  88037. * Returns a promise that resolves after the given amount of time.
  88038. * @param delay Number of milliseconds to delay
  88039. * @returns Promise that resolves after the given amount of time
  88040. */
  88041. static DelayAsync(delay: number): Promise<void>;
  88042. /**
  88043. * Gets the current gradient from an array of IValueGradient
  88044. * @param ratio defines the current ratio to get
  88045. * @param gradients defines the array of IValueGradient
  88046. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88047. */
  88048. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88049. }
  88050. /**
  88051. * This class is used to track a performance counter which is number based.
  88052. * The user has access to many properties which give statistics of different nature.
  88053. *
  88054. * The implementer can track two kinds of Performance Counter: time and count.
  88055. * 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.
  88056. * 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.
  88057. */
  88058. export class PerfCounter {
  88059. /**
  88060. * Gets or sets a global boolean to turn on and off all the counters
  88061. */
  88062. static Enabled: boolean;
  88063. /**
  88064. * Returns the smallest value ever
  88065. */
  88066. readonly min: number;
  88067. /**
  88068. * Returns the biggest value ever
  88069. */
  88070. readonly max: number;
  88071. /**
  88072. * Returns the average value since the performance counter is running
  88073. */
  88074. readonly average: number;
  88075. /**
  88076. * Returns the average value of the last second the counter was monitored
  88077. */
  88078. readonly lastSecAverage: number;
  88079. /**
  88080. * Returns the current value
  88081. */
  88082. readonly current: number;
  88083. /**
  88084. * Gets the accumulated total
  88085. */
  88086. readonly total: number;
  88087. /**
  88088. * Gets the total value count
  88089. */
  88090. readonly count: number;
  88091. /**
  88092. * Creates a new counter
  88093. */
  88094. constructor();
  88095. /**
  88096. * Call this method to start monitoring a new frame.
  88097. * 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.
  88098. */
  88099. fetchNewFrame(): void;
  88100. /**
  88101. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88102. * @param newCount the count value to add to the monitored count
  88103. * @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.
  88104. */
  88105. addCount(newCount: number, fetchResult: boolean): void;
  88106. /**
  88107. * Start monitoring this performance counter
  88108. */
  88109. beginMonitoring(): void;
  88110. /**
  88111. * Compute the time lapsed since the previous beginMonitoring() call.
  88112. * @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
  88113. */
  88114. endMonitoring(newFrame?: boolean): void;
  88115. private _fetchResult;
  88116. private _startMonitoringTime;
  88117. private _min;
  88118. private _max;
  88119. private _average;
  88120. private _current;
  88121. private _totalValueCount;
  88122. private _totalAccumulated;
  88123. private _lastSecAverage;
  88124. private _lastSecAccumulated;
  88125. private _lastSecTime;
  88126. private _lastSecValueCount;
  88127. }
  88128. /**
  88129. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88130. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88131. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88132. * @param name The name of the class, case should be preserved
  88133. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88134. */
  88135. export function className(name: string, module?: string): (target: Object) => void;
  88136. /**
  88137. * An implementation of a loop for asynchronous functions.
  88138. */
  88139. export class AsyncLoop {
  88140. /**
  88141. * Defines the number of iterations for the loop
  88142. */
  88143. iterations: number;
  88144. /**
  88145. * Defines the current index of the loop.
  88146. */
  88147. index: number;
  88148. private _done;
  88149. private _fn;
  88150. private _successCallback;
  88151. /**
  88152. * Constructor.
  88153. * @param iterations the number of iterations.
  88154. * @param func the function to run each iteration
  88155. * @param successCallback the callback that will be called upon succesful execution
  88156. * @param offset starting offset.
  88157. */
  88158. constructor(
  88159. /**
  88160. * Defines the number of iterations for the loop
  88161. */
  88162. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88163. /**
  88164. * Execute the next iteration. Must be called after the last iteration was finished.
  88165. */
  88166. executeNext(): void;
  88167. /**
  88168. * Break the loop and run the success callback.
  88169. */
  88170. breakLoop(): void;
  88171. /**
  88172. * Create and run an async loop.
  88173. * @param iterations the number of iterations.
  88174. * @param fn the function to run each iteration
  88175. * @param successCallback the callback that will be called upon succesful execution
  88176. * @param offset starting offset.
  88177. * @returns the created async loop object
  88178. */
  88179. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88180. /**
  88181. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88182. * @param iterations total number of iterations
  88183. * @param syncedIterations number of synchronous iterations in each async iteration.
  88184. * @param fn the function to call each iteration.
  88185. * @param callback a success call back that will be called when iterating stops.
  88186. * @param breakFunction a break condition (optional)
  88187. * @param timeout timeout settings for the setTimeout function. default - 0.
  88188. * @returns the created async loop object
  88189. */
  88190. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88191. }
  88192. }
  88193. declare module BABYLON {
  88194. /** @hidden */
  88195. export interface ICollisionCoordinator {
  88196. createCollider(): Collider;
  88197. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88198. init(scene: Scene): void;
  88199. }
  88200. /** @hidden */
  88201. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88202. private _scene;
  88203. private _scaledPosition;
  88204. private _scaledVelocity;
  88205. private _finalPosition;
  88206. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88207. createCollider(): Collider;
  88208. init(scene: Scene): void;
  88209. private _collideWithWorld;
  88210. }
  88211. }
  88212. declare module BABYLON {
  88213. /**
  88214. * This class defines the direct association between an animation and a target
  88215. */
  88216. export class TargetedAnimation {
  88217. /**
  88218. * Animation to perform
  88219. */
  88220. animation: Animation;
  88221. /**
  88222. * Target to animate
  88223. */
  88224. target: any;
  88225. }
  88226. /**
  88227. * Use this class to create coordinated animations on multiple targets
  88228. */
  88229. export class AnimationGroup implements IDisposable {
  88230. /** The name of the animation group */
  88231. name: string;
  88232. private _scene;
  88233. private _targetedAnimations;
  88234. private _animatables;
  88235. private _from;
  88236. private _to;
  88237. private _isStarted;
  88238. private _isPaused;
  88239. private _speedRatio;
  88240. /**
  88241. * Gets or sets the unique id of the node
  88242. */
  88243. uniqueId: number;
  88244. /**
  88245. * This observable will notify when one animation have ended
  88246. */
  88247. onAnimationEndObservable: Observable<TargetedAnimation>;
  88248. /**
  88249. * Observer raised when one animation loops
  88250. */
  88251. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88252. /**
  88253. * This observable will notify when all animations have ended.
  88254. */
  88255. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88256. /**
  88257. * This observable will notify when all animations have paused.
  88258. */
  88259. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88260. /**
  88261. * This observable will notify when all animations are playing.
  88262. */
  88263. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88264. /**
  88265. * Gets the first frame
  88266. */
  88267. readonly from: number;
  88268. /**
  88269. * Gets the last frame
  88270. */
  88271. readonly to: number;
  88272. /**
  88273. * Define if the animations are started
  88274. */
  88275. readonly isStarted: boolean;
  88276. /**
  88277. * Gets a value indicating that the current group is playing
  88278. */
  88279. readonly isPlaying: boolean;
  88280. /**
  88281. * Gets or sets the speed ratio to use for all animations
  88282. */
  88283. /**
  88284. * Gets or sets the speed ratio to use for all animations
  88285. */
  88286. speedRatio: number;
  88287. /**
  88288. * Gets the targeted animations for this animation group
  88289. */
  88290. readonly targetedAnimations: Array<TargetedAnimation>;
  88291. /**
  88292. * returning the list of animatables controlled by this animation group.
  88293. */
  88294. readonly animatables: Array<Animatable>;
  88295. /**
  88296. * Instantiates a new Animation Group.
  88297. * This helps managing several animations at once.
  88298. * @see http://doc.babylonjs.com/how_to/group
  88299. * @param name Defines the name of the group
  88300. * @param scene Defines the scene the group belongs to
  88301. */
  88302. constructor(
  88303. /** The name of the animation group */
  88304. name: string, scene?: Nullable<Scene>);
  88305. /**
  88306. * Add an animation (with its target) in the group
  88307. * @param animation defines the animation we want to add
  88308. * @param target defines the target of the animation
  88309. * @returns the TargetedAnimation object
  88310. */
  88311. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88312. /**
  88313. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88314. * It can add constant keys at begin or end
  88315. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88316. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88317. * @returns the animation group
  88318. */
  88319. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88320. /**
  88321. * Start all animations on given targets
  88322. * @param loop defines if animations must loop
  88323. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88324. * @param from defines the from key (optional)
  88325. * @param to defines the to key (optional)
  88326. * @returns the current animation group
  88327. */
  88328. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88329. /**
  88330. * Pause all animations
  88331. * @returns the animation group
  88332. */
  88333. pause(): AnimationGroup;
  88334. /**
  88335. * Play all animations to initial state
  88336. * This function will start() the animations if they were not started or will restart() them if they were paused
  88337. * @param loop defines if animations must loop
  88338. * @returns the animation group
  88339. */
  88340. play(loop?: boolean): AnimationGroup;
  88341. /**
  88342. * Reset all animations to initial state
  88343. * @returns the animation group
  88344. */
  88345. reset(): AnimationGroup;
  88346. /**
  88347. * Restart animations from key 0
  88348. * @returns the animation group
  88349. */
  88350. restart(): AnimationGroup;
  88351. /**
  88352. * Stop all animations
  88353. * @returns the animation group
  88354. */
  88355. stop(): AnimationGroup;
  88356. /**
  88357. * Set animation weight for all animatables
  88358. * @param weight defines the weight to use
  88359. * @return the animationGroup
  88360. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88361. */
  88362. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88363. /**
  88364. * Synchronize and normalize all animatables with a source animatable
  88365. * @param root defines the root animatable to synchronize with
  88366. * @return the animationGroup
  88367. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88368. */
  88369. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88370. /**
  88371. * Goes to a specific frame in this animation group
  88372. * @param frame the frame number to go to
  88373. * @return the animationGroup
  88374. */
  88375. goToFrame(frame: number): AnimationGroup;
  88376. /**
  88377. * Dispose all associated resources
  88378. */
  88379. dispose(): void;
  88380. private _checkAnimationGroupEnded;
  88381. /**
  88382. * Clone the current animation group and returns a copy
  88383. * @param newName defines the name of the new group
  88384. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88385. * @returns the new aniamtion group
  88386. */
  88387. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88388. /**
  88389. * Returns a new AnimationGroup object parsed from the source provided.
  88390. * @param parsedAnimationGroup defines the source
  88391. * @param scene defines the scene that will receive the animationGroup
  88392. * @returns a new AnimationGroup
  88393. */
  88394. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88395. /**
  88396. * Returns the string "AnimationGroup"
  88397. * @returns "AnimationGroup"
  88398. */
  88399. getClassName(): string;
  88400. /**
  88401. * Creates a detailled string about the object
  88402. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88403. * @returns a string representing the object
  88404. */
  88405. toString(fullDetails?: boolean): string;
  88406. }
  88407. }
  88408. declare module BABYLON {
  88409. /**
  88410. * Define an interface for all classes that will hold resources
  88411. */
  88412. export interface IDisposable {
  88413. /**
  88414. * Releases all held resources
  88415. */
  88416. dispose(): void;
  88417. }
  88418. /** Interface defining initialization parameters for Scene class */
  88419. export interface SceneOptions {
  88420. /**
  88421. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88422. * It will improve performance when the number of geometries becomes important.
  88423. */
  88424. useGeometryUniqueIdsMap?: boolean;
  88425. /**
  88426. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  88430. /**
  88431. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88432. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88433. */
  88434. useClonedMeshhMap?: boolean;
  88435. }
  88436. /**
  88437. * Represents a scene to be rendered by the engine.
  88438. * @see http://doc.babylonjs.com/features/scene
  88439. */
  88440. export class Scene extends AbstractScene implements IAnimatable {
  88441. private static _uniqueIdCounter;
  88442. /** The fog is deactivated */
  88443. static readonly FOGMODE_NONE: number;
  88444. /** The fog density is following an exponential function */
  88445. static readonly FOGMODE_EXP: number;
  88446. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88447. static readonly FOGMODE_EXP2: number;
  88448. /** The fog density is following a linear function. */
  88449. static readonly FOGMODE_LINEAR: number;
  88450. /**
  88451. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88452. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88453. */
  88454. static MinDeltaTime: number;
  88455. /**
  88456. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88458. */
  88459. static MaxDeltaTime: number;
  88460. /**
  88461. * Factory used to create the default material.
  88462. * @param name The name of the material to create
  88463. * @param scene The scene to create the material for
  88464. * @returns The default material
  88465. */
  88466. static DefaultMaterialFactory(scene: Scene): Material;
  88467. /**
  88468. * Factory used to create the a collision coordinator.
  88469. * @returns The collision coordinator
  88470. */
  88471. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88472. /** @hidden */
  88473. readonly _isScene: boolean;
  88474. /**
  88475. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88476. */
  88477. autoClear: boolean;
  88478. /**
  88479. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88480. */
  88481. autoClearDepthAndStencil: boolean;
  88482. /**
  88483. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88484. */
  88485. clearColor: Color4;
  88486. /**
  88487. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88488. */
  88489. ambientColor: Color3;
  88490. /** @hidden */
  88491. _environmentBRDFTexture: BaseTexture;
  88492. /** @hidden */
  88493. protected _environmentTexture: Nullable<BaseTexture>;
  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 reference from here than from all the materials.
  88498. */
  88499. /**
  88500. * Texture used in all pbr material as the reflection texture.
  88501. * As in the majority of the scene they are the same (exception for multi room and so on),
  88502. * this is easier to set here than in all the materials.
  88503. */
  88504. environmentTexture: Nullable<BaseTexture>;
  88505. /** @hidden */
  88506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88507. /**
  88508. * Default image processing configuration used either in the rendering
  88509. * Forward main pass or through the imageProcessingPostProcess if present.
  88510. * As in the majority of the scene they are the same (exception for multi camera),
  88511. * this is easier to reference from here than from all the materials and post process.
  88512. *
  88513. * No setter as we it is a shared configuration, you can set the values instead.
  88514. */
  88515. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88516. private _forceWireframe;
  88517. /**
  88518. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88519. */
  88520. forceWireframe: boolean;
  88521. private _forcePointsCloud;
  88522. /**
  88523. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88524. */
  88525. forcePointsCloud: boolean;
  88526. /**
  88527. * Gets or sets the active clipplane 1
  88528. */
  88529. clipPlane: Nullable<Plane>;
  88530. /**
  88531. * Gets or sets the active clipplane 2
  88532. */
  88533. clipPlane2: Nullable<Plane>;
  88534. /**
  88535. * Gets or sets the active clipplane 3
  88536. */
  88537. clipPlane3: Nullable<Plane>;
  88538. /**
  88539. * Gets or sets the active clipplane 4
  88540. */
  88541. clipPlane4: Nullable<Plane>;
  88542. /**
  88543. * Gets or sets a boolean indicating if animations are enabled
  88544. */
  88545. animationsEnabled: boolean;
  88546. private _animationPropertiesOverride;
  88547. /**
  88548. * Gets or sets the animation properties override
  88549. */
  88550. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88551. /**
  88552. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88553. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88554. */
  88555. useConstantAnimationDeltaTime: boolean;
  88556. /**
  88557. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88558. * Please note that it requires to run a ray cast through the scene on every frame
  88559. */
  88560. constantlyUpdateMeshUnderPointer: boolean;
  88561. /**
  88562. * Defines the HTML cursor to use when hovering over interactive elements
  88563. */
  88564. hoverCursor: string;
  88565. /**
  88566. * Defines the HTML default cursor to use (empty by default)
  88567. */
  88568. defaultCursor: string;
  88569. /**
  88570. * This is used to call preventDefault() on pointer down
  88571. * in order to block unwanted artifacts like system double clicks
  88572. */
  88573. preventDefaultOnPointerDown: boolean;
  88574. /**
  88575. * This is used to call preventDefault() on pointer up
  88576. * in order to block unwanted artifacts like system double clicks
  88577. */
  88578. preventDefaultOnPointerUp: boolean;
  88579. /**
  88580. * Gets or sets user defined metadata
  88581. */
  88582. metadata: any;
  88583. /**
  88584. * For internal use only. Please do not use.
  88585. */
  88586. reservedDataStore: any;
  88587. /**
  88588. * Gets the name of the plugin used to load this scene (null by default)
  88589. */
  88590. loadingPluginName: string;
  88591. /**
  88592. * Use this array to add regular expressions used to disable offline support for specific urls
  88593. */
  88594. disableOfflineSupportExceptionRules: RegExp[];
  88595. /**
  88596. * An event triggered when the scene is disposed.
  88597. */
  88598. onDisposeObservable: Observable<Scene>;
  88599. private _onDisposeObserver;
  88600. /** Sets a function to be executed when this scene is disposed. */
  88601. onDispose: () => void;
  88602. /**
  88603. * An event triggered before rendering the scene (right after animations and physics)
  88604. */
  88605. onBeforeRenderObservable: Observable<Scene>;
  88606. private _onBeforeRenderObserver;
  88607. /** Sets a function to be executed before rendering this scene */
  88608. beforeRender: Nullable<() => void>;
  88609. /**
  88610. * An event triggered after rendering the scene
  88611. */
  88612. onAfterRenderObservable: Observable<Scene>;
  88613. private _onAfterRenderObserver;
  88614. /** Sets a function to be executed after rendering this scene */
  88615. afterRender: Nullable<() => void>;
  88616. /**
  88617. * An event triggered before animating the scene
  88618. */
  88619. onBeforeAnimationsObservable: Observable<Scene>;
  88620. /**
  88621. * An event triggered after animations processing
  88622. */
  88623. onAfterAnimationsObservable: Observable<Scene>;
  88624. /**
  88625. * An event triggered before draw calls are ready to be sent
  88626. */
  88627. onBeforeDrawPhaseObservable: Observable<Scene>;
  88628. /**
  88629. * An event triggered after draw calls have been sent
  88630. */
  88631. onAfterDrawPhaseObservable: Observable<Scene>;
  88632. /**
  88633. * An event triggered when the scene is ready
  88634. */
  88635. onReadyObservable: Observable<Scene>;
  88636. /**
  88637. * An event triggered before rendering a camera
  88638. */
  88639. onBeforeCameraRenderObservable: Observable<Camera>;
  88640. private _onBeforeCameraRenderObserver;
  88641. /** Sets a function to be executed before rendering a camera*/
  88642. beforeCameraRender: () => void;
  88643. /**
  88644. * An event triggered after rendering a camera
  88645. */
  88646. onAfterCameraRenderObservable: Observable<Camera>;
  88647. private _onAfterCameraRenderObserver;
  88648. /** Sets a function to be executed after rendering a camera*/
  88649. afterCameraRender: () => void;
  88650. /**
  88651. * An event triggered when active meshes evaluation is about to start
  88652. */
  88653. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88654. /**
  88655. * An event triggered when active meshes evaluation is done
  88656. */
  88657. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88658. /**
  88659. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88663. /**
  88664. * An event triggered when particles rendering is done
  88665. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88666. */
  88667. onAfterParticlesRenderingObservable: Observable<Scene>;
  88668. /**
  88669. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88670. */
  88671. onDataLoadedObservable: Observable<Scene>;
  88672. /**
  88673. * An event triggered when a camera is created
  88674. */
  88675. onNewCameraAddedObservable: Observable<Camera>;
  88676. /**
  88677. * An event triggered when a camera is removed
  88678. */
  88679. onCameraRemovedObservable: Observable<Camera>;
  88680. /**
  88681. * An event triggered when a light is created
  88682. */
  88683. onNewLightAddedObservable: Observable<Light>;
  88684. /**
  88685. * An event triggered when a light is removed
  88686. */
  88687. onLightRemovedObservable: Observable<Light>;
  88688. /**
  88689. * An event triggered when a geometry is created
  88690. */
  88691. onNewGeometryAddedObservable: Observable<Geometry>;
  88692. /**
  88693. * An event triggered when a geometry is removed
  88694. */
  88695. onGeometryRemovedObservable: Observable<Geometry>;
  88696. /**
  88697. * An event triggered when a transform node is created
  88698. */
  88699. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88700. /**
  88701. * An event triggered when a transform node is removed
  88702. */
  88703. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88704. /**
  88705. * An event triggered when a mesh is created
  88706. */
  88707. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88708. /**
  88709. * An event triggered when a mesh is removed
  88710. */
  88711. onMeshRemovedObservable: Observable<AbstractMesh>;
  88712. /**
  88713. * An event triggered when a material is created
  88714. */
  88715. onNewMaterialAddedObservable: Observable<Material>;
  88716. /**
  88717. * An event triggered when a material is removed
  88718. */
  88719. onMaterialRemovedObservable: Observable<Material>;
  88720. /**
  88721. * An event triggered when a texture is created
  88722. */
  88723. onNewTextureAddedObservable: Observable<BaseTexture>;
  88724. /**
  88725. * An event triggered when a texture is removed
  88726. */
  88727. onTextureRemovedObservable: Observable<BaseTexture>;
  88728. /**
  88729. * An event triggered when render targets are about to be rendered
  88730. * Can happen multiple times per frame.
  88731. */
  88732. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88733. /**
  88734. * An event triggered when render targets were rendered.
  88735. * Can happen multiple times per frame.
  88736. */
  88737. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88738. /**
  88739. * An event triggered before calculating deterministic simulation step
  88740. */
  88741. onBeforeStepObservable: Observable<Scene>;
  88742. /**
  88743. * An event triggered after calculating deterministic simulation step
  88744. */
  88745. onAfterStepObservable: Observable<Scene>;
  88746. /**
  88747. * An event triggered when the activeCamera property is updated
  88748. */
  88749. onActiveCameraChanged: Observable<Scene>;
  88750. /**
  88751. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88752. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88753. * 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)
  88754. */
  88755. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88756. /**
  88757. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88758. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88759. * 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)
  88760. */
  88761. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88762. /**
  88763. * This Observable will when a mesh has been imported into the scene.
  88764. */
  88765. onMeshImportedObservable: Observable<AbstractMesh>;
  88766. /**
  88767. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88768. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88769. */
  88770. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88771. /** @hidden */
  88772. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88773. /**
  88774. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88775. */
  88776. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88777. /**
  88778. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88779. */
  88780. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88781. /**
  88782. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88783. */
  88784. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88785. private _onPointerMove;
  88786. private _onPointerDown;
  88787. private _onPointerUp;
  88788. /** Callback called when a pointer move is detected */
  88789. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88790. /** Callback called when a pointer down is detected */
  88791. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88792. /** Callback called when a pointer up is detected */
  88793. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88794. /** Callback called when a pointer pick is detected */
  88795. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88796. /**
  88797. * 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).
  88798. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88799. */
  88800. onPrePointerObservable: Observable<PointerInfoPre>;
  88801. /**
  88802. * Observable event triggered each time an input event is received from the rendering canvas
  88803. */
  88804. onPointerObservable: Observable<PointerInfo>;
  88805. /**
  88806. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88807. */
  88808. readonly unTranslatedPointer: Vector2;
  88809. /** The distance in pixel that you have to move to prevent some events */
  88810. static DragMovementThreshold: number;
  88811. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88812. static LongPressDelay: number;
  88813. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88814. static DoubleClickDelay: number;
  88815. /** If you need to check double click without raising a single click at first click, enable this flag */
  88816. static ExclusiveDoubleClickMode: boolean;
  88817. private _initClickEvent;
  88818. private _initActionManager;
  88819. private _delayedSimpleClick;
  88820. private _delayedSimpleClickTimeout;
  88821. private _previousDelayedSimpleClickTimeout;
  88822. private _meshPickProceed;
  88823. private _previousButtonPressed;
  88824. private _currentPickResult;
  88825. private _previousPickResult;
  88826. private _totalPointersPressed;
  88827. private _doubleClickOccured;
  88828. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88829. cameraToUseForPointers: Nullable<Camera>;
  88830. private _pointerX;
  88831. private _pointerY;
  88832. private _unTranslatedPointerX;
  88833. private _unTranslatedPointerY;
  88834. private _startingPointerPosition;
  88835. private _previousStartingPointerPosition;
  88836. private _startingPointerTime;
  88837. private _previousStartingPointerTime;
  88838. private _pointerCaptures;
  88839. private _timeAccumulator;
  88840. private _currentStepId;
  88841. private _currentInternalStep;
  88842. /** @hidden */
  88843. _mirroredCameraPosition: Nullable<Vector3>;
  88844. /**
  88845. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88846. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88847. */
  88848. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88849. /**
  88850. * Observable event triggered each time an keyboard event is received from the hosting window
  88851. */
  88852. onKeyboardObservable: Observable<KeyboardInfo>;
  88853. private _onKeyDown;
  88854. private _onKeyUp;
  88855. private _onCanvasFocusObserver;
  88856. private _onCanvasBlurObserver;
  88857. private _useRightHandedSystem;
  88858. /**
  88859. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88860. */
  88861. useRightHandedSystem: boolean;
  88862. /**
  88863. * Sets the step Id used by deterministic lock step
  88864. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88865. * @param newStepId defines the step Id
  88866. */
  88867. setStepId(newStepId: number): void;
  88868. /**
  88869. * Gets the step Id used by deterministic lock step
  88870. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88871. * @returns the step Id
  88872. */
  88873. getStepId(): number;
  88874. /**
  88875. * Gets the internal step used by deterministic lock step
  88876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88877. * @returns the internal step
  88878. */
  88879. getInternalStep(): number;
  88880. private _fogEnabled;
  88881. /**
  88882. * Gets or sets a boolean indicating if fog is enabled on this scene
  88883. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88884. * (Default is true)
  88885. */
  88886. fogEnabled: boolean;
  88887. private _fogMode;
  88888. /**
  88889. * Gets or sets the fog mode to use
  88890. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88891. * | mode | value |
  88892. * | --- | --- |
  88893. * | FOGMODE_NONE | 0 |
  88894. * | FOGMODE_EXP | 1 |
  88895. * | FOGMODE_EXP2 | 2 |
  88896. * | FOGMODE_LINEAR | 3 |
  88897. */
  88898. fogMode: number;
  88899. /**
  88900. * Gets or sets the fog color to use
  88901. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88902. * (Default is Color3(0.2, 0.2, 0.3))
  88903. */
  88904. fogColor: Color3;
  88905. /**
  88906. * Gets or sets the fog density to use
  88907. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88908. * (Default is 0.1)
  88909. */
  88910. fogDensity: number;
  88911. /**
  88912. * Gets or sets the fog start distance to use
  88913. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88914. * (Default is 0)
  88915. */
  88916. fogStart: number;
  88917. /**
  88918. * Gets or sets the fog end distance to use
  88919. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88920. * (Default is 1000)
  88921. */
  88922. fogEnd: number;
  88923. private _shadowsEnabled;
  88924. /**
  88925. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88926. */
  88927. shadowsEnabled: boolean;
  88928. private _lightsEnabled;
  88929. /**
  88930. * Gets or sets a boolean indicating if lights are enabled on this scene
  88931. */
  88932. lightsEnabled: boolean;
  88933. /** All of the active cameras added to this scene. */
  88934. activeCameras: Camera[];
  88935. private _activeCamera;
  88936. /** Gets or sets the current active camera */
  88937. activeCamera: Nullable<Camera>;
  88938. private _defaultMaterial;
  88939. /** The default material used on meshes when no material is affected */
  88940. /** The default material used on meshes when no material is affected */
  88941. defaultMaterial: Material;
  88942. private _texturesEnabled;
  88943. /**
  88944. * Gets or sets a boolean indicating if textures are enabled on this scene
  88945. */
  88946. texturesEnabled: boolean;
  88947. /**
  88948. * Gets or sets a boolean indicating if particles are enabled on this scene
  88949. */
  88950. particlesEnabled: boolean;
  88951. /**
  88952. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88953. */
  88954. spritesEnabled: boolean;
  88955. private _skeletonsEnabled;
  88956. /**
  88957. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88958. */
  88959. skeletonsEnabled: boolean;
  88960. /**
  88961. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88962. */
  88963. lensFlaresEnabled: boolean;
  88964. /**
  88965. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88967. */
  88968. collisionsEnabled: boolean;
  88969. private _collisionCoordinator;
  88970. /** @hidden */
  88971. readonly collisionCoordinator: ICollisionCoordinator;
  88972. /**
  88973. * Defines the gravity applied to this scene (used only for collisions)
  88974. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88975. */
  88976. gravity: Vector3;
  88977. /**
  88978. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88979. */
  88980. postProcessesEnabled: boolean;
  88981. /**
  88982. * The list of postprocesses added to the scene
  88983. */
  88984. postProcesses: PostProcess[];
  88985. /**
  88986. * Gets the current postprocess manager
  88987. */
  88988. postProcessManager: PostProcessManager;
  88989. /**
  88990. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88991. */
  88992. renderTargetsEnabled: boolean;
  88993. /**
  88994. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88995. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88996. */
  88997. dumpNextRenderTargets: boolean;
  88998. /**
  88999. * The list of user defined render targets added to the scene
  89000. */
  89001. customRenderTargets: RenderTargetTexture[];
  89002. /**
  89003. * Defines if texture loading must be delayed
  89004. * If true, textures will only be loaded when they need to be rendered
  89005. */
  89006. useDelayedTextureLoading: boolean;
  89007. /**
  89008. * Gets the list of meshes imported to the scene through SceneLoader
  89009. */
  89010. importedMeshesFiles: String[];
  89011. /**
  89012. * Gets or sets a boolean indicating if probes are enabled on this scene
  89013. */
  89014. probesEnabled: boolean;
  89015. /**
  89016. * Gets or sets the current offline provider to use to store scene data
  89017. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89018. */
  89019. offlineProvider: IOfflineProvider;
  89020. /**
  89021. * Gets or sets the action manager associated with the scene
  89022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89023. */
  89024. actionManager: AbstractActionManager;
  89025. private _meshesForIntersections;
  89026. /**
  89027. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89028. */
  89029. proceduralTexturesEnabled: boolean;
  89030. private _engine;
  89031. private _totalVertices;
  89032. /** @hidden */
  89033. _activeIndices: PerfCounter;
  89034. /** @hidden */
  89035. _activeParticles: PerfCounter;
  89036. /** @hidden */
  89037. _activeBones: PerfCounter;
  89038. private _animationRatio;
  89039. /** @hidden */
  89040. _animationTimeLast: number;
  89041. /** @hidden */
  89042. _animationTime: number;
  89043. /**
  89044. * Gets or sets a general scale for animation speed
  89045. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89046. */
  89047. animationTimeScale: number;
  89048. /** @hidden */
  89049. _cachedMaterial: Nullable<Material>;
  89050. /** @hidden */
  89051. _cachedEffect: Nullable<Effect>;
  89052. /** @hidden */
  89053. _cachedVisibility: Nullable<number>;
  89054. private _renderId;
  89055. private _frameId;
  89056. private _executeWhenReadyTimeoutId;
  89057. private _intermediateRendering;
  89058. private _viewUpdateFlag;
  89059. private _projectionUpdateFlag;
  89060. private _alternateViewUpdateFlag;
  89061. private _alternateProjectionUpdateFlag;
  89062. /** @hidden */
  89063. _toBeDisposed: Nullable<IDisposable>[];
  89064. private _activeRequests;
  89065. /** @hidden */
  89066. _pendingData: any[];
  89067. private _isDisposed;
  89068. /**
  89069. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89070. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89071. */
  89072. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89073. private _activeMeshes;
  89074. private _processedMaterials;
  89075. private _renderTargets;
  89076. /** @hidden */
  89077. _activeParticleSystems: SmartArray<IParticleSystem>;
  89078. private _activeSkeletons;
  89079. private _softwareSkinnedMeshes;
  89080. private _renderingManager;
  89081. /** @hidden */
  89082. _activeAnimatables: Animatable[];
  89083. private _transformMatrix;
  89084. private _sceneUbo;
  89085. private _alternateSceneUbo;
  89086. private _viewMatrix;
  89087. private _projectionMatrix;
  89088. private _alternateViewMatrix;
  89089. private _alternateProjectionMatrix;
  89090. private _alternateTransformMatrix;
  89091. private _useAlternateCameraConfiguration;
  89092. private _alternateRendering;
  89093. private _wheelEventName;
  89094. /** @hidden */
  89095. _forcedViewPosition: Nullable<Vector3>;
  89096. /** @hidden */
  89097. readonly _isAlternateRenderingEnabled: boolean;
  89098. private _frustumPlanes;
  89099. /**
  89100. * Gets the list of frustum planes (built from the active camera)
  89101. */
  89102. readonly frustumPlanes: Plane[];
  89103. /**
  89104. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89105. * This is useful if there are more lights that the maximum simulteanous authorized
  89106. */
  89107. requireLightSorting: boolean;
  89108. /** @hidden */
  89109. readonly useMaterialMeshMap: boolean;
  89110. /** @hidden */
  89111. readonly useClonedMeshhMap: boolean;
  89112. private _pointerOverMesh;
  89113. private _pickedDownMesh;
  89114. private _pickedUpMesh;
  89115. private _externalData;
  89116. private _uid;
  89117. /**
  89118. * @hidden
  89119. * Backing store of defined scene components.
  89120. */
  89121. _components: ISceneComponent[];
  89122. /**
  89123. * @hidden
  89124. * Backing store of defined scene components.
  89125. */
  89126. _serializableComponents: ISceneSerializableComponent[];
  89127. /**
  89128. * List of components to register on the next registration step.
  89129. */
  89130. private _transientComponents;
  89131. /**
  89132. * Registers the transient components if needed.
  89133. */
  89134. private _registerTransientComponents;
  89135. /**
  89136. * @hidden
  89137. * Add a component to the scene.
  89138. * Note that the ccomponent could be registered on th next frame if this is called after
  89139. * the register component stage.
  89140. * @param component Defines the component to add to the scene
  89141. */
  89142. _addComponent(component: ISceneComponent): void;
  89143. /**
  89144. * @hidden
  89145. * Gets a component from the scene.
  89146. * @param name defines the name of the component to retrieve
  89147. * @returns the component or null if not present
  89148. */
  89149. _getComponent(name: string): Nullable<ISceneComponent>;
  89150. /**
  89151. * @hidden
  89152. * Defines the actions happening before camera updates.
  89153. */
  89154. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89155. /**
  89156. * @hidden
  89157. * Defines the actions happening before clear the canvas.
  89158. */
  89159. _beforeClearStage: Stage<SimpleStageAction>;
  89160. /**
  89161. * @hidden
  89162. * Defines the actions when collecting render targets for the frame.
  89163. */
  89164. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89165. /**
  89166. * @hidden
  89167. * Defines the actions happening for one camera in the frame.
  89168. */
  89169. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89170. /**
  89171. * @hidden
  89172. * Defines the actions happening during the per mesh ready checks.
  89173. */
  89174. _isReadyForMeshStage: Stage<MeshStageAction>;
  89175. /**
  89176. * @hidden
  89177. * Defines the actions happening before evaluate active mesh checks.
  89178. */
  89179. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89180. /**
  89181. * @hidden
  89182. * Defines the actions happening during the evaluate sub mesh checks.
  89183. */
  89184. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89185. /**
  89186. * @hidden
  89187. * Defines the actions happening during the active mesh stage.
  89188. */
  89189. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89190. /**
  89191. * @hidden
  89192. * Defines the actions happening during the per camera render target step.
  89193. */
  89194. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89195. /**
  89196. * @hidden
  89197. * Defines the actions happening just before the active camera is drawing.
  89198. */
  89199. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89200. /**
  89201. * @hidden
  89202. * Defines the actions happening just before a render target is drawing.
  89203. */
  89204. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89205. /**
  89206. * @hidden
  89207. * Defines the actions happening just before a rendering group is drawing.
  89208. */
  89209. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89210. /**
  89211. * @hidden
  89212. * Defines the actions happening just before a mesh is drawing.
  89213. */
  89214. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89215. /**
  89216. * @hidden
  89217. * Defines the actions happening just after a mesh has been drawn.
  89218. */
  89219. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89220. /**
  89221. * @hidden
  89222. * Defines the actions happening just after a rendering group has been drawn.
  89223. */
  89224. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89225. /**
  89226. * @hidden
  89227. * Defines the actions happening just after the active camera has been drawn.
  89228. */
  89229. _afterCameraDrawStage: Stage<CameraStageAction>;
  89230. /**
  89231. * @hidden
  89232. * Defines the actions happening just after a render target has been drawn.
  89233. */
  89234. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89235. /**
  89236. * @hidden
  89237. * Defines the actions happening just after rendering all cameras and computing intersections.
  89238. */
  89239. _afterRenderStage: Stage<SimpleStageAction>;
  89240. /**
  89241. * @hidden
  89242. * Defines the actions happening when a pointer move event happens.
  89243. */
  89244. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89245. /**
  89246. * @hidden
  89247. * Defines the actions happening when a pointer down event happens.
  89248. */
  89249. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89250. /**
  89251. * @hidden
  89252. * Defines the actions happening when a pointer up event happens.
  89253. */
  89254. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89255. /**
  89256. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89257. */
  89258. private geometriesByUniqueId;
  89259. /**
  89260. * Creates a new Scene
  89261. * @param engine defines the engine to use to render this scene
  89262. * @param options defines the scene options
  89263. */
  89264. constructor(engine: Engine, options?: SceneOptions);
  89265. private _defaultMeshCandidates;
  89266. /**
  89267. * @hidden
  89268. */
  89269. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89270. private _defaultSubMeshCandidates;
  89271. /**
  89272. * @hidden
  89273. */
  89274. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89275. /**
  89276. * Sets the default candidate providers for the scene.
  89277. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89278. * and getCollidingSubMeshCandidates to their default function
  89279. */
  89280. setDefaultCandidateProviders(): void;
  89281. /**
  89282. * Gets the mesh that is currently under the pointer
  89283. */
  89284. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89285. /**
  89286. * Gets or sets the current on-screen X position of the pointer
  89287. */
  89288. pointerX: number;
  89289. /**
  89290. * Gets or sets the current on-screen Y position of the pointer
  89291. */
  89292. pointerY: number;
  89293. /**
  89294. * Gets the cached material (ie. the latest rendered one)
  89295. * @returns the cached material
  89296. */
  89297. getCachedMaterial(): Nullable<Material>;
  89298. /**
  89299. * Gets the cached effect (ie. the latest rendered one)
  89300. * @returns the cached effect
  89301. */
  89302. getCachedEffect(): Nullable<Effect>;
  89303. /**
  89304. * Gets the cached visibility state (ie. the latest rendered one)
  89305. * @returns the cached visibility state
  89306. */
  89307. getCachedVisibility(): Nullable<number>;
  89308. /**
  89309. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89310. * @param material defines the current material
  89311. * @param effect defines the current effect
  89312. * @param visibility defines the current visibility state
  89313. * @returns true if one parameter is not cached
  89314. */
  89315. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89316. /**
  89317. * Gets the engine associated with the scene
  89318. * @returns an Engine
  89319. */
  89320. getEngine(): Engine;
  89321. /**
  89322. * Gets the total number of vertices rendered per frame
  89323. * @returns the total number of vertices rendered per frame
  89324. */
  89325. getTotalVertices(): number;
  89326. /**
  89327. * Gets the performance counter for total vertices
  89328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89329. */
  89330. readonly totalVerticesPerfCounter: PerfCounter;
  89331. /**
  89332. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89333. * @returns the total number of active indices rendered per frame
  89334. */
  89335. getActiveIndices(): number;
  89336. /**
  89337. * Gets the performance counter for active indices
  89338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89339. */
  89340. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89341. /**
  89342. * Gets the total number of active particles rendered per frame
  89343. * @returns the total number of active particles rendered per frame
  89344. */
  89345. getActiveParticles(): number;
  89346. /**
  89347. * Gets the performance counter for active particles
  89348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89349. */
  89350. readonly activeParticlesPerfCounter: PerfCounter;
  89351. /**
  89352. * Gets the total number of active bones rendered per frame
  89353. * @returns the total number of active bones rendered per frame
  89354. */
  89355. getActiveBones(): number;
  89356. /**
  89357. * Gets the performance counter for active bones
  89358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89359. */
  89360. readonly activeBonesPerfCounter: PerfCounter;
  89361. /**
  89362. * Gets the array of active meshes
  89363. * @returns an array of AbstractMesh
  89364. */
  89365. getActiveMeshes(): SmartArray<AbstractMesh>;
  89366. /**
  89367. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89368. * @returns a number
  89369. */
  89370. getAnimationRatio(): number;
  89371. /**
  89372. * Gets an unique Id for the current render phase
  89373. * @returns a number
  89374. */
  89375. getRenderId(): number;
  89376. /**
  89377. * Gets an unique Id for the current frame
  89378. * @returns a number
  89379. */
  89380. getFrameId(): number;
  89381. /** Call this function if you want to manually increment the render Id*/
  89382. incrementRenderId(): void;
  89383. private _updatePointerPosition;
  89384. private _createUbo;
  89385. private _createAlternateUbo;
  89386. private _setRayOnPointerInfo;
  89387. /**
  89388. * Use this method to simulate a pointer move on a mesh
  89389. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89390. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89391. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89392. * @returns the current scene
  89393. */
  89394. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89395. private _processPointerMove;
  89396. private _checkPrePointerObservable;
  89397. /**
  89398. * Use this method to simulate a pointer down on a mesh
  89399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89402. * @returns the current scene
  89403. */
  89404. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89405. private _processPointerDown;
  89406. /**
  89407. * Use this method to simulate a pointer up on a mesh
  89408. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89409. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89410. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89411. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89412. * @returns the current scene
  89413. */
  89414. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89415. private _processPointerUp;
  89416. /**
  89417. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89418. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89419. * @returns true if the pointer was captured
  89420. */
  89421. isPointerCaptured(pointerId?: number): boolean;
  89422. /** @hidden */
  89423. _isPointerSwiping(): boolean;
  89424. /**
  89425. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89426. * @param attachUp defines if you want to attach events to pointerup
  89427. * @param attachDown defines if you want to attach events to pointerdown
  89428. * @param attachMove defines if you want to attach events to pointermove
  89429. */
  89430. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89431. /** Detaches all event handlers*/
  89432. detachControl(): void;
  89433. /**
  89434. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89435. * Delay loaded resources are not taking in account
  89436. * @return true if all required resources are ready
  89437. */
  89438. isReady(): boolean;
  89439. /** Resets all cached information relative to material (including effect and visibility) */
  89440. resetCachedMaterial(): void;
  89441. /**
  89442. * Registers a function to be called before every frame render
  89443. * @param func defines the function to register
  89444. */
  89445. registerBeforeRender(func: () => void): void;
  89446. /**
  89447. * Unregisters a function called before every frame render
  89448. * @param func defines the function to unregister
  89449. */
  89450. unregisterBeforeRender(func: () => void): void;
  89451. /**
  89452. * Registers a function to be called after every frame render
  89453. * @param func defines the function to register
  89454. */
  89455. registerAfterRender(func: () => void): void;
  89456. /**
  89457. * Unregisters a function called after every frame render
  89458. * @param func defines the function to unregister
  89459. */
  89460. unregisterAfterRender(func: () => void): void;
  89461. private _executeOnceBeforeRender;
  89462. /**
  89463. * The provided function will run before render once and will be disposed afterwards.
  89464. * A timeout delay can be provided so that the function will be executed in N ms.
  89465. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89466. * @param func The function to be executed.
  89467. * @param timeout optional delay in ms
  89468. */
  89469. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89470. /** @hidden */
  89471. _addPendingData(data: any): void;
  89472. /** @hidden */
  89473. _removePendingData(data: any): void;
  89474. /**
  89475. * Returns the number of items waiting to be loaded
  89476. * @returns the number of items waiting to be loaded
  89477. */
  89478. getWaitingItemsCount(): number;
  89479. /**
  89480. * Returns a boolean indicating if the scene is still loading data
  89481. */
  89482. readonly isLoading: boolean;
  89483. /**
  89484. * Registers a function to be executed when the scene is ready
  89485. * @param {Function} func - the function to be executed
  89486. */
  89487. executeWhenReady(func: () => void): void;
  89488. /**
  89489. * Returns a promise that resolves when the scene is ready
  89490. * @returns A promise that resolves when the scene is ready
  89491. */
  89492. whenReadyAsync(): Promise<void>;
  89493. /** @hidden */
  89494. _checkIsReady(): void;
  89495. /**
  89496. * Gets all animatable attached to the scene
  89497. */
  89498. readonly animatables: Animatable[];
  89499. /**
  89500. * Resets the last animation time frame.
  89501. * Useful to override when animations start running when loading a scene for the first time.
  89502. */
  89503. resetLastAnimationTimeFrame(): void;
  89504. /** @hidden */
  89505. _switchToAlternateCameraConfiguration(active: boolean): void;
  89506. /**
  89507. * Gets the current view matrix
  89508. * @returns a Matrix
  89509. */
  89510. getViewMatrix(): Matrix;
  89511. /**
  89512. * Gets the current projection matrix
  89513. * @returns a Matrix
  89514. */
  89515. getProjectionMatrix(): Matrix;
  89516. /**
  89517. * Gets the current transform matrix
  89518. * @returns a Matrix made of View * Projection
  89519. */
  89520. getTransformMatrix(): Matrix;
  89521. /**
  89522. * Sets the current transform matrix
  89523. * @param view defines the View matrix to use
  89524. * @param projection defines the Projection matrix to use
  89525. */
  89526. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89527. /** @hidden */
  89528. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89529. /**
  89530. * Gets the uniform buffer used to store scene data
  89531. * @returns a UniformBuffer
  89532. */
  89533. getSceneUniformBuffer(): UniformBuffer;
  89534. /**
  89535. * Gets an unique (relatively to the current scene) Id
  89536. * @returns an unique number for the scene
  89537. */
  89538. getUniqueId(): number;
  89539. /**
  89540. * Add a mesh to the list of scene's meshes
  89541. * @param newMesh defines the mesh to add
  89542. * @param recursive if all child meshes should also be added to the scene
  89543. */
  89544. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89545. /**
  89546. * Remove a mesh for the list of scene's meshes
  89547. * @param toRemove defines the mesh to remove
  89548. * @param recursive if all child meshes should also be removed from the scene
  89549. * @returns the index where the mesh was in the mesh list
  89550. */
  89551. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89552. /**
  89553. * Add a transform node to the list of scene's transform nodes
  89554. * @param newTransformNode defines the transform node to add
  89555. */
  89556. addTransformNode(newTransformNode: TransformNode): void;
  89557. /**
  89558. * Remove a transform node for the list of scene's transform nodes
  89559. * @param toRemove defines the transform node to remove
  89560. * @returns the index where the transform node was in the transform node list
  89561. */
  89562. removeTransformNode(toRemove: TransformNode): number;
  89563. /**
  89564. * Remove a skeleton for the list of scene's skeletons
  89565. * @param toRemove defines the skeleton to remove
  89566. * @returns the index where the skeleton was in the skeleton list
  89567. */
  89568. removeSkeleton(toRemove: Skeleton): number;
  89569. /**
  89570. * Remove a morph target for the list of scene's morph targets
  89571. * @param toRemove defines the morph target to remove
  89572. * @returns the index where the morph target was in the morph target list
  89573. */
  89574. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89575. /**
  89576. * Remove a light for the list of scene's lights
  89577. * @param toRemove defines the light to remove
  89578. * @returns the index where the light was in the light list
  89579. */
  89580. removeLight(toRemove: Light): number;
  89581. /**
  89582. * Remove a camera for the list of scene's cameras
  89583. * @param toRemove defines the camera to remove
  89584. * @returns the index where the camera was in the camera list
  89585. */
  89586. removeCamera(toRemove: Camera): number;
  89587. /**
  89588. * Remove a particle system for the list of scene's particle systems
  89589. * @param toRemove defines the particle system to remove
  89590. * @returns the index where the particle system was in the particle system list
  89591. */
  89592. removeParticleSystem(toRemove: IParticleSystem): number;
  89593. /**
  89594. * Remove a animation for the list of scene's animations
  89595. * @param toRemove defines the animation to remove
  89596. * @returns the index where the animation was in the animation list
  89597. */
  89598. removeAnimation(toRemove: Animation): number;
  89599. /**
  89600. * Removes the given animation group from this scene.
  89601. * @param toRemove The animation group to remove
  89602. * @returns The index of the removed animation group
  89603. */
  89604. removeAnimationGroup(toRemove: AnimationGroup): number;
  89605. /**
  89606. * Removes the given multi-material from this scene.
  89607. * @param toRemove The multi-material to remove
  89608. * @returns The index of the removed multi-material
  89609. */
  89610. removeMultiMaterial(toRemove: MultiMaterial): number;
  89611. /**
  89612. * Removes the given material from this scene.
  89613. * @param toRemove The material to remove
  89614. * @returns The index of the removed material
  89615. */
  89616. removeMaterial(toRemove: Material): number;
  89617. /**
  89618. * Removes the given action manager from this scene.
  89619. * @param toRemove The action manager to remove
  89620. * @returns The index of the removed action manager
  89621. */
  89622. removeActionManager(toRemove: AbstractActionManager): number;
  89623. /**
  89624. * Removes the given texture from this scene.
  89625. * @param toRemove The texture to remove
  89626. * @returns The index of the removed texture
  89627. */
  89628. removeTexture(toRemove: BaseTexture): number;
  89629. /**
  89630. * Adds the given light to this scene
  89631. * @param newLight The light to add
  89632. */
  89633. addLight(newLight: Light): void;
  89634. /**
  89635. * Sorts the list list based on light priorities
  89636. */
  89637. sortLightsByPriority(): void;
  89638. /**
  89639. * Adds the given camera to this scene
  89640. * @param newCamera The camera to add
  89641. */
  89642. addCamera(newCamera: Camera): void;
  89643. /**
  89644. * Adds the given skeleton to this scene
  89645. * @param newSkeleton The skeleton to add
  89646. */
  89647. addSkeleton(newSkeleton: Skeleton): void;
  89648. /**
  89649. * Adds the given particle system to this scene
  89650. * @param newParticleSystem The particle system to add
  89651. */
  89652. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89653. /**
  89654. * Adds the given animation to this scene
  89655. * @param newAnimation The animation to add
  89656. */
  89657. addAnimation(newAnimation: Animation): void;
  89658. /**
  89659. * Adds the given animation group to this scene.
  89660. * @param newAnimationGroup The animation group to add
  89661. */
  89662. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89663. /**
  89664. * Adds the given multi-material to this scene
  89665. * @param newMultiMaterial The multi-material to add
  89666. */
  89667. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89668. /**
  89669. * Adds the given material to this scene
  89670. * @param newMaterial The material to add
  89671. */
  89672. addMaterial(newMaterial: Material): void;
  89673. /**
  89674. * Adds the given morph target to this scene
  89675. * @param newMorphTargetManager The morph target to add
  89676. */
  89677. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89678. /**
  89679. * Adds the given geometry to this scene
  89680. * @param newGeometry The geometry to add
  89681. */
  89682. addGeometry(newGeometry: Geometry): void;
  89683. /**
  89684. * Adds the given action manager to this scene
  89685. * @param newActionManager The action manager to add
  89686. */
  89687. addActionManager(newActionManager: AbstractActionManager): void;
  89688. /**
  89689. * Adds the given texture to this scene.
  89690. * @param newTexture The texture to add
  89691. */
  89692. addTexture(newTexture: BaseTexture): void;
  89693. /**
  89694. * Switch active camera
  89695. * @param newCamera defines the new active camera
  89696. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89697. */
  89698. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89699. /**
  89700. * sets the active camera of the scene using its ID
  89701. * @param id defines the camera's ID
  89702. * @return the new active camera or null if none found.
  89703. */
  89704. setActiveCameraByID(id: string): Nullable<Camera>;
  89705. /**
  89706. * sets the active camera of the scene using its name
  89707. * @param name defines the camera's name
  89708. * @returns the new active camera or null if none found.
  89709. */
  89710. setActiveCameraByName(name: string): Nullable<Camera>;
  89711. /**
  89712. * get an animation group using its name
  89713. * @param name defines the material's name
  89714. * @return the animation group or null if none found.
  89715. */
  89716. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89717. /**
  89718. * get a material using its id
  89719. * @param id defines the material's ID
  89720. * @return the material or null if none found.
  89721. */
  89722. getMaterialByID(id: string): Nullable<Material>;
  89723. /**
  89724. * Gets a material using its name
  89725. * @param name defines the material's name
  89726. * @return the material or null if none found.
  89727. */
  89728. getMaterialByName(name: string): Nullable<Material>;
  89729. /**
  89730. * Gets a camera using its id
  89731. * @param id defines the id to look for
  89732. * @returns the camera or null if not found
  89733. */
  89734. getCameraByID(id: string): Nullable<Camera>;
  89735. /**
  89736. * Gets a camera using its unique id
  89737. * @param uniqueId defines the unique id to look for
  89738. * @returns the camera or null if not found
  89739. */
  89740. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89741. /**
  89742. * Gets a camera using its name
  89743. * @param name defines the camera's name
  89744. * @return the camera or null if none found.
  89745. */
  89746. getCameraByName(name: string): Nullable<Camera>;
  89747. /**
  89748. * Gets a bone using its id
  89749. * @param id defines the bone's id
  89750. * @return the bone or null if not found
  89751. */
  89752. getBoneByID(id: string): Nullable<Bone>;
  89753. /**
  89754. * Gets a bone using its id
  89755. * @param name defines the bone's name
  89756. * @return the bone or null if not found
  89757. */
  89758. getBoneByName(name: string): Nullable<Bone>;
  89759. /**
  89760. * Gets a light node using its name
  89761. * @param name defines the the light's name
  89762. * @return the light or null if none found.
  89763. */
  89764. getLightByName(name: string): Nullable<Light>;
  89765. /**
  89766. * Gets a light node using its id
  89767. * @param id defines the light's id
  89768. * @return the light or null if none found.
  89769. */
  89770. getLightByID(id: string): Nullable<Light>;
  89771. /**
  89772. * Gets a light node using its scene-generated unique ID
  89773. * @param uniqueId defines the light's unique id
  89774. * @return the light or null if none found.
  89775. */
  89776. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89777. /**
  89778. * Gets a particle system by id
  89779. * @param id defines the particle system id
  89780. * @return the corresponding system or null if none found
  89781. */
  89782. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89783. /**
  89784. * Gets a geometry using its ID
  89785. * @param id defines the geometry's id
  89786. * @return the geometry or null if none found.
  89787. */
  89788. getGeometryByID(id: string): Nullable<Geometry>;
  89789. private _getGeometryByUniqueID;
  89790. /**
  89791. * Add a new geometry to this scene
  89792. * @param geometry defines the geometry to be added to the scene.
  89793. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89794. * @return a boolean defining if the geometry was added or not
  89795. */
  89796. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89797. /**
  89798. * Removes an existing geometry
  89799. * @param geometry defines the geometry to be removed from the scene
  89800. * @return a boolean defining if the geometry was removed or not
  89801. */
  89802. removeGeometry(geometry: Geometry): boolean;
  89803. /**
  89804. * Gets the list of geometries attached to the scene
  89805. * @returns an array of Geometry
  89806. */
  89807. getGeometries(): Geometry[];
  89808. /**
  89809. * Gets the first added mesh found of a given ID
  89810. * @param id defines the id to search for
  89811. * @return the mesh found or null if not found at all
  89812. */
  89813. getMeshByID(id: string): Nullable<AbstractMesh>;
  89814. /**
  89815. * Gets a list of meshes using their id
  89816. * @param id defines the id to search for
  89817. * @returns a list of meshes
  89818. */
  89819. getMeshesByID(id: string): Array<AbstractMesh>;
  89820. /**
  89821. * Gets the first added transform node found of a given ID
  89822. * @param id defines the id to search for
  89823. * @return the found transform node or null if not found at all.
  89824. */
  89825. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89826. /**
  89827. * Gets a list of transform nodes using their id
  89828. * @param id defines the id to search for
  89829. * @returns a list of transform nodes
  89830. */
  89831. getTransformNodesByID(id: string): Array<TransformNode>;
  89832. /**
  89833. * Gets a mesh with its auto-generated unique id
  89834. * @param uniqueId defines the unique id to search for
  89835. * @return the found mesh or null if not found at all.
  89836. */
  89837. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89838. /**
  89839. * Gets a the last added mesh using a given id
  89840. * @param id defines the id to search for
  89841. * @return the found mesh or null if not found at all.
  89842. */
  89843. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89844. /**
  89845. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89846. * @param id defines the id to search for
  89847. * @return the found node or null if not found at all
  89848. */
  89849. getLastEntryByID(id: string): Nullable<Node>;
  89850. /**
  89851. * Gets a node (Mesh, Camera, Light) using a given id
  89852. * @param id defines the id to search for
  89853. * @return the found node or null if not found at all
  89854. */
  89855. getNodeByID(id: string): Nullable<Node>;
  89856. /**
  89857. * Gets a node (Mesh, Camera, Light) using a given name
  89858. * @param name defines the name to search for
  89859. * @return the found node or null if not found at all.
  89860. */
  89861. getNodeByName(name: string): Nullable<Node>;
  89862. /**
  89863. * Gets a mesh using a given name
  89864. * @param name defines the name to search for
  89865. * @return the found mesh or null if not found at all.
  89866. */
  89867. getMeshByName(name: string): Nullable<AbstractMesh>;
  89868. /**
  89869. * Gets a transform node using a given name
  89870. * @param name defines the name to search for
  89871. * @return the found transform node or null if not found at all.
  89872. */
  89873. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89874. /**
  89875. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89876. * @param id defines the id to search for
  89877. * @return the found skeleton or null if not found at all.
  89878. */
  89879. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89880. /**
  89881. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89882. * @param id defines the id to search for
  89883. * @return the found skeleton or null if not found at all.
  89884. */
  89885. getSkeletonById(id: string): Nullable<Skeleton>;
  89886. /**
  89887. * Gets a skeleton using a given name
  89888. * @param name defines the name to search for
  89889. * @return the found skeleton or null if not found at all.
  89890. */
  89891. getSkeletonByName(name: string): Nullable<Skeleton>;
  89892. /**
  89893. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89894. * @param id defines the id to search for
  89895. * @return the found morph target manager or null if not found at all.
  89896. */
  89897. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89898. /**
  89899. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89900. * @param id defines the id to search for
  89901. * @return the found morph target or null if not found at all.
  89902. */
  89903. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89904. /**
  89905. * Gets a boolean indicating if the given mesh is active
  89906. * @param mesh defines the mesh to look for
  89907. * @returns true if the mesh is in the active list
  89908. */
  89909. isActiveMesh(mesh: AbstractMesh): boolean;
  89910. /**
  89911. * Return a unique id as a string which can serve as an identifier for the scene
  89912. */
  89913. readonly uid: string;
  89914. /**
  89915. * Add an externaly attached data from its key.
  89916. * This method call will fail and return false, if such key already exists.
  89917. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89918. * @param key the unique key that identifies the data
  89919. * @param data the data object to associate to the key for this Engine instance
  89920. * @return true if no such key were already present and the data was added successfully, false otherwise
  89921. */
  89922. addExternalData<T>(key: string, data: T): boolean;
  89923. /**
  89924. * Get an externaly attached data from its key
  89925. * @param key the unique key that identifies the data
  89926. * @return the associated data, if present (can be null), or undefined if not present
  89927. */
  89928. getExternalData<T>(key: string): Nullable<T>;
  89929. /**
  89930. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89931. * @param key the unique key that identifies the data
  89932. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89933. * @return the associated data, can be null if the factory returned null.
  89934. */
  89935. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89936. /**
  89937. * Remove an externaly attached data from the Engine instance
  89938. * @param key the unique key that identifies the data
  89939. * @return true if the data was successfully removed, false if it doesn't exist
  89940. */
  89941. removeExternalData(key: string): boolean;
  89942. private _evaluateSubMesh;
  89943. /**
  89944. * Clear the processed materials smart array preventing retention point in material dispose.
  89945. */
  89946. freeProcessedMaterials(): void;
  89947. private _preventFreeActiveMeshesAndRenderingGroups;
  89948. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89949. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89950. * when disposing several meshes in a row or a hierarchy of meshes.
  89951. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89952. */
  89953. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89954. /**
  89955. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89956. */
  89957. freeActiveMeshes(): void;
  89958. /**
  89959. * Clear the info related to rendering groups preventing retention points during dispose.
  89960. */
  89961. freeRenderingGroups(): void;
  89962. /** @hidden */
  89963. _isInIntermediateRendering(): boolean;
  89964. /**
  89965. * Lambda returning the list of potentially active meshes.
  89966. */
  89967. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89968. /**
  89969. * Lambda returning the list of potentially active sub meshes.
  89970. */
  89971. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89972. /**
  89973. * Lambda returning the list of potentially intersecting sub meshes.
  89974. */
  89975. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89976. /**
  89977. * Lambda returning the list of potentially colliding sub meshes.
  89978. */
  89979. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89980. private _activeMeshesFrozen;
  89981. /**
  89982. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89983. * @returns the current scene
  89984. */
  89985. freezeActiveMeshes(): Scene;
  89986. /**
  89987. * Use this function to restart evaluating active meshes on every frame
  89988. * @returns the current scene
  89989. */
  89990. unfreezeActiveMeshes(): Scene;
  89991. private _evaluateActiveMeshes;
  89992. private _activeMesh;
  89993. /**
  89994. * Update the transform matrix to update from the current active camera
  89995. * @param force defines a boolean used to force the update even if cache is up to date
  89996. */
  89997. updateTransformMatrix(force?: boolean): void;
  89998. /**
  89999. * 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)
  90000. * @param alternateCamera defines the camera to use
  90001. */
  90002. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90003. /** @hidden */
  90004. _allowPostProcessClearColor: boolean;
  90005. private _renderForCamera;
  90006. private _processSubCameras;
  90007. private _checkIntersections;
  90008. /** @hidden */
  90009. _advancePhysicsEngineStep(step: number): void;
  90010. /**
  90011. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90012. */
  90013. getDeterministicFrameTime: () => number;
  90014. /** @hidden */
  90015. _animate(): void;
  90016. /**
  90017. * Render the scene
  90018. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90019. */
  90020. render(updateCameras?: boolean): void;
  90021. /**
  90022. * Freeze all materials
  90023. * A frozen material will not be updatable but should be faster to render
  90024. */
  90025. freezeMaterials(): void;
  90026. /**
  90027. * Unfreeze all materials
  90028. * A frozen material will not be updatable but should be faster to render
  90029. */
  90030. unfreezeMaterials(): void;
  90031. /**
  90032. * Releases all held ressources
  90033. */
  90034. dispose(): void;
  90035. /**
  90036. * Gets if the scene is already disposed
  90037. */
  90038. readonly isDisposed: boolean;
  90039. /**
  90040. * Call this function to reduce memory footprint of the scene.
  90041. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90042. */
  90043. clearCachedVertexData(): void;
  90044. /**
  90045. * This function will remove the local cached buffer data from texture.
  90046. * It will save memory but will prevent the texture from being rebuilt
  90047. */
  90048. cleanCachedTextureBuffer(): void;
  90049. /**
  90050. * Get the world extend vectors with an optional filter
  90051. *
  90052. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90053. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90054. */
  90055. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90056. min: Vector3;
  90057. max: Vector3;
  90058. };
  90059. /**
  90060. * Creates a ray that can be used to pick in the scene
  90061. * @param x defines the x coordinate of the origin (on-screen)
  90062. * @param y defines the y coordinate of the origin (on-screen)
  90063. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90064. * @param camera defines the camera to use for the picking
  90065. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90066. * @returns a Ray
  90067. */
  90068. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90069. /**
  90070. * Creates a ray that can be used to pick in the scene
  90071. * @param x defines the x coordinate of the origin (on-screen)
  90072. * @param y defines the y coordinate of the origin (on-screen)
  90073. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90074. * @param result defines the ray where to store the picking ray
  90075. * @param camera defines the camera to use for the picking
  90076. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90077. * @returns the current scene
  90078. */
  90079. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90080. /**
  90081. * Creates a ray that can be used to pick in the scene
  90082. * @param x defines the x coordinate of the origin (on-screen)
  90083. * @param y defines the y coordinate of the origin (on-screen)
  90084. * @param camera defines the camera to use for the picking
  90085. * @returns a Ray
  90086. */
  90087. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90088. /**
  90089. * Creates a ray that can be used to pick in the scene
  90090. * @param x defines the x coordinate of the origin (on-screen)
  90091. * @param y defines the y coordinate of the origin (on-screen)
  90092. * @param result defines the ray where to store the picking ray
  90093. * @param camera defines the camera to use for the picking
  90094. * @returns the current scene
  90095. */
  90096. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90097. /** Launch a ray to try to pick a mesh in the scene
  90098. * @param x position on screen
  90099. * @param y position on screen
  90100. * @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
  90101. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90102. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90103. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90104. * @returns a PickingInfo
  90105. */
  90106. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90107. /** Use the given ray to pick a mesh in the scene
  90108. * @param ray The ray to use to pick meshes
  90109. * @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
  90110. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90111. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90112. * @returns a PickingInfo
  90113. */
  90114. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90115. /**
  90116. * Launch a ray to try to pick a mesh in the scene
  90117. * @param x X position on screen
  90118. * @param y Y position on screen
  90119. * @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
  90120. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90121. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90122. * @returns an array of PickingInfo
  90123. */
  90124. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90125. /**
  90126. * Launch a ray to try to pick a mesh in the scene
  90127. * @param ray Ray to use
  90128. * @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
  90129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90130. * @returns an array of PickingInfo
  90131. */
  90132. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90133. /**
  90134. * Force the value of meshUnderPointer
  90135. * @param mesh defines the mesh to use
  90136. */
  90137. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90138. /**
  90139. * Gets the mesh under the pointer
  90140. * @returns a Mesh or null if no mesh is under the pointer
  90141. */
  90142. getPointerOverMesh(): Nullable<AbstractMesh>;
  90143. /** @hidden */
  90144. _rebuildGeometries(): void;
  90145. /** @hidden */
  90146. _rebuildTextures(): void;
  90147. private _getByTags;
  90148. /**
  90149. * Get a list of meshes by tags
  90150. * @param tagsQuery defines the tags query to use
  90151. * @param forEach defines a predicate used to filter results
  90152. * @returns an array of Mesh
  90153. */
  90154. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90155. /**
  90156. * Get a list of cameras by tags
  90157. * @param tagsQuery defines the tags query to use
  90158. * @param forEach defines a predicate used to filter results
  90159. * @returns an array of Camera
  90160. */
  90161. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90162. /**
  90163. * Get a list of lights by tags
  90164. * @param tagsQuery defines the tags query to use
  90165. * @param forEach defines a predicate used to filter results
  90166. * @returns an array of Light
  90167. */
  90168. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90169. /**
  90170. * Get a list of materials by tags
  90171. * @param tagsQuery defines the tags query to use
  90172. * @param forEach defines a predicate used to filter results
  90173. * @returns an array of Material
  90174. */
  90175. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90176. /**
  90177. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90178. * This allowed control for front to back rendering or reversly depending of the special needs.
  90179. *
  90180. * @param renderingGroupId The rendering group id corresponding to its index
  90181. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90182. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90183. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90184. */
  90185. 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;
  90186. /**
  90187. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90188. *
  90189. * @param renderingGroupId The rendering group id corresponding to its index
  90190. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90191. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90192. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90193. */
  90194. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90195. /**
  90196. * Gets the current auto clear configuration for one rendering group of the rendering
  90197. * manager.
  90198. * @param index the rendering group index to get the information for
  90199. * @returns The auto clear setup for the requested rendering group
  90200. */
  90201. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90202. private _blockMaterialDirtyMechanism;
  90203. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90204. blockMaterialDirtyMechanism: boolean;
  90205. /**
  90206. * Will flag all materials as dirty to trigger new shader compilation
  90207. * @param flag defines the flag used to specify which material part must be marked as dirty
  90208. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90209. */
  90210. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90211. /** @hidden */
  90212. _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;
  90213. /** @hidden */
  90214. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90215. }
  90216. }
  90217. declare module BABYLON {
  90218. /**
  90219. * Set of assets to keep when moving a scene into an asset container.
  90220. */
  90221. export class KeepAssets extends AbstractScene {
  90222. }
  90223. /**
  90224. * Container with a set of assets that can be added or removed from a scene.
  90225. */
  90226. export class AssetContainer extends AbstractScene {
  90227. /**
  90228. * The scene the AssetContainer belongs to.
  90229. */
  90230. scene: Scene;
  90231. /**
  90232. * Instantiates an AssetContainer.
  90233. * @param scene The scene the AssetContainer belongs to.
  90234. */
  90235. constructor(scene: Scene);
  90236. /**
  90237. * Adds all the assets from the container to the scene.
  90238. */
  90239. addAllToScene(): void;
  90240. /**
  90241. * Removes all the assets in the container from the scene
  90242. */
  90243. removeAllFromScene(): void;
  90244. /**
  90245. * Disposes all the assets in the container
  90246. */
  90247. dispose(): void;
  90248. private _moveAssets;
  90249. /**
  90250. * Removes all the assets contained in the scene and adds them to the container.
  90251. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90252. */
  90253. moveAllFromScene(keepAssets?: KeepAssets): void;
  90254. /**
  90255. * 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.
  90256. * @returns the root mesh
  90257. */
  90258. createRootMesh(): Mesh;
  90259. }
  90260. }
  90261. declare module BABYLON {
  90262. /**
  90263. * Defines how the parser contract is defined.
  90264. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90265. */
  90266. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90267. /**
  90268. * Defines how the individual parser contract is defined.
  90269. * These parser can parse an individual asset
  90270. */
  90271. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90272. /**
  90273. * Base class of the scene acting as a container for the different elements composing a scene.
  90274. * This class is dynamically extended by the different components of the scene increasing
  90275. * flexibility and reducing coupling
  90276. */
  90277. export abstract class AbstractScene {
  90278. /**
  90279. * Stores the list of available parsers in the application.
  90280. */
  90281. private static _BabylonFileParsers;
  90282. /**
  90283. * Stores the list of available individual parsers in the application.
  90284. */
  90285. private static _IndividualBabylonFileParsers;
  90286. /**
  90287. * Adds a parser in the list of available ones
  90288. * @param name Defines the name of the parser
  90289. * @param parser Defines the parser to add
  90290. */
  90291. static AddParser(name: string, parser: BabylonFileParser): void;
  90292. /**
  90293. * Gets a general parser from the list of avaialble ones
  90294. * @param name Defines the name of the parser
  90295. * @returns the requested parser or null
  90296. */
  90297. static GetParser(name: string): Nullable<BabylonFileParser>;
  90298. /**
  90299. * Adds n individual parser in the list of available ones
  90300. * @param name Defines the name of the parser
  90301. * @param parser Defines the parser to add
  90302. */
  90303. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90304. /**
  90305. * Gets an individual parser from the list of avaialble ones
  90306. * @param name Defines the name of the parser
  90307. * @returns the requested parser or null
  90308. */
  90309. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90310. /**
  90311. * Parser json data and populate both a scene and its associated container object
  90312. * @param jsonData Defines the data to parse
  90313. * @param scene Defines the scene to parse the data for
  90314. * @param container Defines the container attached to the parsing sequence
  90315. * @param rootUrl Defines the root url of the data
  90316. */
  90317. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90318. /**
  90319. * Gets the list of root nodes (ie. nodes with no parent)
  90320. */
  90321. rootNodes: Node[];
  90322. /** All of the cameras added to this scene
  90323. * @see http://doc.babylonjs.com/babylon101/cameras
  90324. */
  90325. cameras: Camera[];
  90326. /**
  90327. * All of the lights added to this scene
  90328. * @see http://doc.babylonjs.com/babylon101/lights
  90329. */
  90330. lights: Light[];
  90331. /**
  90332. * All of the (abstract) meshes added to this scene
  90333. */
  90334. meshes: AbstractMesh[];
  90335. /**
  90336. * The list of skeletons added to the scene
  90337. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90338. */
  90339. skeletons: Skeleton[];
  90340. /**
  90341. * All of the particle systems added to this scene
  90342. * @see http://doc.babylonjs.com/babylon101/particles
  90343. */
  90344. particleSystems: IParticleSystem[];
  90345. /**
  90346. * Gets a list of Animations associated with the scene
  90347. */
  90348. animations: Animation[];
  90349. /**
  90350. * All of the animation groups added to this scene
  90351. * @see http://doc.babylonjs.com/how_to/group
  90352. */
  90353. animationGroups: AnimationGroup[];
  90354. /**
  90355. * All of the multi-materials added to this scene
  90356. * @see http://doc.babylonjs.com/how_to/multi_materials
  90357. */
  90358. multiMaterials: MultiMaterial[];
  90359. /**
  90360. * All of the materials added to this scene
  90361. * In the context of a Scene, it is not supposed to be modified manually.
  90362. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90363. * Note also that the order of the Material wihin the array is not significant and might change.
  90364. * @see http://doc.babylonjs.com/babylon101/materials
  90365. */
  90366. materials: Material[];
  90367. /**
  90368. * The list of morph target managers added to the scene
  90369. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90370. */
  90371. morphTargetManagers: MorphTargetManager[];
  90372. /**
  90373. * The list of geometries used in the scene.
  90374. */
  90375. geometries: Geometry[];
  90376. /**
  90377. * All of the tranform nodes added to this scene
  90378. * In the context of a Scene, it is not supposed to be modified manually.
  90379. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90380. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90381. * @see http://doc.babylonjs.com/how_to/transformnode
  90382. */
  90383. transformNodes: TransformNode[];
  90384. /**
  90385. * ActionManagers available on the scene.
  90386. */
  90387. actionManagers: AbstractActionManager[];
  90388. /**
  90389. * Textures to keep.
  90390. */
  90391. textures: BaseTexture[];
  90392. }
  90393. }
  90394. declare module BABYLON {
  90395. /**
  90396. * Defines a sound that can be played in the application.
  90397. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90399. */
  90400. export class Sound {
  90401. /**
  90402. * The name of the sound in the scene.
  90403. */
  90404. name: string;
  90405. /**
  90406. * Does the sound autoplay once loaded.
  90407. */
  90408. autoplay: boolean;
  90409. /**
  90410. * Does the sound loop after it finishes playing once.
  90411. */
  90412. loop: boolean;
  90413. /**
  90414. * Does the sound use a custom attenuation curve to simulate the falloff
  90415. * happening when the source gets further away from the camera.
  90416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90417. */
  90418. useCustomAttenuation: boolean;
  90419. /**
  90420. * The sound track id this sound belongs to.
  90421. */
  90422. soundTrackId: number;
  90423. /**
  90424. * Is this sound currently played.
  90425. */
  90426. isPlaying: boolean;
  90427. /**
  90428. * Is this sound currently paused.
  90429. */
  90430. isPaused: boolean;
  90431. /**
  90432. * Does this sound enables spatial sound.
  90433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90434. */
  90435. spatialSound: boolean;
  90436. /**
  90437. * Define the reference distance the sound should be heard perfectly.
  90438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90439. */
  90440. refDistance: number;
  90441. /**
  90442. * Define the roll off factor of spatial sounds.
  90443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90444. */
  90445. rolloffFactor: number;
  90446. /**
  90447. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90449. */
  90450. maxDistance: number;
  90451. /**
  90452. * Define the distance attenuation model the sound will follow.
  90453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90454. */
  90455. distanceModel: string;
  90456. /**
  90457. * @hidden
  90458. * Back Compat
  90459. **/
  90460. onended: () => any;
  90461. /**
  90462. * Observable event when the current playing sound finishes.
  90463. */
  90464. onEndedObservable: Observable<Sound>;
  90465. private _panningModel;
  90466. private _playbackRate;
  90467. private _streaming;
  90468. private _startTime;
  90469. private _startOffset;
  90470. private _position;
  90471. /** @hidden */
  90472. _positionInEmitterSpace: boolean;
  90473. private _localDirection;
  90474. private _volume;
  90475. private _isReadyToPlay;
  90476. private _isDirectional;
  90477. private _readyToPlayCallback;
  90478. private _audioBuffer;
  90479. private _soundSource;
  90480. private _streamingSource;
  90481. private _soundPanner;
  90482. private _soundGain;
  90483. private _inputAudioNode;
  90484. private _outputAudioNode;
  90485. private _coneInnerAngle;
  90486. private _coneOuterAngle;
  90487. private _coneOuterGain;
  90488. private _scene;
  90489. private _connectedTransformNode;
  90490. private _customAttenuationFunction;
  90491. private _registerFunc;
  90492. private _isOutputConnected;
  90493. private _htmlAudioElement;
  90494. private _urlType;
  90495. /** @hidden */
  90496. static _SceneComponentInitialization: (scene: Scene) => void;
  90497. /**
  90498. * Create a sound and attach it to a scene
  90499. * @param name Name of your sound
  90500. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90501. * @param scene defines the scene the sound belongs to
  90502. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90503. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90504. */
  90505. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90506. /**
  90507. * Release the sound and its associated resources
  90508. */
  90509. dispose(): void;
  90510. /**
  90511. * Gets if the sounds is ready to be played or not.
  90512. * @returns true if ready, otherwise false
  90513. */
  90514. isReady(): boolean;
  90515. private _soundLoaded;
  90516. /**
  90517. * Sets the data of the sound from an audiobuffer
  90518. * @param audioBuffer The audioBuffer containing the data
  90519. */
  90520. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90521. /**
  90522. * Updates the current sounds options such as maxdistance, loop...
  90523. * @param options A JSON object containing values named as the object properties
  90524. */
  90525. updateOptions(options: any): void;
  90526. private _createSpatialParameters;
  90527. private _updateSpatialParameters;
  90528. /**
  90529. * Switch the panning model to HRTF:
  90530. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90532. */
  90533. switchPanningModelToHRTF(): void;
  90534. /**
  90535. * Switch the panning model to Equal Power:
  90536. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90538. */
  90539. switchPanningModelToEqualPower(): void;
  90540. private _switchPanningModel;
  90541. /**
  90542. * Connect this sound to a sound track audio node like gain...
  90543. * @param soundTrackAudioNode the sound track audio node to connect to
  90544. */
  90545. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90546. /**
  90547. * Transform this sound into a directional source
  90548. * @param coneInnerAngle Size of the inner cone in degree
  90549. * @param coneOuterAngle Size of the outer cone in degree
  90550. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90551. */
  90552. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90553. /**
  90554. * Gets or sets the inner angle for the directional cone.
  90555. */
  90556. /**
  90557. * Gets or sets the inner angle for the directional cone.
  90558. */
  90559. directionalConeInnerAngle: number;
  90560. /**
  90561. * Gets or sets the outer angle for the directional cone.
  90562. */
  90563. /**
  90564. * Gets or sets the outer angle for the directional cone.
  90565. */
  90566. directionalConeOuterAngle: number;
  90567. /**
  90568. * Sets the position of the emitter if spatial sound is enabled
  90569. * @param newPosition Defines the new posisiton
  90570. */
  90571. setPosition(newPosition: Vector3): void;
  90572. /**
  90573. * Sets the local direction of the emitter if spatial sound is enabled
  90574. * @param newLocalDirection Defines the new local direction
  90575. */
  90576. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90577. private _updateDirection;
  90578. /** @hidden */
  90579. updateDistanceFromListener(): void;
  90580. /**
  90581. * Sets a new custom attenuation function for the sound.
  90582. * @param callback Defines the function used for the attenuation
  90583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90584. */
  90585. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90586. /**
  90587. * Play the sound
  90588. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90589. * @param offset (optional) Start the sound setting it at a specific time
  90590. */
  90591. play(time?: number, offset?: number): void;
  90592. private _onended;
  90593. /**
  90594. * Stop the sound
  90595. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90596. */
  90597. stop(time?: number): void;
  90598. /**
  90599. * Put the sound in pause
  90600. */
  90601. pause(): void;
  90602. /**
  90603. * Sets a dedicated volume for this sounds
  90604. * @param newVolume Define the new volume of the sound
  90605. * @param time Define in how long the sound should be at this value
  90606. */
  90607. setVolume(newVolume: number, time?: number): void;
  90608. /**
  90609. * Set the sound play back rate
  90610. * @param newPlaybackRate Define the playback rate the sound should be played at
  90611. */
  90612. setPlaybackRate(newPlaybackRate: number): void;
  90613. /**
  90614. * Gets the volume of the sound.
  90615. * @returns the volume of the sound
  90616. */
  90617. getVolume(): number;
  90618. /**
  90619. * Attach the sound to a dedicated mesh
  90620. * @param transformNode The transform node to connect the sound with
  90621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90622. */
  90623. attachToMesh(transformNode: TransformNode): void;
  90624. /**
  90625. * Detach the sound from the previously attached mesh
  90626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90627. */
  90628. detachFromMesh(): void;
  90629. private _onRegisterAfterWorldMatrixUpdate;
  90630. /**
  90631. * Clone the current sound in the scene.
  90632. * @returns the new sound clone
  90633. */
  90634. clone(): Nullable<Sound>;
  90635. /**
  90636. * Gets the current underlying audio buffer containing the data
  90637. * @returns the audio buffer
  90638. */
  90639. getAudioBuffer(): Nullable<AudioBuffer>;
  90640. /**
  90641. * Serializes the Sound in a JSON representation
  90642. * @returns the JSON representation of the sound
  90643. */
  90644. serialize(): any;
  90645. /**
  90646. * Parse a JSON representation of a sound to innstantiate in a given scene
  90647. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90648. * @param scene Define the scene the new parsed sound should be created in
  90649. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90650. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90651. * @returns the newly parsed sound
  90652. */
  90653. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90654. }
  90655. }
  90656. declare module BABYLON {
  90657. /**
  90658. * This defines an action helpful to play a defined sound on a triggered action.
  90659. */
  90660. export class PlaySoundAction extends Action {
  90661. private _sound;
  90662. /**
  90663. * Instantiate the action
  90664. * @param triggerOptions defines the trigger options
  90665. * @param sound defines the sound to play
  90666. * @param condition defines the trigger related conditions
  90667. */
  90668. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90669. /** @hidden */
  90670. _prepare(): void;
  90671. /**
  90672. * Execute the action and play the sound.
  90673. */
  90674. execute(): void;
  90675. /**
  90676. * Serializes the actions and its related information.
  90677. * @param parent defines the object to serialize in
  90678. * @returns the serialized object
  90679. */
  90680. serialize(parent: any): any;
  90681. }
  90682. /**
  90683. * This defines an action helpful to stop a defined sound on a triggered action.
  90684. */
  90685. export class StopSoundAction extends Action {
  90686. private _sound;
  90687. /**
  90688. * Instantiate the action
  90689. * @param triggerOptions defines the trigger options
  90690. * @param sound defines the sound to stop
  90691. * @param condition defines the trigger related conditions
  90692. */
  90693. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90694. /** @hidden */
  90695. _prepare(): void;
  90696. /**
  90697. * Execute the action and stop the sound.
  90698. */
  90699. execute(): void;
  90700. /**
  90701. * Serializes the actions and its related information.
  90702. * @param parent defines the object to serialize in
  90703. * @returns the serialized object
  90704. */
  90705. serialize(parent: any): any;
  90706. }
  90707. }
  90708. declare module BABYLON {
  90709. /**
  90710. * This defines an action responsible to change the value of a property
  90711. * by interpolating between its current value and the newly set one once triggered.
  90712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90713. */
  90714. export class InterpolateValueAction extends Action {
  90715. /**
  90716. * Defines the path of the property where the value should be interpolated
  90717. */
  90718. propertyPath: string;
  90719. /**
  90720. * Defines the target value at the end of the interpolation.
  90721. */
  90722. value: any;
  90723. /**
  90724. * Defines the time it will take for the property to interpolate to the value.
  90725. */
  90726. duration: number;
  90727. /**
  90728. * Defines if the other scene animations should be stopped when the action has been triggered
  90729. */
  90730. stopOtherAnimations?: boolean;
  90731. /**
  90732. * Defines a callback raised once the interpolation animation has been done.
  90733. */
  90734. onInterpolationDone?: () => void;
  90735. /**
  90736. * Observable triggered once the interpolation animation has been done.
  90737. */
  90738. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90739. private _target;
  90740. private _effectiveTarget;
  90741. private _property;
  90742. /**
  90743. * Instantiate the action
  90744. * @param triggerOptions defines the trigger options
  90745. * @param target defines the object containing the value to interpolate
  90746. * @param propertyPath defines the path to the property in the target object
  90747. * @param value defines the target value at the end of the interpolation
  90748. * @param duration deines the time it will take for the property to interpolate to the value.
  90749. * @param condition defines the trigger related conditions
  90750. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90751. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90752. */
  90753. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90754. /** @hidden */
  90755. _prepare(): void;
  90756. /**
  90757. * Execute the action starts the value interpolation.
  90758. */
  90759. execute(): void;
  90760. /**
  90761. * Serializes the actions and its related information.
  90762. * @param parent defines the object to serialize in
  90763. * @returns the serialized object
  90764. */
  90765. serialize(parent: any): any;
  90766. }
  90767. }
  90768. declare module BABYLON {
  90769. /**
  90770. * Options allowed during the creation of a sound track.
  90771. */
  90772. export interface ISoundTrackOptions {
  90773. /**
  90774. * The volume the sound track should take during creation
  90775. */
  90776. volume?: number;
  90777. /**
  90778. * Define if the sound track is the main sound track of the scene
  90779. */
  90780. mainTrack?: boolean;
  90781. }
  90782. /**
  90783. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90784. * It will be also used in a future release to apply effects on a specific track.
  90785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90786. */
  90787. export class SoundTrack {
  90788. /**
  90789. * The unique identifier of the sound track in the scene.
  90790. */
  90791. id: number;
  90792. /**
  90793. * The list of sounds included in the sound track.
  90794. */
  90795. soundCollection: Array<Sound>;
  90796. private _outputAudioNode;
  90797. private _scene;
  90798. private _isMainTrack;
  90799. private _connectedAnalyser;
  90800. private _options;
  90801. private _isInitialized;
  90802. /**
  90803. * Creates a new sound track.
  90804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90805. * @param scene Define the scene the sound track belongs to
  90806. * @param options
  90807. */
  90808. constructor(scene: Scene, options?: ISoundTrackOptions);
  90809. private _initializeSoundTrackAudioGraph;
  90810. /**
  90811. * Release the sound track and its associated resources
  90812. */
  90813. dispose(): void;
  90814. /**
  90815. * Adds a sound to this sound track
  90816. * @param sound define the cound to add
  90817. * @ignoreNaming
  90818. */
  90819. AddSound(sound: Sound): void;
  90820. /**
  90821. * Removes a sound to this sound track
  90822. * @param sound define the cound to remove
  90823. * @ignoreNaming
  90824. */
  90825. RemoveSound(sound: Sound): void;
  90826. /**
  90827. * Set a global volume for the full sound track.
  90828. * @param newVolume Define the new volume of the sound track
  90829. */
  90830. setVolume(newVolume: number): void;
  90831. /**
  90832. * Switch the panning model to HRTF:
  90833. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90835. */
  90836. switchPanningModelToHRTF(): void;
  90837. /**
  90838. * Switch the panning model to Equal Power:
  90839. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90841. */
  90842. switchPanningModelToEqualPower(): void;
  90843. /**
  90844. * Connect the sound track to an audio analyser allowing some amazing
  90845. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90847. * @param analyser The analyser to connect to the engine
  90848. */
  90849. connectToAnalyser(analyser: Analyser): void;
  90850. }
  90851. }
  90852. declare module BABYLON {
  90853. interface AbstractScene {
  90854. /**
  90855. * The list of sounds used in the scene.
  90856. */
  90857. sounds: Nullable<Array<Sound>>;
  90858. }
  90859. interface Scene {
  90860. /**
  90861. * @hidden
  90862. * Backing field
  90863. */
  90864. _mainSoundTrack: SoundTrack;
  90865. /**
  90866. * The main sound track played by the scene.
  90867. * It cotains your primary collection of sounds.
  90868. */
  90869. mainSoundTrack: SoundTrack;
  90870. /**
  90871. * The list of sound tracks added to the scene
  90872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90873. */
  90874. soundTracks: Nullable<Array<SoundTrack>>;
  90875. /**
  90876. * Gets a sound using a given name
  90877. * @param name defines the name to search for
  90878. * @return the found sound or null if not found at all.
  90879. */
  90880. getSoundByName(name: string): Nullable<Sound>;
  90881. /**
  90882. * Gets or sets if audio support is enabled
  90883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90884. */
  90885. audioEnabled: boolean;
  90886. /**
  90887. * Gets or sets if audio will be output to headphones
  90888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90889. */
  90890. headphone: boolean;
  90891. }
  90892. /**
  90893. * Defines the sound scene component responsible to manage any sounds
  90894. * in a given scene.
  90895. */
  90896. export class AudioSceneComponent implements ISceneSerializableComponent {
  90897. /**
  90898. * The component name helpfull to identify the component in the list of scene components.
  90899. */
  90900. readonly name: string;
  90901. /**
  90902. * The scene the component belongs to.
  90903. */
  90904. scene: Scene;
  90905. private _audioEnabled;
  90906. /**
  90907. * Gets whether audio is enabled or not.
  90908. * Please use related enable/disable method to switch state.
  90909. */
  90910. readonly audioEnabled: boolean;
  90911. private _headphone;
  90912. /**
  90913. * Gets whether audio is outputing to headphone or not.
  90914. * Please use the according Switch methods to change output.
  90915. */
  90916. readonly headphone: boolean;
  90917. /**
  90918. * Creates a new instance of the component for the given scene
  90919. * @param scene Defines the scene to register the component in
  90920. */
  90921. constructor(scene: Scene);
  90922. /**
  90923. * Registers the component in a given scene
  90924. */
  90925. register(): void;
  90926. /**
  90927. * Rebuilds the elements related to this component in case of
  90928. * context lost for instance.
  90929. */
  90930. rebuild(): void;
  90931. /**
  90932. * Serializes the component data to the specified json object
  90933. * @param serializationObject The object to serialize to
  90934. */
  90935. serialize(serializationObject: any): void;
  90936. /**
  90937. * Adds all the element from the container to the scene
  90938. * @param container the container holding the elements
  90939. */
  90940. addFromContainer(container: AbstractScene): void;
  90941. /**
  90942. * Removes all the elements in the container from the scene
  90943. * @param container contains the elements to remove
  90944. */
  90945. removeFromContainer(container: AbstractScene): void;
  90946. /**
  90947. * Disposes the component and the associated ressources.
  90948. */
  90949. dispose(): void;
  90950. /**
  90951. * Disables audio in the associated scene.
  90952. */
  90953. disableAudio(): void;
  90954. /**
  90955. * Enables audio in the associated scene.
  90956. */
  90957. enableAudio(): void;
  90958. /**
  90959. * Switch audio to headphone output.
  90960. */
  90961. switchAudioModeForHeadphones(): void;
  90962. /**
  90963. * Switch audio to normal speakers.
  90964. */
  90965. switchAudioModeForNormalSpeakers(): void;
  90966. private _afterRender;
  90967. }
  90968. }
  90969. declare module BABYLON {
  90970. /**
  90971. * Wraps one or more Sound objects and selects one with random weight for playback.
  90972. */
  90973. export class WeightedSound {
  90974. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90975. loop: boolean;
  90976. private _coneInnerAngle;
  90977. private _coneOuterAngle;
  90978. private _volume;
  90979. /** A Sound is currently playing. */
  90980. isPlaying: boolean;
  90981. /** A Sound is currently paused. */
  90982. isPaused: boolean;
  90983. private _sounds;
  90984. private _weights;
  90985. private _currentIndex?;
  90986. /**
  90987. * Creates a new WeightedSound from the list of sounds given.
  90988. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90989. * @param sounds Array of Sounds that will be selected from.
  90990. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90991. */
  90992. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90993. /**
  90994. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90995. */
  90996. /**
  90997. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90998. */
  90999. directionalConeInnerAngle: number;
  91000. /**
  91001. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91002. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91003. */
  91004. /**
  91005. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91006. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91007. */
  91008. directionalConeOuterAngle: number;
  91009. /**
  91010. * Playback volume.
  91011. */
  91012. /**
  91013. * Playback volume.
  91014. */
  91015. volume: number;
  91016. private _onended;
  91017. /**
  91018. * Suspend playback
  91019. */
  91020. pause(): void;
  91021. /**
  91022. * Stop playback
  91023. */
  91024. stop(): void;
  91025. /**
  91026. * Start playback.
  91027. * @param startOffset Position the clip head at a specific time in seconds.
  91028. */
  91029. play(startOffset?: number): void;
  91030. }
  91031. }
  91032. declare module BABYLON {
  91033. /**
  91034. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91036. */
  91037. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91038. /**
  91039. * Gets the name of the behavior.
  91040. */
  91041. readonly name: string;
  91042. /**
  91043. * The easing function used by animations
  91044. */
  91045. static EasingFunction: BackEase;
  91046. /**
  91047. * The easing mode used by animations
  91048. */
  91049. static EasingMode: number;
  91050. /**
  91051. * The duration of the animation, in milliseconds
  91052. */
  91053. transitionDuration: number;
  91054. /**
  91055. * Length of the distance animated by the transition when lower radius is reached
  91056. */
  91057. lowerRadiusTransitionRange: number;
  91058. /**
  91059. * Length of the distance animated by the transition when upper radius is reached
  91060. */
  91061. upperRadiusTransitionRange: number;
  91062. private _autoTransitionRange;
  91063. /**
  91064. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91065. */
  91066. /**
  91067. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91068. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91069. */
  91070. autoTransitionRange: boolean;
  91071. private _attachedCamera;
  91072. private _onAfterCheckInputsObserver;
  91073. private _onMeshTargetChangedObserver;
  91074. /**
  91075. * Initializes the behavior.
  91076. */
  91077. init(): void;
  91078. /**
  91079. * Attaches the behavior to its arc rotate camera.
  91080. * @param camera Defines the camera to attach the behavior to
  91081. */
  91082. attach(camera: ArcRotateCamera): void;
  91083. /**
  91084. * Detaches the behavior from its current arc rotate camera.
  91085. */
  91086. detach(): void;
  91087. private _radiusIsAnimating;
  91088. private _radiusBounceTransition;
  91089. private _animatables;
  91090. private _cachedWheelPrecision;
  91091. /**
  91092. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91093. * @param radiusLimit The limit to check against.
  91094. * @return Bool to indicate if at limit.
  91095. */
  91096. private _isRadiusAtLimit;
  91097. /**
  91098. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91099. * @param radiusDelta The delta by which to animate to. Can be negative.
  91100. */
  91101. private _applyBoundRadiusAnimation;
  91102. /**
  91103. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91104. */
  91105. protected _clearAnimationLocks(): void;
  91106. /**
  91107. * Stops and removes all animations that have been applied to the camera
  91108. */
  91109. stopAllAnimations(): void;
  91110. }
  91111. }
  91112. declare module BABYLON {
  91113. /**
  91114. * 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.
  91115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91116. */
  91117. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91118. /**
  91119. * Gets the name of the behavior.
  91120. */
  91121. readonly name: string;
  91122. private _mode;
  91123. private _radiusScale;
  91124. private _positionScale;
  91125. private _defaultElevation;
  91126. private _elevationReturnTime;
  91127. private _elevationReturnWaitTime;
  91128. private _zoomStopsAnimation;
  91129. private _framingTime;
  91130. /**
  91131. * The easing function used by animations
  91132. */
  91133. static EasingFunction: ExponentialEase;
  91134. /**
  91135. * The easing mode used by animations
  91136. */
  91137. static EasingMode: number;
  91138. /**
  91139. * Sets the current mode used by the behavior
  91140. */
  91141. /**
  91142. * Gets current mode used by the behavior.
  91143. */
  91144. mode: number;
  91145. /**
  91146. * Sets the scale applied to the radius (1 by default)
  91147. */
  91148. /**
  91149. * Gets the scale applied to the radius
  91150. */
  91151. radiusScale: number;
  91152. /**
  91153. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91154. */
  91155. /**
  91156. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91157. */
  91158. positionScale: number;
  91159. /**
  91160. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91161. * behaviour is triggered, in radians.
  91162. */
  91163. /**
  91164. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91165. * behaviour is triggered, in radians.
  91166. */
  91167. defaultElevation: number;
  91168. /**
  91169. * Sets the time (in milliseconds) taken to return to the default beta position.
  91170. * Negative value indicates camera should not return to default.
  91171. */
  91172. /**
  91173. * Gets the time (in milliseconds) taken to return to the default beta position.
  91174. * Negative value indicates camera should not return to default.
  91175. */
  91176. elevationReturnTime: number;
  91177. /**
  91178. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91179. */
  91180. /**
  91181. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91182. */
  91183. elevationReturnWaitTime: number;
  91184. /**
  91185. * Sets the flag that indicates if user zooming should stop animation.
  91186. */
  91187. /**
  91188. * Gets the flag that indicates if user zooming should stop animation.
  91189. */
  91190. zoomStopsAnimation: boolean;
  91191. /**
  91192. * Sets the transition time when framing the mesh, in milliseconds
  91193. */
  91194. /**
  91195. * Gets the transition time when framing the mesh, in milliseconds
  91196. */
  91197. framingTime: number;
  91198. /**
  91199. * Define if the behavior should automatically change the configured
  91200. * camera limits and sensibilities.
  91201. */
  91202. autoCorrectCameraLimitsAndSensibility: boolean;
  91203. private _onPrePointerObservableObserver;
  91204. private _onAfterCheckInputsObserver;
  91205. private _onMeshTargetChangedObserver;
  91206. private _attachedCamera;
  91207. private _isPointerDown;
  91208. private _lastInteractionTime;
  91209. /**
  91210. * Initializes the behavior.
  91211. */
  91212. init(): void;
  91213. /**
  91214. * Attaches the behavior to its arc rotate camera.
  91215. * @param camera Defines the camera to attach the behavior to
  91216. */
  91217. attach(camera: ArcRotateCamera): void;
  91218. /**
  91219. * Detaches the behavior from its current arc rotate camera.
  91220. */
  91221. detach(): void;
  91222. private _animatables;
  91223. private _betaIsAnimating;
  91224. private _betaTransition;
  91225. private _radiusTransition;
  91226. private _vectorTransition;
  91227. /**
  91228. * Targets the given mesh and updates zoom level accordingly.
  91229. * @param mesh The mesh to target.
  91230. * @param radius Optional. If a cached radius position already exists, overrides default.
  91231. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91232. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91233. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91234. */
  91235. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91236. /**
  91237. * Targets the given mesh with its children and updates zoom level accordingly.
  91238. * @param mesh The mesh to target.
  91239. * @param radius Optional. If a cached radius position already exists, overrides default.
  91240. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91241. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91242. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91243. */
  91244. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91245. /**
  91246. * Targets the given meshes with their children and updates zoom level accordingly.
  91247. * @param meshes The mesh to target.
  91248. * @param radius Optional. If a cached radius position already exists, overrides default.
  91249. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91250. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91251. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91252. */
  91253. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91254. /**
  91255. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91256. * @param minimumWorld Determines the smaller position of the bounding box extend
  91257. * @param maximumWorld Determines the bigger position of the bounding box extend
  91258. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91259. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91260. */
  91261. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91262. /**
  91263. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91264. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91265. * frustum width.
  91266. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91267. * to fully enclose the mesh in the viewing frustum.
  91268. */
  91269. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91270. /**
  91271. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91272. * is automatically returned to its default position (expected to be above ground plane).
  91273. */
  91274. private _maintainCameraAboveGround;
  91275. /**
  91276. * Returns the frustum slope based on the canvas ratio and camera FOV
  91277. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91278. */
  91279. private _getFrustumSlope;
  91280. /**
  91281. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91282. */
  91283. private _clearAnimationLocks;
  91284. /**
  91285. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91286. */
  91287. private _applyUserInteraction;
  91288. /**
  91289. * Stops and removes all animations that have been applied to the camera
  91290. */
  91291. stopAllAnimations(): void;
  91292. /**
  91293. * Gets a value indicating if the user is moving the camera
  91294. */
  91295. readonly isUserIsMoving: boolean;
  91296. /**
  91297. * The camera can move all the way towards the mesh.
  91298. */
  91299. static IgnoreBoundsSizeMode: number;
  91300. /**
  91301. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91302. */
  91303. static FitFrustumSidesMode: number;
  91304. }
  91305. }
  91306. declare module BABYLON {
  91307. /**
  91308. * Base class for Camera Pointer Inputs.
  91309. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91310. * for example usage.
  91311. */
  91312. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91313. /**
  91314. * Defines the camera the input is attached to.
  91315. */
  91316. abstract camera: Camera;
  91317. /**
  91318. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91319. */
  91320. protected _altKey: boolean;
  91321. protected _ctrlKey: boolean;
  91322. protected _metaKey: boolean;
  91323. protected _shiftKey: boolean;
  91324. /**
  91325. * Which mouse buttons were pressed at time of last mouse event.
  91326. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91327. */
  91328. protected _buttonsPressed: number;
  91329. /**
  91330. * Defines the buttons associated with the input to handle camera move.
  91331. */
  91332. buttons: number[];
  91333. /**
  91334. * Attach the input controls to a specific dom element to get the input from.
  91335. * @param element Defines the element the controls should be listened from
  91336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91337. */
  91338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91339. /**
  91340. * Detach the current controls from the specified dom element.
  91341. * @param element Defines the element to stop listening the inputs from
  91342. */
  91343. detachControl(element: Nullable<HTMLElement>): void;
  91344. /**
  91345. * Gets the class name of the current input.
  91346. * @returns the class name
  91347. */
  91348. getClassName(): string;
  91349. /**
  91350. * Get the friendly name associated with the input class.
  91351. * @returns the input friendly name
  91352. */
  91353. getSimpleName(): string;
  91354. /**
  91355. * Called on pointer POINTERDOUBLETAP event.
  91356. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91357. */
  91358. protected onDoubleTap(type: string): void;
  91359. /**
  91360. * Called on pointer POINTERMOVE event if only a single touch is active.
  91361. * Override this method to provide functionality.
  91362. */
  91363. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91364. /**
  91365. * Called on pointer POINTERMOVE event if multiple touches are active.
  91366. * Override this method to provide functionality.
  91367. */
  91368. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91369. /**
  91370. * Called on JS contextmenu event.
  91371. * Override this method to provide functionality.
  91372. */
  91373. protected onContextMenu(evt: PointerEvent): void;
  91374. /**
  91375. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91376. * press.
  91377. * Override this method to provide functionality.
  91378. */
  91379. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91380. /**
  91381. * Called each time a new POINTERUP event occurs. Ie, for each button
  91382. * release.
  91383. * Override this method to provide functionality.
  91384. */
  91385. protected onButtonUp(evt: PointerEvent): void;
  91386. /**
  91387. * Called when window becomes inactive.
  91388. * Override this method to provide functionality.
  91389. */
  91390. protected onLostFocus(): void;
  91391. private _pointerInput;
  91392. private _observer;
  91393. private _onLostFocus;
  91394. }
  91395. }
  91396. declare module BABYLON {
  91397. /**
  91398. * Manage the pointers inputs to control an arc rotate camera.
  91399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91400. */
  91401. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91402. /**
  91403. * Defines the camera the input is attached to.
  91404. */
  91405. camera: ArcRotateCamera;
  91406. /**
  91407. * Gets the class name of the current input.
  91408. * @returns the class name
  91409. */
  91410. getClassName(): string;
  91411. /**
  91412. * Defines the buttons associated with the input to handle camera move.
  91413. */
  91414. buttons: number[];
  91415. /**
  91416. * Defines the pointer angular sensibility along the X axis or how fast is
  91417. * the camera rotating.
  91418. */
  91419. angularSensibilityX: number;
  91420. /**
  91421. * Defines the pointer angular sensibility along the Y axis or how fast is
  91422. * the camera rotating.
  91423. */
  91424. angularSensibilityY: number;
  91425. /**
  91426. * Defines the pointer pinch precision or how fast is the camera zooming.
  91427. */
  91428. pinchPrecision: number;
  91429. /**
  91430. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91431. * from 0.
  91432. * It defines the percentage of current camera.radius to use as delta when
  91433. * pinch zoom is used.
  91434. */
  91435. pinchDeltaPercentage: number;
  91436. /**
  91437. * Defines the pointer panning sensibility or how fast is the camera moving.
  91438. */
  91439. panningSensibility: number;
  91440. /**
  91441. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91442. */
  91443. multiTouchPanning: boolean;
  91444. /**
  91445. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91446. * zoom (pinch) through multitouch.
  91447. */
  91448. multiTouchPanAndZoom: boolean;
  91449. /**
  91450. * Revers pinch action direction.
  91451. */
  91452. pinchInwards: boolean;
  91453. private _isPanClick;
  91454. private _twoFingerActivityCount;
  91455. private _isPinching;
  91456. /**
  91457. * Called on pointer POINTERMOVE event if only a single touch is active.
  91458. */
  91459. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91460. /**
  91461. * Called on pointer POINTERDOUBLETAP event.
  91462. */
  91463. protected onDoubleTap(type: string): void;
  91464. /**
  91465. * Called on pointer POINTERMOVE event if multiple touches are active.
  91466. */
  91467. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91468. /**
  91469. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91470. * press.
  91471. */
  91472. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91473. /**
  91474. * Called each time a new POINTERUP event occurs. Ie, for each button
  91475. * release.
  91476. */
  91477. protected onButtonUp(evt: PointerEvent): void;
  91478. /**
  91479. * Called when window becomes inactive.
  91480. */
  91481. protected onLostFocus(): void;
  91482. }
  91483. }
  91484. declare module BABYLON {
  91485. /**
  91486. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91488. */
  91489. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91490. /**
  91491. * Defines the camera the input is attached to.
  91492. */
  91493. camera: ArcRotateCamera;
  91494. /**
  91495. * Defines the list of key codes associated with the up action (increase alpha)
  91496. */
  91497. keysUp: number[];
  91498. /**
  91499. * Defines the list of key codes associated with the down action (decrease alpha)
  91500. */
  91501. keysDown: number[];
  91502. /**
  91503. * Defines the list of key codes associated with the left action (increase beta)
  91504. */
  91505. keysLeft: number[];
  91506. /**
  91507. * Defines the list of key codes associated with the right action (decrease beta)
  91508. */
  91509. keysRight: number[];
  91510. /**
  91511. * Defines the list of key codes associated with the reset action.
  91512. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91513. */
  91514. keysReset: number[];
  91515. /**
  91516. * Defines the panning sensibility of the inputs.
  91517. * (How fast is the camera paning)
  91518. */
  91519. panningSensibility: number;
  91520. /**
  91521. * Defines the zooming sensibility of the inputs.
  91522. * (How fast is the camera zooming)
  91523. */
  91524. zoomingSensibility: number;
  91525. /**
  91526. * Defines wether maintaining the alt key down switch the movement mode from
  91527. * orientation to zoom.
  91528. */
  91529. useAltToZoom: boolean;
  91530. /**
  91531. * Rotation speed of the camera
  91532. */
  91533. angularSpeed: number;
  91534. private _keys;
  91535. private _ctrlPressed;
  91536. private _altPressed;
  91537. private _onCanvasBlurObserver;
  91538. private _onKeyboardObserver;
  91539. private _engine;
  91540. private _scene;
  91541. /**
  91542. * Attach the input controls to a specific dom element to get the input from.
  91543. * @param element Defines the element the controls should be listened from
  91544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91545. */
  91546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91547. /**
  91548. * Detach the current controls from the specified dom element.
  91549. * @param element Defines the element to stop listening the inputs from
  91550. */
  91551. detachControl(element: Nullable<HTMLElement>): void;
  91552. /**
  91553. * Update the current camera state depending on the inputs that have been used this frame.
  91554. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91555. */
  91556. checkInputs(): void;
  91557. /**
  91558. * Gets the class name of the current intput.
  91559. * @returns the class name
  91560. */
  91561. getClassName(): string;
  91562. /**
  91563. * Get the friendly name associated with the input class.
  91564. * @returns the input friendly name
  91565. */
  91566. getSimpleName(): string;
  91567. }
  91568. }
  91569. declare module BABYLON {
  91570. /**
  91571. * Manage the mouse wheel inputs to control an arc rotate camera.
  91572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91573. */
  91574. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91575. /**
  91576. * Defines the camera the input is attached to.
  91577. */
  91578. camera: ArcRotateCamera;
  91579. /**
  91580. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91581. */
  91582. wheelPrecision: number;
  91583. /**
  91584. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91585. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91586. */
  91587. wheelDeltaPercentage: number;
  91588. private _wheel;
  91589. private _observer;
  91590. /**
  91591. * Attach the input controls to a specific dom element to get the input from.
  91592. * @param element Defines the element the controls should be listened from
  91593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91594. */
  91595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91596. /**
  91597. * Detach the current controls from the specified dom element.
  91598. * @param element Defines the element to stop listening the inputs from
  91599. */
  91600. detachControl(element: Nullable<HTMLElement>): void;
  91601. /**
  91602. * Gets the class name of the current intput.
  91603. * @returns the class name
  91604. */
  91605. getClassName(): string;
  91606. /**
  91607. * Get the friendly name associated with the input class.
  91608. * @returns the input friendly name
  91609. */
  91610. getSimpleName(): string;
  91611. }
  91612. }
  91613. declare module BABYLON {
  91614. /**
  91615. * Default Inputs manager for the ArcRotateCamera.
  91616. * It groups all the default supported inputs for ease of use.
  91617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91618. */
  91619. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91620. /**
  91621. * Instantiates a new ArcRotateCameraInputsManager.
  91622. * @param camera Defines the camera the inputs belong to
  91623. */
  91624. constructor(camera: ArcRotateCamera);
  91625. /**
  91626. * Add mouse wheel input support to the input manager.
  91627. * @returns the current input manager
  91628. */
  91629. addMouseWheel(): ArcRotateCameraInputsManager;
  91630. /**
  91631. * Add pointers input support to the input manager.
  91632. * @returns the current input manager
  91633. */
  91634. addPointers(): ArcRotateCameraInputsManager;
  91635. /**
  91636. * Add keyboard input support to the input manager.
  91637. * @returns the current input manager
  91638. */
  91639. addKeyboard(): ArcRotateCameraInputsManager;
  91640. }
  91641. }
  91642. declare module BABYLON {
  91643. /**
  91644. * This represents an orbital type of camera.
  91645. *
  91646. * 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.
  91647. * 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.
  91648. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91649. */
  91650. export class ArcRotateCamera extends TargetCamera {
  91651. /**
  91652. * Defines the rotation angle of the camera along the longitudinal axis.
  91653. */
  91654. alpha: number;
  91655. /**
  91656. * Defines the rotation angle of the camera along the latitudinal axis.
  91657. */
  91658. beta: number;
  91659. /**
  91660. * Defines the radius of the camera from it s target point.
  91661. */
  91662. radius: number;
  91663. protected _target: Vector3;
  91664. protected _targetHost: Nullable<AbstractMesh>;
  91665. /**
  91666. * Defines the target point of the camera.
  91667. * The camera looks towards it form the radius distance.
  91668. */
  91669. target: Vector3;
  91670. /**
  91671. * Define the current local position of the camera in the scene
  91672. */
  91673. position: Vector3;
  91674. /**
  91675. * Current inertia value on the longitudinal axis.
  91676. * The bigger this number the longer it will take for the camera to stop.
  91677. */
  91678. inertialAlphaOffset: number;
  91679. /**
  91680. * Current inertia value on the latitudinal axis.
  91681. * The bigger this number the longer it will take for the camera to stop.
  91682. */
  91683. inertialBetaOffset: number;
  91684. /**
  91685. * Current inertia value on the radius axis.
  91686. * The bigger this number the longer it will take for the camera to stop.
  91687. */
  91688. inertialRadiusOffset: number;
  91689. /**
  91690. * Minimum allowed angle on the longitudinal axis.
  91691. * This can help limiting how the Camera is able to move in the scene.
  91692. */
  91693. lowerAlphaLimit: Nullable<number>;
  91694. /**
  91695. * Maximum allowed angle on the longitudinal axis.
  91696. * This can help limiting how the Camera is able to move in the scene.
  91697. */
  91698. upperAlphaLimit: Nullable<number>;
  91699. /**
  91700. * Minimum allowed angle on the latitudinal axis.
  91701. * This can help limiting how the Camera is able to move in the scene.
  91702. */
  91703. lowerBetaLimit: number;
  91704. /**
  91705. * Maximum allowed angle on the latitudinal axis.
  91706. * This can help limiting how the Camera is able to move in the scene.
  91707. */
  91708. upperBetaLimit: number;
  91709. /**
  91710. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91711. * This can help limiting how the Camera is able to move in the scene.
  91712. */
  91713. lowerRadiusLimit: Nullable<number>;
  91714. /**
  91715. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91716. * This can help limiting how the Camera is able to move in the scene.
  91717. */
  91718. upperRadiusLimit: Nullable<number>;
  91719. /**
  91720. * Defines the current inertia value used during panning of the camera along the X axis.
  91721. */
  91722. inertialPanningX: number;
  91723. /**
  91724. * Defines the current inertia value used during panning of the camera along the Y axis.
  91725. */
  91726. inertialPanningY: number;
  91727. /**
  91728. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91729. * Basically if your fingers moves away from more than this distance you will be considered
  91730. * in pinch mode.
  91731. */
  91732. pinchToPanMaxDistance: number;
  91733. /**
  91734. * Defines the maximum distance the camera can pan.
  91735. * This could help keeping the cammera always in your scene.
  91736. */
  91737. panningDistanceLimit: Nullable<number>;
  91738. /**
  91739. * Defines the target of the camera before paning.
  91740. */
  91741. panningOriginTarget: Vector3;
  91742. /**
  91743. * Defines the value of the inertia used during panning.
  91744. * 0 would mean stop inertia and one would mean no decelleration at all.
  91745. */
  91746. panningInertia: number;
  91747. /**
  91748. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91749. */
  91750. angularSensibilityX: number;
  91751. /**
  91752. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91753. */
  91754. angularSensibilityY: number;
  91755. /**
  91756. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91757. */
  91758. pinchPrecision: number;
  91759. /**
  91760. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91761. * It will be used instead of pinchDeltaPrecision if different from 0.
  91762. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91763. */
  91764. pinchDeltaPercentage: number;
  91765. /**
  91766. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91767. */
  91768. panningSensibility: number;
  91769. /**
  91770. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91771. */
  91772. keysUp: number[];
  91773. /**
  91774. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91775. */
  91776. keysDown: number[];
  91777. /**
  91778. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91779. */
  91780. keysLeft: number[];
  91781. /**
  91782. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91783. */
  91784. keysRight: number[];
  91785. /**
  91786. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91787. */
  91788. wheelPrecision: number;
  91789. /**
  91790. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91791. * It will be used instead of pinchDeltaPrecision if different from 0.
  91792. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91793. */
  91794. wheelDeltaPercentage: number;
  91795. /**
  91796. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91797. */
  91798. zoomOnFactor: number;
  91799. /**
  91800. * Defines a screen offset for the camera position.
  91801. */
  91802. targetScreenOffset: Vector2;
  91803. /**
  91804. * Allows the camera to be completely reversed.
  91805. * If false the camera can not arrive upside down.
  91806. */
  91807. allowUpsideDown: boolean;
  91808. /**
  91809. * Define if double tap/click is used to restore the previously saved state of the camera.
  91810. */
  91811. useInputToRestoreState: boolean;
  91812. /** @hidden */
  91813. _viewMatrix: Matrix;
  91814. /** @hidden */
  91815. _useCtrlForPanning: boolean;
  91816. /** @hidden */
  91817. _panningMouseButton: number;
  91818. /**
  91819. * Defines the input associated to the camera.
  91820. */
  91821. inputs: ArcRotateCameraInputsManager;
  91822. /** @hidden */
  91823. _reset: () => void;
  91824. /**
  91825. * Defines the allowed panning axis.
  91826. */
  91827. panningAxis: Vector3;
  91828. protected _localDirection: Vector3;
  91829. protected _transformedDirection: Vector3;
  91830. private _bouncingBehavior;
  91831. /**
  91832. * Gets the bouncing behavior of the camera if it has been enabled.
  91833. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91834. */
  91835. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91836. /**
  91837. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91838. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91839. */
  91840. useBouncingBehavior: boolean;
  91841. private _framingBehavior;
  91842. /**
  91843. * Gets the framing behavior of the camera if it has been enabled.
  91844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91845. */
  91846. readonly framingBehavior: Nullable<FramingBehavior>;
  91847. /**
  91848. * Defines if the framing behavior of the camera is enabled on the camera.
  91849. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91850. */
  91851. useFramingBehavior: boolean;
  91852. private _autoRotationBehavior;
  91853. /**
  91854. * Gets the auto rotation behavior of the camera if it has been enabled.
  91855. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91856. */
  91857. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91858. /**
  91859. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91860. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91861. */
  91862. useAutoRotationBehavior: boolean;
  91863. /**
  91864. * Observable triggered when the mesh target has been changed on the camera.
  91865. */
  91866. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91867. /**
  91868. * Event raised when the camera is colliding with a mesh.
  91869. */
  91870. onCollide: (collidedMesh: AbstractMesh) => void;
  91871. /**
  91872. * Defines whether the camera should check collision with the objects oh the scene.
  91873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91874. */
  91875. checkCollisions: boolean;
  91876. /**
  91877. * Defines the collision radius of the camera.
  91878. * This simulates a sphere around the camera.
  91879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91880. */
  91881. collisionRadius: Vector3;
  91882. protected _collider: Collider;
  91883. protected _previousPosition: Vector3;
  91884. protected _collisionVelocity: Vector3;
  91885. protected _newPosition: Vector3;
  91886. protected _previousAlpha: number;
  91887. protected _previousBeta: number;
  91888. protected _previousRadius: number;
  91889. protected _collisionTriggered: boolean;
  91890. protected _targetBoundingCenter: Nullable<Vector3>;
  91891. private _computationVector;
  91892. private _tempAxisVector;
  91893. private _tempAxisRotationMatrix;
  91894. /**
  91895. * Instantiates a new ArcRotateCamera in a given scene
  91896. * @param name Defines the name of the camera
  91897. * @param alpha Defines the camera rotation along the logitudinal axis
  91898. * @param beta Defines the camera rotation along the latitudinal axis
  91899. * @param radius Defines the camera distance from its target
  91900. * @param target Defines the camera target
  91901. * @param scene Defines the scene the camera belongs to
  91902. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91903. */
  91904. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91905. /** @hidden */
  91906. _initCache(): void;
  91907. /** @hidden */
  91908. _updateCache(ignoreParentClass?: boolean): void;
  91909. protected _getTargetPosition(): Vector3;
  91910. private _storedAlpha;
  91911. private _storedBeta;
  91912. private _storedRadius;
  91913. private _storedTarget;
  91914. /**
  91915. * Stores the current state of the camera (alpha, beta, radius and target)
  91916. * @returns the camera itself
  91917. */
  91918. storeState(): Camera;
  91919. /**
  91920. * @hidden
  91921. * Restored camera state. You must call storeState() first
  91922. */
  91923. _restoreStateValues(): boolean;
  91924. /** @hidden */
  91925. _isSynchronizedViewMatrix(): boolean;
  91926. /**
  91927. * Attached controls to the current camera.
  91928. * @param element Defines the element the controls should be listened from
  91929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91930. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91931. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91932. */
  91933. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91934. /**
  91935. * Detach the current controls from the camera.
  91936. * The camera will stop reacting to inputs.
  91937. * @param element Defines the element to stop listening the inputs from
  91938. */
  91939. detachControl(element: HTMLElement): void;
  91940. /** @hidden */
  91941. _checkInputs(): void;
  91942. protected _checkLimits(): void;
  91943. /**
  91944. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91945. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91946. */
  91947. rebuildAnglesAndRadius(updateView?: boolean): void;
  91948. /**
  91949. * Use a position to define the current camera related information like aplha, beta and radius
  91950. * @param position Defines the position to set the camera at
  91951. */
  91952. setPosition(position: Vector3): void;
  91953. /**
  91954. * Defines the target the camera should look at.
  91955. * This will automatically adapt alpha beta and radius to fit within the new target.
  91956. * @param target Defines the new target as a Vector or a mesh
  91957. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91958. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91959. */
  91960. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91961. /** @hidden */
  91962. _getViewMatrix(): Matrix;
  91963. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91964. /**
  91965. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91966. * @param meshes Defines the mesh to zoom on
  91967. * @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)
  91968. */
  91969. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91970. /**
  91971. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91972. * The target will be changed but the radius
  91973. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91974. * @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)
  91975. */
  91976. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91977. min: Vector3;
  91978. max: Vector3;
  91979. distance: number;
  91980. }, doNotUpdateMaxZ?: boolean): void;
  91981. /**
  91982. * @override
  91983. * Override Camera.createRigCamera
  91984. */
  91985. createRigCamera(name: string, cameraIndex: number): Camera;
  91986. /**
  91987. * @hidden
  91988. * @override
  91989. * Override Camera._updateRigCameras
  91990. */
  91991. _updateRigCameras(): void;
  91992. /**
  91993. * Destroy the camera and release the current resources hold by it.
  91994. */
  91995. dispose(): void;
  91996. /**
  91997. * Gets the current object class name.
  91998. * @return the class name
  91999. */
  92000. getClassName(): string;
  92001. }
  92002. }
  92003. declare module BABYLON {
  92004. /**
  92005. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92006. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92007. */
  92008. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92009. /**
  92010. * Gets the name of the behavior.
  92011. */
  92012. readonly name: string;
  92013. private _zoomStopsAnimation;
  92014. private _idleRotationSpeed;
  92015. private _idleRotationWaitTime;
  92016. private _idleRotationSpinupTime;
  92017. /**
  92018. * Sets the flag that indicates if user zooming should stop animation.
  92019. */
  92020. /**
  92021. * Gets the flag that indicates if user zooming should stop animation.
  92022. */
  92023. zoomStopsAnimation: boolean;
  92024. /**
  92025. * Sets the default speed at which the camera rotates around the model.
  92026. */
  92027. /**
  92028. * Gets the default speed at which the camera rotates around the model.
  92029. */
  92030. idleRotationSpeed: number;
  92031. /**
  92032. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92033. */
  92034. /**
  92035. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92036. */
  92037. idleRotationWaitTime: number;
  92038. /**
  92039. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92040. */
  92041. /**
  92042. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92043. */
  92044. idleRotationSpinupTime: number;
  92045. /**
  92046. * Gets a value indicating if the camera is currently rotating because of this behavior
  92047. */
  92048. readonly rotationInProgress: boolean;
  92049. private _onPrePointerObservableObserver;
  92050. private _onAfterCheckInputsObserver;
  92051. private _attachedCamera;
  92052. private _isPointerDown;
  92053. private _lastFrameTime;
  92054. private _lastInteractionTime;
  92055. private _cameraRotationSpeed;
  92056. /**
  92057. * Initializes the behavior.
  92058. */
  92059. init(): void;
  92060. /**
  92061. * Attaches the behavior to its arc rotate camera.
  92062. * @param camera Defines the camera to attach the behavior to
  92063. */
  92064. attach(camera: ArcRotateCamera): void;
  92065. /**
  92066. * Detaches the behavior from its current arc rotate camera.
  92067. */
  92068. detach(): void;
  92069. /**
  92070. * Returns true if user is scrolling.
  92071. * @return true if user is scrolling.
  92072. */
  92073. private _userIsZooming;
  92074. private _lastFrameRadius;
  92075. private _shouldAnimationStopForInteraction;
  92076. /**
  92077. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92078. */
  92079. private _applyUserInteraction;
  92080. private _userIsMoving;
  92081. }
  92082. }
  92083. declare module BABYLON {
  92084. /**
  92085. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92086. */
  92087. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92088. private ui;
  92089. /**
  92090. * The name of the behavior
  92091. */
  92092. name: string;
  92093. /**
  92094. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92095. */
  92096. distanceAwayFromFace: number;
  92097. /**
  92098. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92099. */
  92100. distanceAwayFromBottomOfFace: number;
  92101. private _faceVectors;
  92102. private _target;
  92103. private _scene;
  92104. private _onRenderObserver;
  92105. private _tmpMatrix;
  92106. private _tmpVector;
  92107. /**
  92108. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92109. * @param ui The transform node that should be attched to the mesh
  92110. */
  92111. constructor(ui: TransformNode);
  92112. /**
  92113. * Initializes the behavior
  92114. */
  92115. init(): void;
  92116. private _closestFace;
  92117. private _zeroVector;
  92118. private _lookAtTmpMatrix;
  92119. private _lookAtToRef;
  92120. /**
  92121. * Attaches the AttachToBoxBehavior to the passed in mesh
  92122. * @param target The mesh that the specified node will be attached to
  92123. */
  92124. attach(target: Mesh): void;
  92125. /**
  92126. * Detaches the behavior from the mesh
  92127. */
  92128. detach(): void;
  92129. }
  92130. }
  92131. declare module BABYLON {
  92132. /**
  92133. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92134. */
  92135. export class FadeInOutBehavior implements Behavior<Mesh> {
  92136. /**
  92137. * Time in milliseconds to delay before fading in (Default: 0)
  92138. */
  92139. delay: number;
  92140. /**
  92141. * Time in milliseconds for the mesh to fade in (Default: 300)
  92142. */
  92143. fadeInTime: number;
  92144. private _millisecondsPerFrame;
  92145. private _hovered;
  92146. private _hoverValue;
  92147. private _ownerNode;
  92148. /**
  92149. * Instatiates the FadeInOutBehavior
  92150. */
  92151. constructor();
  92152. /**
  92153. * The name of the behavior
  92154. */
  92155. readonly name: string;
  92156. /**
  92157. * Initializes the behavior
  92158. */
  92159. init(): void;
  92160. /**
  92161. * Attaches the fade behavior on the passed in mesh
  92162. * @param ownerNode The mesh that will be faded in/out once attached
  92163. */
  92164. attach(ownerNode: Mesh): void;
  92165. /**
  92166. * Detaches the behavior from the mesh
  92167. */
  92168. detach(): void;
  92169. /**
  92170. * Triggers the mesh to begin fading in or out
  92171. * @param value if the object should fade in or out (true to fade in)
  92172. */
  92173. fadeIn(value: boolean): void;
  92174. private _update;
  92175. private _setAllVisibility;
  92176. }
  92177. }
  92178. declare module BABYLON {
  92179. /**
  92180. * Class containing a set of static utilities functions for managing Pivots
  92181. * @hidden
  92182. */
  92183. export class PivotTools {
  92184. private static _PivotCached;
  92185. private static _OldPivotPoint;
  92186. private static _PivotTranslation;
  92187. private static _PivotTmpVector;
  92188. /** @hidden */
  92189. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92190. /** @hidden */
  92191. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92192. }
  92193. }
  92194. declare module BABYLON {
  92195. /**
  92196. * Class containing static functions to help procedurally build meshes
  92197. */
  92198. export class PlaneBuilder {
  92199. /**
  92200. * Creates a plane mesh
  92201. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92202. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92203. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92205. * * If you create a double-sided mesh, you can choose what parts of 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
  92206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92207. * @param name defines the name of the mesh
  92208. * @param options defines the options used to create the mesh
  92209. * @param scene defines the hosting scene
  92210. * @returns the plane mesh
  92211. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92212. */
  92213. static CreatePlane(name: string, options: {
  92214. size?: number;
  92215. width?: number;
  92216. height?: number;
  92217. sideOrientation?: number;
  92218. frontUVs?: Vector4;
  92219. backUVs?: Vector4;
  92220. updatable?: boolean;
  92221. sourcePlane?: Plane;
  92222. }, scene: Scene): Mesh;
  92223. }
  92224. }
  92225. declare module BABYLON {
  92226. /**
  92227. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92228. */
  92229. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92230. private static _AnyMouseID;
  92231. private _attachedNode;
  92232. private _dragPlane;
  92233. private _scene;
  92234. private _pointerObserver;
  92235. private _beforeRenderObserver;
  92236. private static _planeScene;
  92237. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92238. /**
  92239. * 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)
  92240. */
  92241. maxDragAngle: number;
  92242. /**
  92243. * @hidden
  92244. */
  92245. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92246. /**
  92247. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92248. */
  92249. currentDraggingPointerID: number;
  92250. /**
  92251. * The last position where the pointer hit the drag plane in world space
  92252. */
  92253. lastDragPosition: Vector3;
  92254. /**
  92255. * If the behavior is currently in a dragging state
  92256. */
  92257. dragging: boolean;
  92258. /**
  92259. * 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)
  92260. */
  92261. dragDeltaRatio: number;
  92262. /**
  92263. * If the drag plane orientation should be updated during the dragging (Default: true)
  92264. */
  92265. updateDragPlane: boolean;
  92266. private _debugMode;
  92267. private _moving;
  92268. /**
  92269. * Fires each time the attached mesh is dragged with the pointer
  92270. * * delta between last drag position and current drag position in world space
  92271. * * dragDistance along the drag axis
  92272. * * dragPlaneNormal normal of the current drag plane used during the drag
  92273. * * dragPlanePoint in world space where the drag intersects the drag plane
  92274. */
  92275. onDragObservable: Observable<{
  92276. delta: Vector3;
  92277. dragPlanePoint: Vector3;
  92278. dragPlaneNormal: Vector3;
  92279. dragDistance: number;
  92280. pointerId: number;
  92281. }>;
  92282. /**
  92283. * Fires each time a drag begins (eg. mouse down on mesh)
  92284. */
  92285. onDragStartObservable: Observable<{
  92286. dragPlanePoint: Vector3;
  92287. pointerId: number;
  92288. }>;
  92289. /**
  92290. * Fires each time a drag ends (eg. mouse release after drag)
  92291. */
  92292. onDragEndObservable: Observable<{
  92293. dragPlanePoint: Vector3;
  92294. pointerId: number;
  92295. }>;
  92296. /**
  92297. * If the attached mesh should be moved when dragged
  92298. */
  92299. moveAttached: boolean;
  92300. /**
  92301. * If the drag behavior will react to drag events (Default: true)
  92302. */
  92303. enabled: boolean;
  92304. /**
  92305. * If camera controls should be detached during the drag
  92306. */
  92307. detachCameraControls: boolean;
  92308. /**
  92309. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92310. */
  92311. useObjectOrienationForDragging: boolean;
  92312. private _options;
  92313. /**
  92314. * Creates a pointer drag behavior that can be attached to a mesh
  92315. * @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)
  92316. */
  92317. constructor(options?: {
  92318. dragAxis?: Vector3;
  92319. dragPlaneNormal?: Vector3;
  92320. });
  92321. /**
  92322. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92323. */
  92324. validateDrag: (targetPosition: Vector3) => boolean;
  92325. /**
  92326. * The name of the behavior
  92327. */
  92328. readonly name: string;
  92329. /**
  92330. * Initializes the behavior
  92331. */
  92332. init(): void;
  92333. private _tmpVector;
  92334. private _alternatePickedPoint;
  92335. private _worldDragAxis;
  92336. private _targetPosition;
  92337. private _attachedElement;
  92338. /**
  92339. * Attaches the drag behavior the passed in mesh
  92340. * @param ownerNode The mesh that will be dragged around once attached
  92341. */
  92342. attach(ownerNode: AbstractMesh): void;
  92343. /**
  92344. * Force relase the drag action by code.
  92345. */
  92346. releaseDrag(): void;
  92347. private _startDragRay;
  92348. private _lastPointerRay;
  92349. /**
  92350. * Simulates the start of a pointer drag event on the behavior
  92351. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92352. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92353. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92354. */
  92355. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92356. private _startDrag;
  92357. private _dragDelta;
  92358. private _moveDrag;
  92359. private _pickWithRayOnDragPlane;
  92360. private _pointA;
  92361. private _pointB;
  92362. private _pointC;
  92363. private _lineA;
  92364. private _lineB;
  92365. private _localAxis;
  92366. private _lookAt;
  92367. private _updateDragPlanePosition;
  92368. /**
  92369. * Detaches the behavior from the mesh
  92370. */
  92371. detach(): void;
  92372. }
  92373. }
  92374. declare module BABYLON {
  92375. /**
  92376. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92377. */
  92378. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92379. private _dragBehaviorA;
  92380. private _dragBehaviorB;
  92381. private _startDistance;
  92382. private _initialScale;
  92383. private _targetScale;
  92384. private _ownerNode;
  92385. private _sceneRenderObserver;
  92386. /**
  92387. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92388. */
  92389. constructor();
  92390. /**
  92391. * The name of the behavior
  92392. */
  92393. readonly name: string;
  92394. /**
  92395. * Initializes the behavior
  92396. */
  92397. init(): void;
  92398. private _getCurrentDistance;
  92399. /**
  92400. * Attaches the scale behavior the passed in mesh
  92401. * @param ownerNode The mesh that will be scaled around once attached
  92402. */
  92403. attach(ownerNode: Mesh): void;
  92404. /**
  92405. * Detaches the behavior from the mesh
  92406. */
  92407. detach(): void;
  92408. }
  92409. }
  92410. declare module BABYLON {
  92411. /**
  92412. * 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
  92413. */
  92414. export class SixDofDragBehavior implements Behavior<Mesh> {
  92415. private static _virtualScene;
  92416. private _ownerNode;
  92417. private _sceneRenderObserver;
  92418. private _scene;
  92419. private _targetPosition;
  92420. private _virtualOriginMesh;
  92421. private _virtualDragMesh;
  92422. private _pointerObserver;
  92423. private _moving;
  92424. private _startingOrientation;
  92425. /**
  92426. * 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)
  92427. */
  92428. private zDragFactor;
  92429. /**
  92430. * If the object should rotate to face the drag origin
  92431. */
  92432. rotateDraggedObject: boolean;
  92433. /**
  92434. * If the behavior is currently in a dragging state
  92435. */
  92436. dragging: boolean;
  92437. /**
  92438. * 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)
  92439. */
  92440. dragDeltaRatio: number;
  92441. /**
  92442. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92443. */
  92444. currentDraggingPointerID: number;
  92445. /**
  92446. * If camera controls should be detached during the drag
  92447. */
  92448. detachCameraControls: boolean;
  92449. /**
  92450. * Fires each time a drag starts
  92451. */
  92452. onDragStartObservable: Observable<{}>;
  92453. /**
  92454. * Fires each time a drag ends (eg. mouse release after drag)
  92455. */
  92456. onDragEndObservable: Observable<{}>;
  92457. /**
  92458. * 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
  92459. */
  92460. constructor();
  92461. /**
  92462. * The name of the behavior
  92463. */
  92464. readonly name: string;
  92465. /**
  92466. * Initializes the behavior
  92467. */
  92468. init(): void;
  92469. /**
  92470. * Attaches the scale behavior the passed in mesh
  92471. * @param ownerNode The mesh that will be scaled around once attached
  92472. */
  92473. attach(ownerNode: Mesh): void;
  92474. /**
  92475. * Detaches the behavior from the mesh
  92476. */
  92477. detach(): void;
  92478. }
  92479. }
  92480. declare module BABYLON {
  92481. /**
  92482. * Class used to apply inverse kinematics to bones
  92483. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92484. */
  92485. export class BoneIKController {
  92486. private static _tmpVecs;
  92487. private static _tmpQuat;
  92488. private static _tmpMats;
  92489. /**
  92490. * Gets or sets the target mesh
  92491. */
  92492. targetMesh: AbstractMesh;
  92493. /** Gets or sets the mesh used as pole */
  92494. poleTargetMesh: AbstractMesh;
  92495. /**
  92496. * Gets or sets the bone used as pole
  92497. */
  92498. poleTargetBone: Nullable<Bone>;
  92499. /**
  92500. * Gets or sets the target position
  92501. */
  92502. targetPosition: Vector3;
  92503. /**
  92504. * Gets or sets the pole target position
  92505. */
  92506. poleTargetPosition: Vector3;
  92507. /**
  92508. * Gets or sets the pole target local offset
  92509. */
  92510. poleTargetLocalOffset: Vector3;
  92511. /**
  92512. * Gets or sets the pole angle
  92513. */
  92514. poleAngle: number;
  92515. /**
  92516. * Gets or sets the mesh associated with the controller
  92517. */
  92518. mesh: AbstractMesh;
  92519. /**
  92520. * 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)
  92521. */
  92522. slerpAmount: number;
  92523. private _bone1Quat;
  92524. private _bone1Mat;
  92525. private _bone2Ang;
  92526. private _bone1;
  92527. private _bone2;
  92528. private _bone1Length;
  92529. private _bone2Length;
  92530. private _maxAngle;
  92531. private _maxReach;
  92532. private _rightHandedSystem;
  92533. private _bendAxis;
  92534. private _slerping;
  92535. private _adjustRoll;
  92536. /**
  92537. * Gets or sets maximum allowed angle
  92538. */
  92539. maxAngle: number;
  92540. /**
  92541. * Creates a new BoneIKController
  92542. * @param mesh defines the mesh to control
  92543. * @param bone defines the bone to control
  92544. * @param options defines options to set up the controller
  92545. */
  92546. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92547. targetMesh?: AbstractMesh;
  92548. poleTargetMesh?: AbstractMesh;
  92549. poleTargetBone?: Bone;
  92550. poleTargetLocalOffset?: Vector3;
  92551. poleAngle?: number;
  92552. bendAxis?: Vector3;
  92553. maxAngle?: number;
  92554. slerpAmount?: number;
  92555. });
  92556. private _setMaxAngle;
  92557. /**
  92558. * Force the controller to update the bones
  92559. */
  92560. update(): void;
  92561. }
  92562. }
  92563. declare module BABYLON {
  92564. /**
  92565. * Class used to make a bone look toward a point in space
  92566. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92567. */
  92568. export class BoneLookController {
  92569. private static _tmpVecs;
  92570. private static _tmpQuat;
  92571. private static _tmpMats;
  92572. /**
  92573. * The target Vector3 that the bone will look at
  92574. */
  92575. target: Vector3;
  92576. /**
  92577. * The mesh that the bone is attached to
  92578. */
  92579. mesh: AbstractMesh;
  92580. /**
  92581. * The bone that will be looking to the target
  92582. */
  92583. bone: Bone;
  92584. /**
  92585. * The up axis of the coordinate system that is used when the bone is rotated
  92586. */
  92587. upAxis: Vector3;
  92588. /**
  92589. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92590. */
  92591. upAxisSpace: Space;
  92592. /**
  92593. * Used to make an adjustment to the yaw of the bone
  92594. */
  92595. adjustYaw: number;
  92596. /**
  92597. * Used to make an adjustment to the pitch of the bone
  92598. */
  92599. adjustPitch: number;
  92600. /**
  92601. * Used to make an adjustment to the roll of the bone
  92602. */
  92603. adjustRoll: number;
  92604. /**
  92605. * 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)
  92606. */
  92607. slerpAmount: number;
  92608. private _minYaw;
  92609. private _maxYaw;
  92610. private _minPitch;
  92611. private _maxPitch;
  92612. private _minYawSin;
  92613. private _minYawCos;
  92614. private _maxYawSin;
  92615. private _maxYawCos;
  92616. private _midYawConstraint;
  92617. private _minPitchTan;
  92618. private _maxPitchTan;
  92619. private _boneQuat;
  92620. private _slerping;
  92621. private _transformYawPitch;
  92622. private _transformYawPitchInv;
  92623. private _firstFrameSkipped;
  92624. private _yawRange;
  92625. private _fowardAxis;
  92626. /**
  92627. * Gets or sets the minimum yaw angle that the bone can look to
  92628. */
  92629. minYaw: number;
  92630. /**
  92631. * Gets or sets the maximum yaw angle that the bone can look to
  92632. */
  92633. maxYaw: number;
  92634. /**
  92635. * Gets or sets the minimum pitch angle that the bone can look to
  92636. */
  92637. minPitch: number;
  92638. /**
  92639. * Gets or sets the maximum pitch angle that the bone can look to
  92640. */
  92641. maxPitch: number;
  92642. /**
  92643. * Create a BoneLookController
  92644. * @param mesh the mesh that the bone belongs to
  92645. * @param bone the bone that will be looking to the target
  92646. * @param target the target Vector3 to look at
  92647. * @param options optional settings:
  92648. * * maxYaw: the maximum angle the bone will yaw to
  92649. * * minYaw: the minimum angle the bone will yaw to
  92650. * * maxPitch: the maximum angle the bone will pitch to
  92651. * * minPitch: the minimum angle the bone will yaw to
  92652. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92653. * * upAxis: the up axis of the coordinate system
  92654. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92655. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92656. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92657. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92658. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92659. * * adjustRoll: used to make an adjustment to the roll of the bone
  92660. **/
  92661. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92662. maxYaw?: number;
  92663. minYaw?: number;
  92664. maxPitch?: number;
  92665. minPitch?: number;
  92666. slerpAmount?: number;
  92667. upAxis?: Vector3;
  92668. upAxisSpace?: Space;
  92669. yawAxis?: Vector3;
  92670. pitchAxis?: Vector3;
  92671. adjustYaw?: number;
  92672. adjustPitch?: number;
  92673. adjustRoll?: number;
  92674. });
  92675. /**
  92676. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92677. */
  92678. update(): void;
  92679. private _getAngleDiff;
  92680. private _getAngleBetween;
  92681. private _isAngleBetween;
  92682. }
  92683. }
  92684. declare module BABYLON {
  92685. /**
  92686. * Manage the gamepad inputs to control an arc rotate camera.
  92687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92688. */
  92689. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92690. /**
  92691. * Defines the camera the input is attached to.
  92692. */
  92693. camera: ArcRotateCamera;
  92694. /**
  92695. * Defines the gamepad the input is gathering event from.
  92696. */
  92697. gamepad: Nullable<Gamepad>;
  92698. /**
  92699. * Defines the gamepad rotation sensiblity.
  92700. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92701. */
  92702. gamepadRotationSensibility: number;
  92703. /**
  92704. * Defines the gamepad move sensiblity.
  92705. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92706. */
  92707. gamepadMoveSensibility: number;
  92708. private _onGamepadConnectedObserver;
  92709. private _onGamepadDisconnectedObserver;
  92710. /**
  92711. * Attach the input controls to a specific dom element to get the input from.
  92712. * @param element Defines the element the controls should be listened from
  92713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92714. */
  92715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92716. /**
  92717. * Detach the current controls from the specified dom element.
  92718. * @param element Defines the element to stop listening the inputs from
  92719. */
  92720. detachControl(element: Nullable<HTMLElement>): void;
  92721. /**
  92722. * Update the current camera state depending on the inputs that have been used this frame.
  92723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92724. */
  92725. checkInputs(): void;
  92726. /**
  92727. * Gets the class name of the current intput.
  92728. * @returns the class name
  92729. */
  92730. getClassName(): string;
  92731. /**
  92732. * Get the friendly name associated with the input class.
  92733. * @returns the input friendly name
  92734. */
  92735. getSimpleName(): string;
  92736. }
  92737. }
  92738. declare module BABYLON {
  92739. interface ArcRotateCameraInputsManager {
  92740. /**
  92741. * Add orientation input support to the input manager.
  92742. * @returns the current input manager
  92743. */
  92744. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92745. }
  92746. /**
  92747. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92749. */
  92750. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92751. /**
  92752. * Defines the camera the input is attached to.
  92753. */
  92754. camera: ArcRotateCamera;
  92755. /**
  92756. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92757. */
  92758. alphaCorrection: number;
  92759. /**
  92760. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92761. */
  92762. gammaCorrection: number;
  92763. private _alpha;
  92764. private _gamma;
  92765. private _dirty;
  92766. private _deviceOrientationHandler;
  92767. /**
  92768. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92769. */
  92770. constructor();
  92771. /**
  92772. * Attach the input controls to a specific dom element to get the input from.
  92773. * @param element Defines the element the controls should be listened from
  92774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92775. */
  92776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92777. /** @hidden */
  92778. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92779. /**
  92780. * Update the current camera state depending on the inputs that have been used this frame.
  92781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92782. */
  92783. checkInputs(): void;
  92784. /**
  92785. * Detach the current controls from the specified dom element.
  92786. * @param element Defines the element to stop listening the inputs from
  92787. */
  92788. detachControl(element: Nullable<HTMLElement>): void;
  92789. /**
  92790. * Gets the class name of the current intput.
  92791. * @returns the class name
  92792. */
  92793. getClassName(): string;
  92794. /**
  92795. * Get the friendly name associated with the input class.
  92796. * @returns the input friendly name
  92797. */
  92798. getSimpleName(): string;
  92799. }
  92800. }
  92801. declare module BABYLON {
  92802. /**
  92803. * Listen to mouse events to control the camera.
  92804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92805. */
  92806. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92807. /**
  92808. * Defines the camera the input is attached to.
  92809. */
  92810. camera: FlyCamera;
  92811. /**
  92812. * Defines if touch is enabled. (Default is true.)
  92813. */
  92814. touchEnabled: boolean;
  92815. /**
  92816. * Defines the buttons associated with the input to handle camera rotation.
  92817. */
  92818. buttons: number[];
  92819. /**
  92820. * Assign buttons for Yaw control.
  92821. */
  92822. buttonsYaw: number[];
  92823. /**
  92824. * Assign buttons for Pitch control.
  92825. */
  92826. buttonsPitch: number[];
  92827. /**
  92828. * Assign buttons for Roll control.
  92829. */
  92830. buttonsRoll: number[];
  92831. /**
  92832. * Detect if any button is being pressed while mouse is moved.
  92833. * -1 = Mouse locked.
  92834. * 0 = Left button.
  92835. * 1 = Middle Button.
  92836. * 2 = Right Button.
  92837. */
  92838. activeButton: number;
  92839. /**
  92840. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92841. * Higher values reduce its sensitivity.
  92842. */
  92843. angularSensibility: number;
  92844. private _mousemoveCallback;
  92845. private _observer;
  92846. private _rollObserver;
  92847. private previousPosition;
  92848. private noPreventDefault;
  92849. private element;
  92850. /**
  92851. * Listen to mouse events to control the camera.
  92852. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92854. */
  92855. constructor(touchEnabled?: boolean);
  92856. /**
  92857. * Attach the mouse control to the HTML DOM element.
  92858. * @param element Defines the element that listens to the input events.
  92859. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92860. */
  92861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92862. /**
  92863. * Detach the current controls from the specified dom element.
  92864. * @param element Defines the element to stop listening the inputs from
  92865. */
  92866. detachControl(element: Nullable<HTMLElement>): void;
  92867. /**
  92868. * Gets the class name of the current input.
  92869. * @returns the class name.
  92870. */
  92871. getClassName(): string;
  92872. /**
  92873. * Get the friendly name associated with the input class.
  92874. * @returns the input's friendly name.
  92875. */
  92876. getSimpleName(): string;
  92877. private _pointerInput;
  92878. private _onMouseMove;
  92879. /**
  92880. * Rotate camera by mouse offset.
  92881. */
  92882. private rotateCamera;
  92883. }
  92884. }
  92885. declare module BABYLON {
  92886. /**
  92887. * Default Inputs manager for the FlyCamera.
  92888. * It groups all the default supported inputs for ease of use.
  92889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92890. */
  92891. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92892. /**
  92893. * Instantiates a new FlyCameraInputsManager.
  92894. * @param camera Defines the camera the inputs belong to.
  92895. */
  92896. constructor(camera: FlyCamera);
  92897. /**
  92898. * Add keyboard input support to the input manager.
  92899. * @returns the new FlyCameraKeyboardMoveInput().
  92900. */
  92901. addKeyboard(): FlyCameraInputsManager;
  92902. /**
  92903. * Add mouse input support to the input manager.
  92904. * @param touchEnabled Enable touch screen support.
  92905. * @returns the new FlyCameraMouseInput().
  92906. */
  92907. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92908. }
  92909. }
  92910. declare module BABYLON {
  92911. /**
  92912. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92913. * such as in a 3D Space Shooter or a Flight Simulator.
  92914. */
  92915. export class FlyCamera extends TargetCamera {
  92916. /**
  92917. * Define the collision ellipsoid of the camera.
  92918. * This is helpful for simulating a camera body, like a player's body.
  92919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92920. */
  92921. ellipsoid: Vector3;
  92922. /**
  92923. * Define an offset for the position of the ellipsoid around the camera.
  92924. * This can be helpful if the camera is attached away from the player's body center,
  92925. * such as at its head.
  92926. */
  92927. ellipsoidOffset: Vector3;
  92928. /**
  92929. * Enable or disable collisions of the camera with the rest of the scene objects.
  92930. */
  92931. checkCollisions: boolean;
  92932. /**
  92933. * Enable or disable gravity on the camera.
  92934. */
  92935. applyGravity: boolean;
  92936. /**
  92937. * Define the current direction the camera is moving to.
  92938. */
  92939. cameraDirection: Vector3;
  92940. /**
  92941. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92942. * This overrides and empties cameraRotation.
  92943. */
  92944. rotationQuaternion: Quaternion;
  92945. /**
  92946. * Track Roll to maintain the wanted Rolling when looking around.
  92947. */
  92948. _trackRoll: number;
  92949. /**
  92950. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92951. */
  92952. rollCorrect: number;
  92953. /**
  92954. * Mimic a banked turn, Rolling the camera when Yawing.
  92955. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92956. */
  92957. bankedTurn: boolean;
  92958. /**
  92959. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92960. */
  92961. bankedTurnLimit: number;
  92962. /**
  92963. * Value of 0 disables the banked Roll.
  92964. * Value of 1 is equal to the Yaw angle in radians.
  92965. */
  92966. bankedTurnMultiplier: number;
  92967. /**
  92968. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92969. */
  92970. inputs: FlyCameraInputsManager;
  92971. /**
  92972. * Gets the input sensibility for mouse input.
  92973. * Higher values reduce sensitivity.
  92974. */
  92975. /**
  92976. * Sets the input sensibility for a mouse input.
  92977. * Higher values reduce sensitivity.
  92978. */
  92979. angularSensibility: number;
  92980. /**
  92981. * Get the keys for camera movement forward.
  92982. */
  92983. /**
  92984. * Set the keys for camera movement forward.
  92985. */
  92986. keysForward: number[];
  92987. /**
  92988. * Get the keys for camera movement backward.
  92989. */
  92990. keysBackward: number[];
  92991. /**
  92992. * Get the keys for camera movement up.
  92993. */
  92994. /**
  92995. * Set the keys for camera movement up.
  92996. */
  92997. keysUp: number[];
  92998. /**
  92999. * Get the keys for camera movement down.
  93000. */
  93001. /**
  93002. * Set the keys for camera movement down.
  93003. */
  93004. keysDown: number[];
  93005. /**
  93006. * Get the keys for camera movement left.
  93007. */
  93008. /**
  93009. * Set the keys for camera movement left.
  93010. */
  93011. keysLeft: number[];
  93012. /**
  93013. * Set the keys for camera movement right.
  93014. */
  93015. /**
  93016. * Set the keys for camera movement right.
  93017. */
  93018. keysRight: number[];
  93019. /**
  93020. * Event raised when the camera collides with a mesh in the scene.
  93021. */
  93022. onCollide: (collidedMesh: AbstractMesh) => void;
  93023. private _collider;
  93024. private _needMoveForGravity;
  93025. private _oldPosition;
  93026. private _diffPosition;
  93027. private _newPosition;
  93028. /** @hidden */
  93029. _localDirection: Vector3;
  93030. /** @hidden */
  93031. _transformedDirection: Vector3;
  93032. /**
  93033. * Instantiates a FlyCamera.
  93034. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93035. * such as in a 3D Space Shooter or a Flight Simulator.
  93036. * @param name Define the name of the camera in the scene.
  93037. * @param position Define the starting position of the camera in the scene.
  93038. * @param scene Define the scene the camera belongs to.
  93039. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93040. */
  93041. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93042. /**
  93043. * Attach a control to the HTML DOM element.
  93044. * @param element Defines the element that listens to the input events.
  93045. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93046. */
  93047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93048. /**
  93049. * Detach a control from the HTML DOM element.
  93050. * The camera will stop reacting to that input.
  93051. * @param element Defines the element that listens to the input events.
  93052. */
  93053. detachControl(element: HTMLElement): void;
  93054. private _collisionMask;
  93055. /**
  93056. * Get the mask that the camera ignores in collision events.
  93057. */
  93058. /**
  93059. * Set the mask that the camera ignores in collision events.
  93060. */
  93061. collisionMask: number;
  93062. /** @hidden */
  93063. _collideWithWorld(displacement: Vector3): void;
  93064. /** @hidden */
  93065. private _onCollisionPositionChange;
  93066. /** @hidden */
  93067. _checkInputs(): void;
  93068. /** @hidden */
  93069. _decideIfNeedsToMove(): boolean;
  93070. /** @hidden */
  93071. _updatePosition(): void;
  93072. /**
  93073. * Restore the Roll to its target value at the rate specified.
  93074. * @param rate - Higher means slower restoring.
  93075. * @hidden
  93076. */
  93077. restoreRoll(rate: number): void;
  93078. /**
  93079. * Destroy the camera and release the current resources held by it.
  93080. */
  93081. dispose(): void;
  93082. /**
  93083. * Get the current object class name.
  93084. * @returns the class name.
  93085. */
  93086. getClassName(): string;
  93087. }
  93088. }
  93089. declare module BABYLON {
  93090. /**
  93091. * Listen to keyboard events to control the camera.
  93092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93093. */
  93094. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93095. /**
  93096. * Defines the camera the input is attached to.
  93097. */
  93098. camera: FlyCamera;
  93099. /**
  93100. * The list of keyboard keys used to control the forward move of the camera.
  93101. */
  93102. keysForward: number[];
  93103. /**
  93104. * The list of keyboard keys used to control the backward move of the camera.
  93105. */
  93106. keysBackward: number[];
  93107. /**
  93108. * The list of keyboard keys used to control the forward move of the camera.
  93109. */
  93110. keysUp: number[];
  93111. /**
  93112. * The list of keyboard keys used to control the backward move of the camera.
  93113. */
  93114. keysDown: number[];
  93115. /**
  93116. * The list of keyboard keys used to control the right strafe move of the camera.
  93117. */
  93118. keysRight: number[];
  93119. /**
  93120. * The list of keyboard keys used to control the left strafe move of the camera.
  93121. */
  93122. keysLeft: number[];
  93123. private _keys;
  93124. private _onCanvasBlurObserver;
  93125. private _onKeyboardObserver;
  93126. private _engine;
  93127. private _scene;
  93128. /**
  93129. * Attach the input controls to a specific dom element to get the input from.
  93130. * @param element Defines the element the controls should be listened from
  93131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93132. */
  93133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93134. /**
  93135. * Detach the current controls from the specified dom element.
  93136. * @param element Defines the element to stop listening the inputs from
  93137. */
  93138. detachControl(element: Nullable<HTMLElement>): void;
  93139. /**
  93140. * Gets the class name of the current intput.
  93141. * @returns the class name
  93142. */
  93143. getClassName(): string;
  93144. /** @hidden */
  93145. _onLostFocus(e: FocusEvent): void;
  93146. /**
  93147. * Get the friendly name associated with the input class.
  93148. * @returns the input friendly name
  93149. */
  93150. getSimpleName(): string;
  93151. /**
  93152. * Update the current camera state depending on the inputs that have been used this frame.
  93153. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93154. */
  93155. checkInputs(): void;
  93156. }
  93157. }
  93158. declare module BABYLON {
  93159. /**
  93160. * Manage the mouse wheel inputs to control a follow camera.
  93161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93162. */
  93163. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93164. /**
  93165. * Defines the camera the input is attached to.
  93166. */
  93167. camera: FollowCamera;
  93168. /**
  93169. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93170. */
  93171. axisControlRadius: boolean;
  93172. /**
  93173. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93174. */
  93175. axisControlHeight: boolean;
  93176. /**
  93177. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93178. */
  93179. axisControlRotation: boolean;
  93180. /**
  93181. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93182. * relation to mouseWheel events.
  93183. */
  93184. wheelPrecision: number;
  93185. /**
  93186. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93187. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93188. */
  93189. wheelDeltaPercentage: number;
  93190. private _wheel;
  93191. private _observer;
  93192. /**
  93193. * Attach the input controls to a specific dom element to get the input from.
  93194. * @param element Defines the element the controls should be listened from
  93195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93196. */
  93197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93198. /**
  93199. * Detach the current controls from the specified dom element.
  93200. * @param element Defines the element to stop listening the inputs from
  93201. */
  93202. detachControl(element: Nullable<HTMLElement>): void;
  93203. /**
  93204. * Gets the class name of the current intput.
  93205. * @returns the class name
  93206. */
  93207. getClassName(): string;
  93208. /**
  93209. * Get the friendly name associated with the input class.
  93210. * @returns the input friendly name
  93211. */
  93212. getSimpleName(): string;
  93213. }
  93214. }
  93215. declare module BABYLON {
  93216. /**
  93217. * Manage the pointers inputs to control an follow camera.
  93218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93219. */
  93220. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93221. /**
  93222. * Defines the camera the input is attached to.
  93223. */
  93224. camera: FollowCamera;
  93225. /**
  93226. * Gets the class name of the current input.
  93227. * @returns the class name
  93228. */
  93229. getClassName(): string;
  93230. /**
  93231. * Defines the pointer angular sensibility along the X axis or how fast is
  93232. * the camera rotating.
  93233. * A negative number will reverse the axis direction.
  93234. */
  93235. angularSensibilityX: number;
  93236. /**
  93237. * Defines the pointer angular sensibility along the Y axis or how fast is
  93238. * the camera rotating.
  93239. * A negative number will reverse the axis direction.
  93240. */
  93241. angularSensibilityY: number;
  93242. /**
  93243. * Defines the pointer pinch precision or how fast is the camera zooming.
  93244. * A negative number will reverse the axis direction.
  93245. */
  93246. pinchPrecision: number;
  93247. /**
  93248. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93249. * from 0.
  93250. * It defines the percentage of current camera.radius to use as delta when
  93251. * pinch zoom is used.
  93252. */
  93253. pinchDeltaPercentage: number;
  93254. /**
  93255. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93256. */
  93257. axisXControlRadius: boolean;
  93258. /**
  93259. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93260. */
  93261. axisXControlHeight: boolean;
  93262. /**
  93263. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93264. */
  93265. axisXControlRotation: boolean;
  93266. /**
  93267. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93268. */
  93269. axisYControlRadius: boolean;
  93270. /**
  93271. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93272. */
  93273. axisYControlHeight: boolean;
  93274. /**
  93275. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93276. */
  93277. axisYControlRotation: boolean;
  93278. /**
  93279. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93280. */
  93281. axisPinchControlRadius: boolean;
  93282. /**
  93283. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93284. */
  93285. axisPinchControlHeight: boolean;
  93286. /**
  93287. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93288. */
  93289. axisPinchControlRotation: boolean;
  93290. /**
  93291. * Log error messages if basic misconfiguration has occurred.
  93292. */
  93293. warningEnable: boolean;
  93294. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93295. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93296. private _warningCounter;
  93297. private _warning;
  93298. }
  93299. }
  93300. declare module BABYLON {
  93301. /**
  93302. * Default Inputs manager for the FollowCamera.
  93303. * It groups all the default supported inputs for ease of use.
  93304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93305. */
  93306. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93307. /**
  93308. * Instantiates a new FollowCameraInputsManager.
  93309. * @param camera Defines the camera the inputs belong to
  93310. */
  93311. constructor(camera: FollowCamera);
  93312. /**
  93313. * Add keyboard input support to the input manager.
  93314. * @returns the current input manager
  93315. */
  93316. addKeyboard(): FollowCameraInputsManager;
  93317. /**
  93318. * Add mouse wheel input support to the input manager.
  93319. * @returns the current input manager
  93320. */
  93321. addMouseWheel(): FollowCameraInputsManager;
  93322. /**
  93323. * Add pointers input support to the input manager.
  93324. * @returns the current input manager
  93325. */
  93326. addPointers(): FollowCameraInputsManager;
  93327. /**
  93328. * Add orientation input support to the input manager.
  93329. * @returns the current input manager
  93330. */
  93331. addVRDeviceOrientation(): FollowCameraInputsManager;
  93332. }
  93333. }
  93334. declare module BABYLON {
  93335. /**
  93336. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93337. * an arc rotate version arcFollowCamera are available.
  93338. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93339. */
  93340. export class FollowCamera extends TargetCamera {
  93341. /**
  93342. * Distance the follow camera should follow an object at
  93343. */
  93344. radius: number;
  93345. /**
  93346. * Minimum allowed distance of the camera to the axis of rotation
  93347. * (The camera can not get closer).
  93348. * This can help limiting how the Camera is able to move in the scene.
  93349. */
  93350. lowerRadiusLimit: Nullable<number>;
  93351. /**
  93352. * Maximum allowed distance of the camera to the axis of rotation
  93353. * (The camera can not get further).
  93354. * This can help limiting how the Camera is able to move in the scene.
  93355. */
  93356. upperRadiusLimit: Nullable<number>;
  93357. /**
  93358. * Define a rotation offset between the camera and the object it follows
  93359. */
  93360. rotationOffset: number;
  93361. /**
  93362. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  93366. /**
  93367. * Maximum allowed angle to camera position relative to target object.
  93368. * This can help limiting how the Camera is able to move in the scene.
  93369. */
  93370. upperRotationOffsetLimit: Nullable<number>;
  93371. /**
  93372. * Define a height offset between the camera and the object it follows.
  93373. * It can help following an object from the top (like a car chaing a plane)
  93374. */
  93375. heightOffset: number;
  93376. /**
  93377. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  93381. /**
  93382. * Maximum allowed height of camera position relative to target object.
  93383. * This can help limiting how the Camera is able to move in the scene.
  93384. */
  93385. upperHeightOffsetLimit: Nullable<number>;
  93386. /**
  93387. * Define how fast the camera can accelerate to follow it s target.
  93388. */
  93389. cameraAcceleration: number;
  93390. /**
  93391. * Define the speed limit of the camera following an object.
  93392. */
  93393. maxCameraSpeed: number;
  93394. /**
  93395. * Define the target of the camera.
  93396. */
  93397. lockedTarget: Nullable<AbstractMesh>;
  93398. /**
  93399. * Defines the input associated with the camera.
  93400. */
  93401. inputs: FollowCameraInputsManager;
  93402. /**
  93403. * Instantiates the follow camera.
  93404. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93405. * @param name Define the name of the camera in the scene
  93406. * @param position Define the position of the camera
  93407. * @param scene Define the scene the camera belong to
  93408. * @param lockedTarget Define the target of the camera
  93409. */
  93410. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93411. private _follow;
  93412. /**
  93413. * Attached controls to the current camera.
  93414. * @param element Defines the element the controls should be listened from
  93415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93416. */
  93417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93418. /**
  93419. * Detach the current controls from the camera.
  93420. * The camera will stop reacting to inputs.
  93421. * @param element Defines the element to stop listening the inputs from
  93422. */
  93423. detachControl(element: HTMLElement): void;
  93424. /** @hidden */
  93425. _checkInputs(): void;
  93426. private _checkLimits;
  93427. /**
  93428. * Gets the camera class name.
  93429. * @returns the class name
  93430. */
  93431. getClassName(): string;
  93432. }
  93433. /**
  93434. * Arc Rotate version of the follow camera.
  93435. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93436. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93437. */
  93438. export class ArcFollowCamera extends TargetCamera {
  93439. /** The longitudinal angle of the camera */
  93440. alpha: number;
  93441. /** The latitudinal angle of the camera */
  93442. beta: number;
  93443. /** The radius of the camera from its target */
  93444. radius: number;
  93445. /** Define the camera target (the messh it should follow) */
  93446. target: Nullable<AbstractMesh>;
  93447. private _cartesianCoordinates;
  93448. /**
  93449. * Instantiates a new ArcFollowCamera
  93450. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93451. * @param name Define the name of the camera
  93452. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93453. * @param beta Define the rotation angle of the camera around the elevation axis
  93454. * @param radius Define the radius of the camera from its target point
  93455. * @param target Define the target of the camera
  93456. * @param scene Define the scene the camera belongs to
  93457. */
  93458. constructor(name: string,
  93459. /** The longitudinal angle of the camera */
  93460. alpha: number,
  93461. /** The latitudinal angle of the camera */
  93462. beta: number,
  93463. /** The radius of the camera from its target */
  93464. radius: number,
  93465. /** Define the camera target (the messh it should follow) */
  93466. target: Nullable<AbstractMesh>, scene: Scene);
  93467. private _follow;
  93468. /** @hidden */
  93469. _checkInputs(): void;
  93470. /**
  93471. * Returns the class name of the object.
  93472. * It is mostly used internally for serialization purposes.
  93473. */
  93474. getClassName(): string;
  93475. }
  93476. }
  93477. declare module BABYLON {
  93478. /**
  93479. * Manage the keyboard inputs to control the movement of a follow camera.
  93480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93481. */
  93482. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93483. /**
  93484. * Defines the camera the input is attached to.
  93485. */
  93486. camera: FollowCamera;
  93487. /**
  93488. * Defines the list of key codes associated with the up action (increase heightOffset)
  93489. */
  93490. keysHeightOffsetIncr: number[];
  93491. /**
  93492. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93493. */
  93494. keysHeightOffsetDecr: number[];
  93495. /**
  93496. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93497. */
  93498. keysHeightOffsetModifierAlt: boolean;
  93499. /**
  93500. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93501. */
  93502. keysHeightOffsetModifierCtrl: boolean;
  93503. /**
  93504. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93505. */
  93506. keysHeightOffsetModifierShift: boolean;
  93507. /**
  93508. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93509. */
  93510. keysRotationOffsetIncr: number[];
  93511. /**
  93512. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93513. */
  93514. keysRotationOffsetDecr: number[];
  93515. /**
  93516. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93517. */
  93518. keysRotationOffsetModifierAlt: boolean;
  93519. /**
  93520. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93521. */
  93522. keysRotationOffsetModifierCtrl: boolean;
  93523. /**
  93524. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93525. */
  93526. keysRotationOffsetModifierShift: boolean;
  93527. /**
  93528. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93529. */
  93530. keysRadiusIncr: number[];
  93531. /**
  93532. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93533. */
  93534. keysRadiusDecr: number[];
  93535. /**
  93536. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93537. */
  93538. keysRadiusModifierAlt: boolean;
  93539. /**
  93540. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93541. */
  93542. keysRadiusModifierCtrl: boolean;
  93543. /**
  93544. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93545. */
  93546. keysRadiusModifierShift: boolean;
  93547. /**
  93548. * Defines the rate of change of heightOffset.
  93549. */
  93550. heightSensibility: number;
  93551. /**
  93552. * Defines the rate of change of rotationOffset.
  93553. */
  93554. rotationSensibility: number;
  93555. /**
  93556. * Defines the rate of change of radius.
  93557. */
  93558. radiusSensibility: number;
  93559. private _keys;
  93560. private _ctrlPressed;
  93561. private _altPressed;
  93562. private _shiftPressed;
  93563. private _onCanvasBlurObserver;
  93564. private _onKeyboardObserver;
  93565. private _engine;
  93566. private _scene;
  93567. /**
  93568. * Attach the input controls to a specific dom element to get the input from.
  93569. * @param element Defines the element the controls should be listened from
  93570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93571. */
  93572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93573. /**
  93574. * Detach the current controls from the specified dom element.
  93575. * @param element Defines the element to stop listening the inputs from
  93576. */
  93577. detachControl(element: Nullable<HTMLElement>): void;
  93578. /**
  93579. * Update the current camera state depending on the inputs that have been used this frame.
  93580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93581. */
  93582. checkInputs(): void;
  93583. /**
  93584. * Gets the class name of the current input.
  93585. * @returns the class name
  93586. */
  93587. getClassName(): string;
  93588. /**
  93589. * Get the friendly name associated with the input class.
  93590. * @returns the input friendly name
  93591. */
  93592. getSimpleName(): string;
  93593. /**
  93594. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93595. * allow modification of the heightOffset value.
  93596. */
  93597. private _modifierHeightOffset;
  93598. /**
  93599. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93600. * allow modification of the rotationOffset value.
  93601. */
  93602. private _modifierRotationOffset;
  93603. /**
  93604. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93605. * allow modification of the radius value.
  93606. */
  93607. private _modifierRadius;
  93608. }
  93609. }
  93610. declare module BABYLON {
  93611. interface FreeCameraInputsManager {
  93612. /**
  93613. * Add orientation input support to the input manager.
  93614. * @returns the current input manager
  93615. */
  93616. addDeviceOrientation(): FreeCameraInputsManager;
  93617. }
  93618. /**
  93619. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93620. * Screen rotation is taken into account.
  93621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93622. */
  93623. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93624. private _camera;
  93625. private _screenOrientationAngle;
  93626. private _constantTranform;
  93627. private _screenQuaternion;
  93628. private _alpha;
  93629. private _beta;
  93630. private _gamma;
  93631. /**
  93632. * Instantiates a new input
  93633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93634. */
  93635. constructor();
  93636. /**
  93637. * Define the camera controlled by the input.
  93638. */
  93639. camera: FreeCamera;
  93640. /**
  93641. * Attach the input controls to a specific dom element to get the input from.
  93642. * @param element Defines the element the controls should be listened from
  93643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93644. */
  93645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93646. private _orientationChanged;
  93647. private _deviceOrientation;
  93648. /**
  93649. * Detach the current controls from the specified dom element.
  93650. * @param element Defines the element to stop listening the inputs from
  93651. */
  93652. detachControl(element: Nullable<HTMLElement>): void;
  93653. /**
  93654. * Update the current camera state depending on the inputs that have been used this frame.
  93655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93656. */
  93657. checkInputs(): void;
  93658. /**
  93659. * Gets the class name of the current intput.
  93660. * @returns the class name
  93661. */
  93662. getClassName(): string;
  93663. /**
  93664. * Get the friendly name associated with the input class.
  93665. * @returns the input friendly name
  93666. */
  93667. getSimpleName(): string;
  93668. }
  93669. }
  93670. declare module BABYLON {
  93671. /**
  93672. * Manage the gamepad inputs to control a free camera.
  93673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93674. */
  93675. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93676. /**
  93677. * Define the camera the input is attached to.
  93678. */
  93679. camera: FreeCamera;
  93680. /**
  93681. * Define the Gamepad controlling the input
  93682. */
  93683. gamepad: Nullable<Gamepad>;
  93684. /**
  93685. * Defines the gamepad rotation sensiblity.
  93686. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93687. */
  93688. gamepadAngularSensibility: number;
  93689. /**
  93690. * Defines the gamepad move sensiblity.
  93691. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93692. */
  93693. gamepadMoveSensibility: number;
  93694. private _onGamepadConnectedObserver;
  93695. private _onGamepadDisconnectedObserver;
  93696. private _cameraTransform;
  93697. private _deltaTransform;
  93698. private _vector3;
  93699. private _vector2;
  93700. /**
  93701. * Attach the input controls to a specific dom element to get the input from.
  93702. * @param element Defines the element the controls should be listened from
  93703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93704. */
  93705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93706. /**
  93707. * Detach the current controls from the specified dom element.
  93708. * @param element Defines the element to stop listening the inputs from
  93709. */
  93710. detachControl(element: Nullable<HTMLElement>): void;
  93711. /**
  93712. * Update the current camera state depending on the inputs that have been used this frame.
  93713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93714. */
  93715. checkInputs(): void;
  93716. /**
  93717. * Gets the class name of the current intput.
  93718. * @returns the class name
  93719. */
  93720. getClassName(): string;
  93721. /**
  93722. * Get the friendly name associated with the input class.
  93723. * @returns the input friendly name
  93724. */
  93725. getSimpleName(): string;
  93726. }
  93727. }
  93728. declare module BABYLON {
  93729. /**
  93730. * Defines the potential axis of a Joystick
  93731. */
  93732. export enum JoystickAxis {
  93733. /** X axis */
  93734. X = 0,
  93735. /** Y axis */
  93736. Y = 1,
  93737. /** Z axis */
  93738. Z = 2
  93739. }
  93740. /**
  93741. * Class used to define virtual joystick (used in touch mode)
  93742. */
  93743. export class VirtualJoystick {
  93744. /**
  93745. * Gets or sets a boolean indicating that left and right values must be inverted
  93746. */
  93747. reverseLeftRight: boolean;
  93748. /**
  93749. * Gets or sets a boolean indicating that up and down values must be inverted
  93750. */
  93751. reverseUpDown: boolean;
  93752. /**
  93753. * Gets the offset value for the position (ie. the change of the position value)
  93754. */
  93755. deltaPosition: Vector3;
  93756. /**
  93757. * Gets a boolean indicating if the virtual joystick was pressed
  93758. */
  93759. pressed: boolean;
  93760. /**
  93761. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93762. */
  93763. static Canvas: Nullable<HTMLCanvasElement>;
  93764. private static _globalJoystickIndex;
  93765. private static vjCanvasContext;
  93766. private static vjCanvasWidth;
  93767. private static vjCanvasHeight;
  93768. private static halfWidth;
  93769. private _action;
  93770. private _axisTargetedByLeftAndRight;
  93771. private _axisTargetedByUpAndDown;
  93772. private _joystickSensibility;
  93773. private _inversedSensibility;
  93774. private _joystickPointerID;
  93775. private _joystickColor;
  93776. private _joystickPointerPos;
  93777. private _joystickPreviousPointerPos;
  93778. private _joystickPointerStartPos;
  93779. private _deltaJoystickVector;
  93780. private _leftJoystick;
  93781. private _touches;
  93782. private _onPointerDownHandlerRef;
  93783. private _onPointerMoveHandlerRef;
  93784. private _onPointerUpHandlerRef;
  93785. private _onResize;
  93786. /**
  93787. * Creates a new virtual joystick
  93788. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93789. */
  93790. constructor(leftJoystick?: boolean);
  93791. /**
  93792. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  93793. * @param newJoystickSensibility defines the new sensibility
  93794. */
  93795. setJoystickSensibility(newJoystickSensibility: number): void;
  93796. private _onPointerDown;
  93797. private _onPointerMove;
  93798. private _onPointerUp;
  93799. /**
  93800. * Change the color of the virtual joystick
  93801. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  93802. */
  93803. setJoystickColor(newColor: string): void;
  93804. /**
  93805. * Defines a callback to call when the joystick is touched
  93806. * @param action defines the callback
  93807. */
  93808. setActionOnTouch(action: () => any): void;
  93809. /**
  93810. * Defines which axis you'd like to control for left & right
  93811. * @param axis defines the axis to use
  93812. */
  93813. setAxisForLeftRight(axis: JoystickAxis): void;
  93814. /**
  93815. * Defines which axis you'd like to control for up & down
  93816. * @param axis defines the axis to use
  93817. */
  93818. setAxisForUpDown(axis: JoystickAxis): void;
  93819. private _drawVirtualJoystick;
  93820. /**
  93821. * Release internal HTML canvas
  93822. */
  93823. releaseCanvas(): void;
  93824. }
  93825. }
  93826. declare module BABYLON {
  93827. interface FreeCameraInputsManager {
  93828. /**
  93829. * Add virtual joystick input support to the input manager.
  93830. * @returns the current input manager
  93831. */
  93832. addVirtualJoystick(): FreeCameraInputsManager;
  93833. }
  93834. /**
  93835. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  93836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93837. */
  93838. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  93839. /**
  93840. * Defines the camera the input is attached to.
  93841. */
  93842. camera: FreeCamera;
  93843. private _leftjoystick;
  93844. private _rightjoystick;
  93845. /**
  93846. * Gets the left stick of the virtual joystick.
  93847. * @returns The virtual Joystick
  93848. */
  93849. getLeftJoystick(): VirtualJoystick;
  93850. /**
  93851. * Gets the right stick of the virtual joystick.
  93852. * @returns The virtual Joystick
  93853. */
  93854. getRightJoystick(): VirtualJoystick;
  93855. /**
  93856. * Update the current camera state depending on the inputs that have been used this frame.
  93857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93858. */
  93859. checkInputs(): void;
  93860. /**
  93861. * Attach the input controls to a specific dom element to get the input from.
  93862. * @param element Defines the element the controls should be listened from
  93863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93864. */
  93865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93866. /**
  93867. * Detach the current controls from the specified dom element.
  93868. * @param element Defines the element to stop listening the inputs from
  93869. */
  93870. detachControl(element: Nullable<HTMLElement>): void;
  93871. /**
  93872. * Gets the class name of the current intput.
  93873. * @returns the class name
  93874. */
  93875. getClassName(): string;
  93876. /**
  93877. * Get the friendly name associated with the input class.
  93878. * @returns the input friendly name
  93879. */
  93880. getSimpleName(): string;
  93881. }
  93882. }
  93883. declare module BABYLON {
  93884. /**
  93885. * This represents a FPS type of camera controlled by touch.
  93886. * This is like a universal camera minus the Gamepad controls.
  93887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93888. */
  93889. export class TouchCamera extends FreeCamera {
  93890. /**
  93891. * Defines the touch sensibility for rotation.
  93892. * The higher the faster.
  93893. */
  93894. touchAngularSensibility: number;
  93895. /**
  93896. * Defines the touch sensibility for move.
  93897. * The higher the faster.
  93898. */
  93899. touchMoveSensibility: number;
  93900. /**
  93901. * Instantiates a new touch camera.
  93902. * This represents a FPS type of camera controlled by touch.
  93903. * This is like a universal camera minus the Gamepad controls.
  93904. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93905. * @param name Define the name of the camera in the scene
  93906. * @param position Define the start position of the camera in the scene
  93907. * @param scene Define the scene the camera belongs to
  93908. */
  93909. constructor(name: string, position: Vector3, scene: Scene);
  93910. /**
  93911. * Gets the current object class name.
  93912. * @return the class name
  93913. */
  93914. getClassName(): string;
  93915. /** @hidden */
  93916. _setupInputs(): void;
  93917. }
  93918. }
  93919. declare module BABYLON {
  93920. /**
  93921. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  93922. * being tilted forward or back and left or right.
  93923. */
  93924. export class DeviceOrientationCamera extends FreeCamera {
  93925. private _initialQuaternion;
  93926. private _quaternionCache;
  93927. /**
  93928. * Creates a new device orientation camera
  93929. * @param name The name of the camera
  93930. * @param position The start position camera
  93931. * @param scene The scene the camera belongs to
  93932. */
  93933. constructor(name: string, position: Vector3, scene: Scene);
  93934. /**
  93935. * Gets the current instance class name ("DeviceOrientationCamera").
  93936. * This helps avoiding instanceof at run time.
  93937. * @returns the class name
  93938. */
  93939. getClassName(): string;
  93940. /**
  93941. * @hidden
  93942. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  93943. */
  93944. _checkInputs(): void;
  93945. /**
  93946. * Reset the camera to its default orientation on the specified axis only.
  93947. * @param axis The axis to reset
  93948. */
  93949. resetToCurrentRotation(axis?: Axis): void;
  93950. }
  93951. }
  93952. declare module BABYLON {
  93953. /**
  93954. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  93955. * which still works and will still be found in many Playgrounds.
  93956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93957. */
  93958. export class UniversalCamera extends TouchCamera {
  93959. /**
  93960. * Defines the gamepad rotation sensiblity.
  93961. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93962. */
  93963. gamepadAngularSensibility: number;
  93964. /**
  93965. * Defines the gamepad move sensiblity.
  93966. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93967. */
  93968. gamepadMoveSensibility: number;
  93969. /**
  93970. * 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,
  93971. * which still works and will still be found in many Playgrounds.
  93972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93973. * @param name Define the name of the camera in the scene
  93974. * @param position Define the start position of the camera in the scene
  93975. * @param scene Define the scene the camera belongs to
  93976. */
  93977. constructor(name: string, position: Vector3, scene: Scene);
  93978. /**
  93979. * Gets the current object class name.
  93980. * @return the class name
  93981. */
  93982. getClassName(): string;
  93983. }
  93984. }
  93985. declare module BABYLON {
  93986. /**
  93987. * This represents a FPS type of camera. This is only here for back compat purpose.
  93988. * Please use the UniversalCamera instead as both are identical.
  93989. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93990. */
  93991. export class GamepadCamera extends UniversalCamera {
  93992. /**
  93993. * Instantiates a new Gamepad Camera
  93994. * This represents a FPS type of camera. This is only here for back compat purpose.
  93995. * Please use the UniversalCamera instead as both are identical.
  93996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93997. * @param name Define the name of the camera in the scene
  93998. * @param position Define the start position of the camera in the scene
  93999. * @param scene Define the scene the camera belongs to
  94000. */
  94001. constructor(name: string, position: Vector3, scene: Scene);
  94002. /**
  94003. * Gets the current object class name.
  94004. * @return the class name
  94005. */
  94006. getClassName(): string;
  94007. }
  94008. }
  94009. declare module BABYLON {
  94010. /** @hidden */
  94011. export var passPixelShader: {
  94012. name: string;
  94013. shader: string;
  94014. };
  94015. }
  94016. declare module BABYLON {
  94017. /** @hidden */
  94018. export var passCubePixelShader: {
  94019. name: string;
  94020. shader: string;
  94021. };
  94022. }
  94023. declare module BABYLON {
  94024. /**
  94025. * PassPostProcess which produces an output the same as it's input
  94026. */
  94027. export class PassPostProcess extends PostProcess {
  94028. /**
  94029. * Creates the PassPostProcess
  94030. * @param name The name of the effect.
  94031. * @param options The required width/height ratio to downsize to before computing the render pass.
  94032. * @param camera The camera to apply the render pass to.
  94033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94034. * @param engine The engine which the post process will be applied. (default: current engine)
  94035. * @param reusable If the post process can be reused on the same frame. (default: false)
  94036. * @param textureType The type of texture to be used when performing the post processing.
  94037. * @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)
  94038. */
  94039. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94040. }
  94041. /**
  94042. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94043. */
  94044. export class PassCubePostProcess extends PostProcess {
  94045. private _face;
  94046. /**
  94047. * Gets or sets the cube face to display.
  94048. * * 0 is +X
  94049. * * 1 is -X
  94050. * * 2 is +Y
  94051. * * 3 is -Y
  94052. * * 4 is +Z
  94053. * * 5 is -Z
  94054. */
  94055. face: number;
  94056. /**
  94057. * Creates the PassCubePostProcess
  94058. * @param name The name of the effect.
  94059. * @param options The required width/height ratio to downsize to before computing the render pass.
  94060. * @param camera The camera to apply the render pass to.
  94061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94062. * @param engine The engine which the post process will be applied. (default: current engine)
  94063. * @param reusable If the post process can be reused on the same frame. (default: false)
  94064. * @param textureType The type of texture to be used when performing the post processing.
  94065. * @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)
  94066. */
  94067. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94068. }
  94069. }
  94070. declare module BABYLON {
  94071. /** @hidden */
  94072. export var anaglyphPixelShader: {
  94073. name: string;
  94074. shader: string;
  94075. };
  94076. }
  94077. declare module BABYLON {
  94078. /**
  94079. * Postprocess used to generate anaglyphic rendering
  94080. */
  94081. export class AnaglyphPostProcess extends PostProcess {
  94082. private _passedProcess;
  94083. /**
  94084. * Creates a new AnaglyphPostProcess
  94085. * @param name defines postprocess name
  94086. * @param options defines creation options or target ratio scale
  94087. * @param rigCameras defines cameras using this postprocess
  94088. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94089. * @param engine defines hosting engine
  94090. * @param reusable defines if the postprocess will be reused multiple times per frame
  94091. */
  94092. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94093. }
  94094. }
  94095. declare module BABYLON {
  94096. /**
  94097. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94098. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94099. */
  94100. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94101. /**
  94102. * Creates a new AnaglyphArcRotateCamera
  94103. * @param name defines camera name
  94104. * @param alpha defines alpha angle (in radians)
  94105. * @param beta defines beta angle (in radians)
  94106. * @param radius defines radius
  94107. * @param target defines camera target
  94108. * @param interaxialDistance defines distance between each color axis
  94109. * @param scene defines the hosting scene
  94110. */
  94111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94112. /**
  94113. * Gets camera class name
  94114. * @returns AnaglyphArcRotateCamera
  94115. */
  94116. getClassName(): string;
  94117. }
  94118. }
  94119. declare module BABYLON {
  94120. /**
  94121. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94122. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94123. */
  94124. export class AnaglyphFreeCamera extends FreeCamera {
  94125. /**
  94126. * Creates a new AnaglyphFreeCamera
  94127. * @param name defines camera name
  94128. * @param position defines initial position
  94129. * @param interaxialDistance defines distance between each color axis
  94130. * @param scene defines the hosting scene
  94131. */
  94132. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94133. /**
  94134. * Gets camera class name
  94135. * @returns AnaglyphFreeCamera
  94136. */
  94137. getClassName(): string;
  94138. }
  94139. }
  94140. declare module BABYLON {
  94141. /**
  94142. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94143. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94144. */
  94145. export class AnaglyphGamepadCamera extends GamepadCamera {
  94146. /**
  94147. * Creates a new AnaglyphGamepadCamera
  94148. * @param name defines camera name
  94149. * @param position defines initial position
  94150. * @param interaxialDistance defines distance between each color axis
  94151. * @param scene defines the hosting scene
  94152. */
  94153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94154. /**
  94155. * Gets camera class name
  94156. * @returns AnaglyphGamepadCamera
  94157. */
  94158. getClassName(): string;
  94159. }
  94160. }
  94161. declare module BABYLON {
  94162. /**
  94163. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94164. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94165. */
  94166. export class AnaglyphUniversalCamera extends UniversalCamera {
  94167. /**
  94168. * Creates a new AnaglyphUniversalCamera
  94169. * @param name defines camera name
  94170. * @param position defines initial position
  94171. * @param interaxialDistance defines distance between each color axis
  94172. * @param scene defines the hosting scene
  94173. */
  94174. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94175. /**
  94176. * Gets camera class name
  94177. * @returns AnaglyphUniversalCamera
  94178. */
  94179. getClassName(): string;
  94180. }
  94181. }
  94182. declare module BABYLON {
  94183. /** @hidden */
  94184. export var stereoscopicInterlacePixelShader: {
  94185. name: string;
  94186. shader: string;
  94187. };
  94188. }
  94189. declare module BABYLON {
  94190. /**
  94191. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94192. */
  94193. export class StereoscopicInterlacePostProcess extends PostProcess {
  94194. private _stepSize;
  94195. private _passedProcess;
  94196. /**
  94197. * Initializes a StereoscopicInterlacePostProcess
  94198. * @param name The name of the effect.
  94199. * @param rigCameras The rig cameras to be appled to the post process
  94200. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94202. * @param engine The engine which the post process will be applied. (default: current engine)
  94203. * @param reusable If the post process can be reused on the same frame. (default: false)
  94204. */
  94205. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94206. }
  94207. }
  94208. declare module BABYLON {
  94209. /**
  94210. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94211. * @see http://doc.babylonjs.com/features/cameras
  94212. */
  94213. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94214. /**
  94215. * Creates a new StereoscopicArcRotateCamera
  94216. * @param name defines camera name
  94217. * @param alpha defines alpha angle (in radians)
  94218. * @param beta defines beta angle (in radians)
  94219. * @param radius defines radius
  94220. * @param target defines camera target
  94221. * @param interaxialDistance defines distance between each color axis
  94222. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94223. * @param scene defines the hosting scene
  94224. */
  94225. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94226. /**
  94227. * Gets camera class name
  94228. * @returns StereoscopicArcRotateCamera
  94229. */
  94230. getClassName(): string;
  94231. }
  94232. }
  94233. declare module BABYLON {
  94234. /**
  94235. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94236. * @see http://doc.babylonjs.com/features/cameras
  94237. */
  94238. export class StereoscopicFreeCamera extends FreeCamera {
  94239. /**
  94240. * Creates a new StereoscopicFreeCamera
  94241. * @param name defines camera name
  94242. * @param position defines initial position
  94243. * @param interaxialDistance defines distance between each color axis
  94244. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94245. * @param scene defines the hosting scene
  94246. */
  94247. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94248. /**
  94249. * Gets camera class name
  94250. * @returns StereoscopicFreeCamera
  94251. */
  94252. getClassName(): string;
  94253. }
  94254. }
  94255. declare module BABYLON {
  94256. /**
  94257. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94258. * @see http://doc.babylonjs.com/features/cameras
  94259. */
  94260. export class StereoscopicGamepadCamera extends GamepadCamera {
  94261. /**
  94262. * Creates a new StereoscopicGamepadCamera
  94263. * @param name defines camera name
  94264. * @param position defines initial position
  94265. * @param interaxialDistance defines distance between each color axis
  94266. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94267. * @param scene defines the hosting scene
  94268. */
  94269. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94270. /**
  94271. * Gets camera class name
  94272. * @returns StereoscopicGamepadCamera
  94273. */
  94274. getClassName(): string;
  94275. }
  94276. }
  94277. declare module BABYLON {
  94278. /**
  94279. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94280. * @see http://doc.babylonjs.com/features/cameras
  94281. */
  94282. export class StereoscopicUniversalCamera extends UniversalCamera {
  94283. /**
  94284. * Creates a new StereoscopicUniversalCamera
  94285. * @param name defines camera name
  94286. * @param position defines initial position
  94287. * @param interaxialDistance defines distance between each color axis
  94288. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94289. * @param scene defines the hosting scene
  94290. */
  94291. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94292. /**
  94293. * Gets camera class name
  94294. * @returns StereoscopicUniversalCamera
  94295. */
  94296. getClassName(): string;
  94297. }
  94298. }
  94299. declare module BABYLON {
  94300. /**
  94301. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94302. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94303. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94304. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94305. */
  94306. export class VirtualJoysticksCamera extends FreeCamera {
  94307. /**
  94308. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94309. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94310. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94311. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94312. * @param name Define the name of the camera in the scene
  94313. * @param position Define the start position of the camera in the scene
  94314. * @param scene Define the scene the camera belongs to
  94315. */
  94316. constructor(name: string, position: Vector3, scene: Scene);
  94317. /**
  94318. * Gets the current object class name.
  94319. * @return the class name
  94320. */
  94321. getClassName(): string;
  94322. }
  94323. }
  94324. declare module BABYLON {
  94325. /**
  94326. * This represents all the required metrics to create a VR camera.
  94327. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94328. */
  94329. export class VRCameraMetrics {
  94330. /**
  94331. * Define the horizontal resolution off the screen.
  94332. */
  94333. hResolution: number;
  94334. /**
  94335. * Define the vertical resolution off the screen.
  94336. */
  94337. vResolution: number;
  94338. /**
  94339. * Define the horizontal screen size.
  94340. */
  94341. hScreenSize: number;
  94342. /**
  94343. * Define the vertical screen size.
  94344. */
  94345. vScreenSize: number;
  94346. /**
  94347. * Define the vertical screen center position.
  94348. */
  94349. vScreenCenter: number;
  94350. /**
  94351. * Define the distance of the eyes to the screen.
  94352. */
  94353. eyeToScreenDistance: number;
  94354. /**
  94355. * Define the distance between both lenses
  94356. */
  94357. lensSeparationDistance: number;
  94358. /**
  94359. * Define the distance between both viewer's eyes.
  94360. */
  94361. interpupillaryDistance: number;
  94362. /**
  94363. * Define the distortion factor of the VR postprocess.
  94364. * Please, touch with care.
  94365. */
  94366. distortionK: number[];
  94367. /**
  94368. * Define the chromatic aberration correction factors for the VR post process.
  94369. */
  94370. chromaAbCorrection: number[];
  94371. /**
  94372. * Define the scale factor of the post process.
  94373. * The smaller the better but the slower.
  94374. */
  94375. postProcessScaleFactor: number;
  94376. /**
  94377. * Define an offset for the lens center.
  94378. */
  94379. lensCenterOffset: number;
  94380. /**
  94381. * Define if the current vr camera should compensate the distortion of the lense or not.
  94382. */
  94383. compensateDistortion: boolean;
  94384. /**
  94385. * Gets the rendering aspect ratio based on the provided resolutions.
  94386. */
  94387. readonly aspectRatio: number;
  94388. /**
  94389. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94390. */
  94391. readonly aspectRatioFov: number;
  94392. /**
  94393. * @hidden
  94394. */
  94395. readonly leftHMatrix: Matrix;
  94396. /**
  94397. * @hidden
  94398. */
  94399. readonly rightHMatrix: Matrix;
  94400. /**
  94401. * @hidden
  94402. */
  94403. readonly leftPreViewMatrix: Matrix;
  94404. /**
  94405. * @hidden
  94406. */
  94407. readonly rightPreViewMatrix: Matrix;
  94408. /**
  94409. * Get the default VRMetrics based on the most generic setup.
  94410. * @returns the default vr metrics
  94411. */
  94412. static GetDefault(): VRCameraMetrics;
  94413. }
  94414. }
  94415. declare module BABYLON {
  94416. /** @hidden */
  94417. export var vrDistortionCorrectionPixelShader: {
  94418. name: string;
  94419. shader: string;
  94420. };
  94421. }
  94422. declare module BABYLON {
  94423. /**
  94424. * VRDistortionCorrectionPostProcess used for mobile VR
  94425. */
  94426. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94427. private _isRightEye;
  94428. private _distortionFactors;
  94429. private _postProcessScaleFactor;
  94430. private _lensCenterOffset;
  94431. private _scaleIn;
  94432. private _scaleFactor;
  94433. private _lensCenter;
  94434. /**
  94435. * Initializes the VRDistortionCorrectionPostProcess
  94436. * @param name The name of the effect.
  94437. * @param camera The camera to apply the render pass to.
  94438. * @param isRightEye If this is for the right eye distortion
  94439. * @param vrMetrics All the required metrics for the VR camera
  94440. */
  94441. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94442. }
  94443. }
  94444. declare module BABYLON {
  94445. /**
  94446. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94447. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94448. */
  94449. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94450. /**
  94451. * Creates a new VRDeviceOrientationArcRotateCamera
  94452. * @param name defines camera name
  94453. * @param alpha defines the camera rotation along the logitudinal axis
  94454. * @param beta defines the camera rotation along the latitudinal axis
  94455. * @param radius defines the camera distance from its target
  94456. * @param target defines the camera target
  94457. * @param scene defines the scene the camera belongs to
  94458. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94459. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94460. */
  94461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94462. /**
  94463. * Gets camera class name
  94464. * @returns VRDeviceOrientationArcRotateCamera
  94465. */
  94466. getClassName(): string;
  94467. }
  94468. }
  94469. declare module BABYLON {
  94470. /**
  94471. * Camera used to simulate VR rendering (based on FreeCamera)
  94472. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94473. */
  94474. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94475. /**
  94476. * Creates a new VRDeviceOrientationFreeCamera
  94477. * @param name defines camera name
  94478. * @param position defines the start position of the camera
  94479. * @param scene defines the scene the camera belongs to
  94480. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94481. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94482. */
  94483. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94484. /**
  94485. * Gets camera class name
  94486. * @returns VRDeviceOrientationFreeCamera
  94487. */
  94488. getClassName(): string;
  94489. }
  94490. }
  94491. declare module BABYLON {
  94492. /**
  94493. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94494. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94495. */
  94496. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94497. /**
  94498. * Creates a new VRDeviceOrientationGamepadCamera
  94499. * @param name defines camera name
  94500. * @param position defines the start position of the camera
  94501. * @param scene defines the scene the camera belongs to
  94502. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94503. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94504. */
  94505. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94506. /**
  94507. * Gets camera class name
  94508. * @returns VRDeviceOrientationGamepadCamera
  94509. */
  94510. getClassName(): string;
  94511. }
  94512. }
  94513. declare module BABYLON {
  94514. /**
  94515. * Defines supported buttons for XBox360 compatible gamepads
  94516. */
  94517. export enum Xbox360Button {
  94518. /** A */
  94519. A = 0,
  94520. /** B */
  94521. B = 1,
  94522. /** X */
  94523. X = 2,
  94524. /** Y */
  94525. Y = 3,
  94526. /** Start */
  94527. Start = 4,
  94528. /** Back */
  94529. Back = 5,
  94530. /** Left button */
  94531. LB = 6,
  94532. /** Right button */
  94533. RB = 7,
  94534. /** Left stick */
  94535. LeftStick = 8,
  94536. /** Right stick */
  94537. RightStick = 9
  94538. }
  94539. /** Defines values for XBox360 DPad */
  94540. export enum Xbox360Dpad {
  94541. /** Up */
  94542. Up = 0,
  94543. /** Down */
  94544. Down = 1,
  94545. /** Left */
  94546. Left = 2,
  94547. /** Right */
  94548. Right = 3
  94549. }
  94550. /**
  94551. * Defines a XBox360 gamepad
  94552. */
  94553. export class Xbox360Pad extends Gamepad {
  94554. private _leftTrigger;
  94555. private _rightTrigger;
  94556. private _onlefttriggerchanged;
  94557. private _onrighttriggerchanged;
  94558. private _onbuttondown;
  94559. private _onbuttonup;
  94560. private _ondpaddown;
  94561. private _ondpadup;
  94562. /** Observable raised when a button is pressed */
  94563. onButtonDownObservable: Observable<Xbox360Button>;
  94564. /** Observable raised when a button is released */
  94565. onButtonUpObservable: Observable<Xbox360Button>;
  94566. /** Observable raised when a pad is pressed */
  94567. onPadDownObservable: Observable<Xbox360Dpad>;
  94568. /** Observable raised when a pad is released */
  94569. onPadUpObservable: Observable<Xbox360Dpad>;
  94570. private _buttonA;
  94571. private _buttonB;
  94572. private _buttonX;
  94573. private _buttonY;
  94574. private _buttonBack;
  94575. private _buttonStart;
  94576. private _buttonLB;
  94577. private _buttonRB;
  94578. private _buttonLeftStick;
  94579. private _buttonRightStick;
  94580. private _dPadUp;
  94581. private _dPadDown;
  94582. private _dPadLeft;
  94583. private _dPadRight;
  94584. private _isXboxOnePad;
  94585. /**
  94586. * Creates a new XBox360 gamepad object
  94587. * @param id defines the id of this gamepad
  94588. * @param index defines its index
  94589. * @param gamepad defines the internal HTML gamepad object
  94590. * @param xboxOne defines if it is a XBox One gamepad
  94591. */
  94592. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94593. /**
  94594. * Defines the callback to call when left trigger is pressed
  94595. * @param callback defines the callback to use
  94596. */
  94597. onlefttriggerchanged(callback: (value: number) => void): void;
  94598. /**
  94599. * Defines the callback to call when right trigger is pressed
  94600. * @param callback defines the callback to use
  94601. */
  94602. onrighttriggerchanged(callback: (value: number) => void): void;
  94603. /**
  94604. * Gets the left trigger value
  94605. */
  94606. /**
  94607. * Sets the left trigger value
  94608. */
  94609. leftTrigger: number;
  94610. /**
  94611. * Gets the right trigger value
  94612. */
  94613. /**
  94614. * Sets the right trigger value
  94615. */
  94616. rightTrigger: number;
  94617. /**
  94618. * Defines the callback to call when a button is pressed
  94619. * @param callback defines the callback to use
  94620. */
  94621. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94622. /**
  94623. * Defines the callback to call when a button is released
  94624. * @param callback defines the callback to use
  94625. */
  94626. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94627. /**
  94628. * Defines the callback to call when a pad is pressed
  94629. * @param callback defines the callback to use
  94630. */
  94631. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94632. /**
  94633. * Defines the callback to call when a pad is released
  94634. * @param callback defines the callback to use
  94635. */
  94636. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94637. private _setButtonValue;
  94638. private _setDPadValue;
  94639. /**
  94640. * Gets the value of the `A` button
  94641. */
  94642. /**
  94643. * Sets the value of the `A` button
  94644. */
  94645. buttonA: number;
  94646. /**
  94647. * Gets the value of the `B` button
  94648. */
  94649. /**
  94650. * Sets the value of the `B` button
  94651. */
  94652. buttonB: number;
  94653. /**
  94654. * Gets the value of the `X` button
  94655. */
  94656. /**
  94657. * Sets the value of the `X` button
  94658. */
  94659. buttonX: number;
  94660. /**
  94661. * Gets the value of the `Y` button
  94662. */
  94663. /**
  94664. * Sets the value of the `Y` button
  94665. */
  94666. buttonY: number;
  94667. /**
  94668. * Gets the value of the `Start` button
  94669. */
  94670. /**
  94671. * Sets the value of the `Start` button
  94672. */
  94673. buttonStart: number;
  94674. /**
  94675. * Gets the value of the `Back` button
  94676. */
  94677. /**
  94678. * Sets the value of the `Back` button
  94679. */
  94680. buttonBack: number;
  94681. /**
  94682. * Gets the value of the `Left` button
  94683. */
  94684. /**
  94685. * Sets the value of the `Left` button
  94686. */
  94687. buttonLB: number;
  94688. /**
  94689. * Gets the value of the `Right` button
  94690. */
  94691. /**
  94692. * Sets the value of the `Right` button
  94693. */
  94694. buttonRB: number;
  94695. /**
  94696. * Gets the value of the Left joystick
  94697. */
  94698. /**
  94699. * Sets the value of the Left joystick
  94700. */
  94701. buttonLeftStick: number;
  94702. /**
  94703. * Gets the value of the Right joystick
  94704. */
  94705. /**
  94706. * Sets the value of the Right joystick
  94707. */
  94708. buttonRightStick: number;
  94709. /**
  94710. * Gets the value of D-pad up
  94711. */
  94712. /**
  94713. * Sets the value of D-pad up
  94714. */
  94715. dPadUp: number;
  94716. /**
  94717. * Gets the value of D-pad down
  94718. */
  94719. /**
  94720. * Sets the value of D-pad down
  94721. */
  94722. dPadDown: number;
  94723. /**
  94724. * Gets the value of D-pad left
  94725. */
  94726. /**
  94727. * Sets the value of D-pad left
  94728. */
  94729. dPadLeft: number;
  94730. /**
  94731. * Gets the value of D-pad right
  94732. */
  94733. /**
  94734. * Sets the value of D-pad right
  94735. */
  94736. dPadRight: number;
  94737. /**
  94738. * Force the gamepad to synchronize with device values
  94739. */
  94740. update(): void;
  94741. /**
  94742. * Disposes the gamepad
  94743. */
  94744. dispose(): void;
  94745. }
  94746. }
  94747. declare module BABYLON {
  94748. /**
  94749. * Base class of materials working in push mode in babylon JS
  94750. * @hidden
  94751. */
  94752. export class PushMaterial extends Material {
  94753. protected _activeEffect: Effect;
  94754. protected _normalMatrix: Matrix;
  94755. /**
  94756. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94757. * This means that the material can keep using a previous shader while a new one is being compiled.
  94758. * This is mostly used when shader parallel compilation is supported (true by default)
  94759. */
  94760. allowShaderHotSwapping: boolean;
  94761. constructor(name: string, scene: Scene);
  94762. getEffect(): Effect;
  94763. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94764. /**
  94765. * Binds the given world matrix to the active effect
  94766. *
  94767. * @param world the matrix to bind
  94768. */
  94769. bindOnlyWorldMatrix(world: Matrix): void;
  94770. /**
  94771. * Binds the given normal matrix to the active effect
  94772. *
  94773. * @param normalMatrix the matrix to bind
  94774. */
  94775. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94776. bind(world: Matrix, mesh?: Mesh): void;
  94777. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94778. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94779. }
  94780. }
  94781. declare module BABYLON {
  94782. /**
  94783. * This groups all the flags used to control the materials channel.
  94784. */
  94785. export class MaterialFlags {
  94786. private static _DiffuseTextureEnabled;
  94787. /**
  94788. * Are diffuse textures enabled in the application.
  94789. */
  94790. static DiffuseTextureEnabled: boolean;
  94791. private static _AmbientTextureEnabled;
  94792. /**
  94793. * Are ambient textures enabled in the application.
  94794. */
  94795. static AmbientTextureEnabled: boolean;
  94796. private static _OpacityTextureEnabled;
  94797. /**
  94798. * Are opacity textures enabled in the application.
  94799. */
  94800. static OpacityTextureEnabled: boolean;
  94801. private static _ReflectionTextureEnabled;
  94802. /**
  94803. * Are reflection textures enabled in the application.
  94804. */
  94805. static ReflectionTextureEnabled: boolean;
  94806. private static _EmissiveTextureEnabled;
  94807. /**
  94808. * Are emissive textures enabled in the application.
  94809. */
  94810. static EmissiveTextureEnabled: boolean;
  94811. private static _SpecularTextureEnabled;
  94812. /**
  94813. * Are specular textures enabled in the application.
  94814. */
  94815. static SpecularTextureEnabled: boolean;
  94816. private static _BumpTextureEnabled;
  94817. /**
  94818. * Are bump textures enabled in the application.
  94819. */
  94820. static BumpTextureEnabled: boolean;
  94821. private static _LightmapTextureEnabled;
  94822. /**
  94823. * Are lightmap textures enabled in the application.
  94824. */
  94825. static LightmapTextureEnabled: boolean;
  94826. private static _RefractionTextureEnabled;
  94827. /**
  94828. * Are refraction textures enabled in the application.
  94829. */
  94830. static RefractionTextureEnabled: boolean;
  94831. private static _ColorGradingTextureEnabled;
  94832. /**
  94833. * Are color grading textures enabled in the application.
  94834. */
  94835. static ColorGradingTextureEnabled: boolean;
  94836. private static _FresnelEnabled;
  94837. /**
  94838. * Are fresnels enabled in the application.
  94839. */
  94840. static FresnelEnabled: boolean;
  94841. private static _ClearCoatTextureEnabled;
  94842. /**
  94843. * Are clear coat textures enabled in the application.
  94844. */
  94845. static ClearCoatTextureEnabled: boolean;
  94846. private static _ClearCoatBumpTextureEnabled;
  94847. /**
  94848. * Are clear coat bump textures enabled in the application.
  94849. */
  94850. static ClearCoatBumpTextureEnabled: boolean;
  94851. private static _ClearCoatTintTextureEnabled;
  94852. /**
  94853. * Are clear coat tint textures enabled in the application.
  94854. */
  94855. static ClearCoatTintTextureEnabled: boolean;
  94856. }
  94857. }
  94858. declare module BABYLON {
  94859. /** @hidden */
  94860. export var defaultFragmentDeclaration: {
  94861. name: string;
  94862. shader: string;
  94863. };
  94864. }
  94865. declare module BABYLON {
  94866. /** @hidden */
  94867. export var defaultUboDeclaration: {
  94868. name: string;
  94869. shader: string;
  94870. };
  94871. }
  94872. declare module BABYLON {
  94873. /** @hidden */
  94874. export var lightFragmentDeclaration: {
  94875. name: string;
  94876. shader: string;
  94877. };
  94878. }
  94879. declare module BABYLON {
  94880. /** @hidden */
  94881. export var lightUboDeclaration: {
  94882. name: string;
  94883. shader: string;
  94884. };
  94885. }
  94886. declare module BABYLON {
  94887. /** @hidden */
  94888. export var lightsFragmentFunctions: {
  94889. name: string;
  94890. shader: string;
  94891. };
  94892. }
  94893. declare module BABYLON {
  94894. /** @hidden */
  94895. export var shadowsFragmentFunctions: {
  94896. name: string;
  94897. shader: string;
  94898. };
  94899. }
  94900. declare module BABYLON {
  94901. /** @hidden */
  94902. export var fresnelFunction: {
  94903. name: string;
  94904. shader: string;
  94905. };
  94906. }
  94907. declare module BABYLON {
  94908. /** @hidden */
  94909. export var reflectionFunction: {
  94910. name: string;
  94911. shader: string;
  94912. };
  94913. }
  94914. declare module BABYLON {
  94915. /** @hidden */
  94916. export var bumpFragmentFunctions: {
  94917. name: string;
  94918. shader: string;
  94919. };
  94920. }
  94921. declare module BABYLON {
  94922. /** @hidden */
  94923. export var logDepthDeclaration: {
  94924. name: string;
  94925. shader: string;
  94926. };
  94927. }
  94928. declare module BABYLON {
  94929. /** @hidden */
  94930. export var bumpFragment: {
  94931. name: string;
  94932. shader: string;
  94933. };
  94934. }
  94935. declare module BABYLON {
  94936. /** @hidden */
  94937. export var depthPrePass: {
  94938. name: string;
  94939. shader: string;
  94940. };
  94941. }
  94942. declare module BABYLON {
  94943. /** @hidden */
  94944. export var lightFragment: {
  94945. name: string;
  94946. shader: string;
  94947. };
  94948. }
  94949. declare module BABYLON {
  94950. /** @hidden */
  94951. export var logDepthFragment: {
  94952. name: string;
  94953. shader: string;
  94954. };
  94955. }
  94956. declare module BABYLON {
  94957. /** @hidden */
  94958. export var defaultPixelShader: {
  94959. name: string;
  94960. shader: string;
  94961. };
  94962. }
  94963. declare module BABYLON {
  94964. /** @hidden */
  94965. export var defaultVertexDeclaration: {
  94966. name: string;
  94967. shader: string;
  94968. };
  94969. }
  94970. declare module BABYLON {
  94971. /** @hidden */
  94972. export var bumpVertexDeclaration: {
  94973. name: string;
  94974. shader: string;
  94975. };
  94976. }
  94977. declare module BABYLON {
  94978. /** @hidden */
  94979. export var bumpVertex: {
  94980. name: string;
  94981. shader: string;
  94982. };
  94983. }
  94984. declare module BABYLON {
  94985. /** @hidden */
  94986. export var fogVertex: {
  94987. name: string;
  94988. shader: string;
  94989. };
  94990. }
  94991. declare module BABYLON {
  94992. /** @hidden */
  94993. export var shadowsVertex: {
  94994. name: string;
  94995. shader: string;
  94996. };
  94997. }
  94998. declare module BABYLON {
  94999. /** @hidden */
  95000. export var pointCloudVertex: {
  95001. name: string;
  95002. shader: string;
  95003. };
  95004. }
  95005. declare module BABYLON {
  95006. /** @hidden */
  95007. export var logDepthVertex: {
  95008. name: string;
  95009. shader: string;
  95010. };
  95011. }
  95012. declare module BABYLON {
  95013. /** @hidden */
  95014. export var defaultVertexShader: {
  95015. name: string;
  95016. shader: string;
  95017. };
  95018. }
  95019. declare module BABYLON {
  95020. /** @hidden */
  95021. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95022. MAINUV1: boolean;
  95023. MAINUV2: boolean;
  95024. DIFFUSE: boolean;
  95025. DIFFUSEDIRECTUV: number;
  95026. AMBIENT: boolean;
  95027. AMBIENTDIRECTUV: number;
  95028. OPACITY: boolean;
  95029. OPACITYDIRECTUV: number;
  95030. OPACITYRGB: boolean;
  95031. REFLECTION: boolean;
  95032. EMISSIVE: boolean;
  95033. EMISSIVEDIRECTUV: number;
  95034. SPECULAR: boolean;
  95035. SPECULARDIRECTUV: number;
  95036. BUMP: boolean;
  95037. BUMPDIRECTUV: number;
  95038. PARALLAX: boolean;
  95039. PARALLAXOCCLUSION: boolean;
  95040. SPECULAROVERALPHA: boolean;
  95041. CLIPPLANE: boolean;
  95042. CLIPPLANE2: boolean;
  95043. CLIPPLANE3: boolean;
  95044. CLIPPLANE4: boolean;
  95045. ALPHATEST: boolean;
  95046. DEPTHPREPASS: boolean;
  95047. ALPHAFROMDIFFUSE: boolean;
  95048. POINTSIZE: boolean;
  95049. FOG: boolean;
  95050. SPECULARTERM: boolean;
  95051. DIFFUSEFRESNEL: boolean;
  95052. OPACITYFRESNEL: boolean;
  95053. REFLECTIONFRESNEL: boolean;
  95054. REFRACTIONFRESNEL: boolean;
  95055. EMISSIVEFRESNEL: boolean;
  95056. FRESNEL: boolean;
  95057. NORMAL: boolean;
  95058. UV1: boolean;
  95059. UV2: boolean;
  95060. VERTEXCOLOR: boolean;
  95061. VERTEXALPHA: boolean;
  95062. NUM_BONE_INFLUENCERS: number;
  95063. BonesPerMesh: number;
  95064. BONETEXTURE: boolean;
  95065. INSTANCES: boolean;
  95066. GLOSSINESS: boolean;
  95067. ROUGHNESS: boolean;
  95068. EMISSIVEASILLUMINATION: boolean;
  95069. LINKEMISSIVEWITHDIFFUSE: boolean;
  95070. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95071. LIGHTMAP: boolean;
  95072. LIGHTMAPDIRECTUV: number;
  95073. OBJECTSPACE_NORMALMAP: boolean;
  95074. USELIGHTMAPASSHADOWMAP: boolean;
  95075. REFLECTIONMAP_3D: boolean;
  95076. REFLECTIONMAP_SPHERICAL: boolean;
  95077. REFLECTIONMAP_PLANAR: boolean;
  95078. REFLECTIONMAP_CUBIC: boolean;
  95079. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95080. REFLECTIONMAP_PROJECTION: boolean;
  95081. REFLECTIONMAP_SKYBOX: boolean;
  95082. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95083. REFLECTIONMAP_EXPLICIT: boolean;
  95084. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95085. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95086. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95087. INVERTCUBICMAP: boolean;
  95088. LOGARITHMICDEPTH: boolean;
  95089. REFRACTION: boolean;
  95090. REFRACTIONMAP_3D: boolean;
  95091. REFLECTIONOVERALPHA: boolean;
  95092. TWOSIDEDLIGHTING: boolean;
  95093. SHADOWFLOAT: boolean;
  95094. MORPHTARGETS: boolean;
  95095. MORPHTARGETS_NORMAL: boolean;
  95096. MORPHTARGETS_TANGENT: boolean;
  95097. NUM_MORPH_INFLUENCERS: number;
  95098. NONUNIFORMSCALING: boolean;
  95099. PREMULTIPLYALPHA: boolean;
  95100. IMAGEPROCESSING: boolean;
  95101. VIGNETTE: boolean;
  95102. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95103. VIGNETTEBLENDMODEOPAQUE: boolean;
  95104. TONEMAPPING: boolean;
  95105. TONEMAPPING_ACES: boolean;
  95106. CONTRAST: boolean;
  95107. COLORCURVES: boolean;
  95108. COLORGRADING: boolean;
  95109. COLORGRADING3D: boolean;
  95110. SAMPLER3DGREENDEPTH: boolean;
  95111. SAMPLER3DBGRMAP: boolean;
  95112. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95113. /**
  95114. * If the reflection texture on this material is in linear color space
  95115. * @hidden
  95116. */
  95117. IS_REFLECTION_LINEAR: boolean;
  95118. /**
  95119. * If the refraction texture on this material is in linear color space
  95120. * @hidden
  95121. */
  95122. IS_REFRACTION_LINEAR: boolean;
  95123. EXPOSURE: boolean;
  95124. constructor();
  95125. setReflectionMode(modeToEnable: string): void;
  95126. }
  95127. /**
  95128. * This is the default material used in Babylon. It is the best trade off between quality
  95129. * and performances.
  95130. * @see http://doc.babylonjs.com/babylon101/materials
  95131. */
  95132. export class StandardMaterial extends PushMaterial {
  95133. private _diffuseTexture;
  95134. /**
  95135. * The basic texture of the material as viewed under a light.
  95136. */
  95137. diffuseTexture: Nullable<BaseTexture>;
  95138. private _ambientTexture;
  95139. /**
  95140. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95141. */
  95142. ambientTexture: Nullable<BaseTexture>;
  95143. private _opacityTexture;
  95144. /**
  95145. * Define the transparency of the material from a texture.
  95146. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95147. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95148. */
  95149. opacityTexture: Nullable<BaseTexture>;
  95150. private _reflectionTexture;
  95151. /**
  95152. * Define the texture used to display the reflection.
  95153. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95154. */
  95155. reflectionTexture: Nullable<BaseTexture>;
  95156. private _emissiveTexture;
  95157. /**
  95158. * Define texture of the material as if self lit.
  95159. * This will be mixed in the final result even in the absence of light.
  95160. */
  95161. emissiveTexture: Nullable<BaseTexture>;
  95162. private _specularTexture;
  95163. /**
  95164. * Define how the color and intensity of the highlight given by the light in the material.
  95165. */
  95166. specularTexture: Nullable<BaseTexture>;
  95167. private _bumpTexture;
  95168. /**
  95169. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95170. * 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.
  95171. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95172. */
  95173. bumpTexture: Nullable<BaseTexture>;
  95174. private _lightmapTexture;
  95175. /**
  95176. * Complex lighting can be computationally expensive to compute at runtime.
  95177. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95178. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95179. */
  95180. lightmapTexture: Nullable<BaseTexture>;
  95181. private _refractionTexture;
  95182. /**
  95183. * Define the texture used to display the refraction.
  95184. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95185. */
  95186. refractionTexture: Nullable<BaseTexture>;
  95187. /**
  95188. * The color of the material lit by the environmental background lighting.
  95189. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95190. */
  95191. ambientColor: Color3;
  95192. /**
  95193. * The basic color of the material as viewed under a light.
  95194. */
  95195. diffuseColor: Color3;
  95196. /**
  95197. * Define how the color and intensity of the highlight given by the light in the material.
  95198. */
  95199. specularColor: Color3;
  95200. /**
  95201. * Define the color of the material as if self lit.
  95202. * This will be mixed in the final result even in the absence of light.
  95203. */
  95204. emissiveColor: Color3;
  95205. /**
  95206. * Defines how sharp are the highlights in the material.
  95207. * The bigger the value the sharper giving a more glossy feeling to the result.
  95208. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95209. */
  95210. specularPower: number;
  95211. private _useAlphaFromDiffuseTexture;
  95212. /**
  95213. * Does the transparency come from the diffuse texture alpha channel.
  95214. */
  95215. useAlphaFromDiffuseTexture: boolean;
  95216. private _useEmissiveAsIllumination;
  95217. /**
  95218. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95219. */
  95220. useEmissiveAsIllumination: boolean;
  95221. private _linkEmissiveWithDiffuse;
  95222. /**
  95223. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95224. * the emissive level when the final color is close to one.
  95225. */
  95226. linkEmissiveWithDiffuse: boolean;
  95227. private _useSpecularOverAlpha;
  95228. /**
  95229. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95230. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95231. */
  95232. useSpecularOverAlpha: boolean;
  95233. private _useReflectionOverAlpha;
  95234. /**
  95235. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95236. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95237. */
  95238. useReflectionOverAlpha: boolean;
  95239. private _disableLighting;
  95240. /**
  95241. * Does lights from the scene impacts this material.
  95242. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95243. */
  95244. disableLighting: boolean;
  95245. private _useObjectSpaceNormalMap;
  95246. /**
  95247. * Allows using an object space normal map (instead of tangent space).
  95248. */
  95249. useObjectSpaceNormalMap: boolean;
  95250. private _useParallax;
  95251. /**
  95252. * Is parallax enabled or not.
  95253. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95254. */
  95255. useParallax: boolean;
  95256. private _useParallaxOcclusion;
  95257. /**
  95258. * Is parallax occlusion enabled or not.
  95259. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95260. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95261. */
  95262. useParallaxOcclusion: boolean;
  95263. /**
  95264. * 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.
  95265. */
  95266. parallaxScaleBias: number;
  95267. private _roughness;
  95268. /**
  95269. * Helps to define how blurry the reflections should appears in the material.
  95270. */
  95271. roughness: number;
  95272. /**
  95273. * In case of refraction, define the value of the indice of refraction.
  95274. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95275. */
  95276. indexOfRefraction: number;
  95277. /**
  95278. * Invert the refraction texture alongside the y axis.
  95279. * It can be useful with procedural textures or probe for instance.
  95280. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95281. */
  95282. invertRefractionY: boolean;
  95283. /**
  95284. * Defines the alpha limits in alpha test mode.
  95285. */
  95286. alphaCutOff: number;
  95287. private _useLightmapAsShadowmap;
  95288. /**
  95289. * In case of light mapping, define whether the map contains light or shadow informations.
  95290. */
  95291. useLightmapAsShadowmap: boolean;
  95292. private _diffuseFresnelParameters;
  95293. /**
  95294. * Define the diffuse fresnel parameters of the material.
  95295. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95296. */
  95297. diffuseFresnelParameters: FresnelParameters;
  95298. private _opacityFresnelParameters;
  95299. /**
  95300. * Define the opacity fresnel parameters of the material.
  95301. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95302. */
  95303. opacityFresnelParameters: FresnelParameters;
  95304. private _reflectionFresnelParameters;
  95305. /**
  95306. * Define the reflection fresnel parameters of the material.
  95307. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95308. */
  95309. reflectionFresnelParameters: FresnelParameters;
  95310. private _refractionFresnelParameters;
  95311. /**
  95312. * Define the refraction fresnel parameters of the material.
  95313. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95314. */
  95315. refractionFresnelParameters: FresnelParameters;
  95316. private _emissiveFresnelParameters;
  95317. /**
  95318. * Define the emissive fresnel parameters of the material.
  95319. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95320. */
  95321. emissiveFresnelParameters: FresnelParameters;
  95322. private _useReflectionFresnelFromSpecular;
  95323. /**
  95324. * If true automatically deducts the fresnels values from the material specularity.
  95325. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95326. */
  95327. useReflectionFresnelFromSpecular: boolean;
  95328. private _useGlossinessFromSpecularMapAlpha;
  95329. /**
  95330. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95331. */
  95332. useGlossinessFromSpecularMapAlpha: boolean;
  95333. private _maxSimultaneousLights;
  95334. /**
  95335. * Defines the maximum number of lights that can be used in the material
  95336. */
  95337. maxSimultaneousLights: number;
  95338. private _invertNormalMapX;
  95339. /**
  95340. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95341. */
  95342. invertNormalMapX: boolean;
  95343. private _invertNormalMapY;
  95344. /**
  95345. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95346. */
  95347. invertNormalMapY: boolean;
  95348. private _twoSidedLighting;
  95349. /**
  95350. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95351. */
  95352. twoSidedLighting: boolean;
  95353. /**
  95354. * Default configuration related to image processing available in the standard Material.
  95355. */
  95356. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95357. /**
  95358. * Gets the image processing configuration used either in this material.
  95359. */
  95360. /**
  95361. * Sets the Default image processing configuration used either in the this material.
  95362. *
  95363. * If sets to null, the scene one is in use.
  95364. */
  95365. imageProcessingConfiguration: ImageProcessingConfiguration;
  95366. /**
  95367. * Keep track of the image processing observer to allow dispose and replace.
  95368. */
  95369. private _imageProcessingObserver;
  95370. /**
  95371. * Attaches a new image processing configuration to the Standard Material.
  95372. * @param configuration
  95373. */
  95374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95375. /**
  95376. * Gets wether the color curves effect is enabled.
  95377. */
  95378. /**
  95379. * Sets wether the color curves effect is enabled.
  95380. */
  95381. cameraColorCurvesEnabled: boolean;
  95382. /**
  95383. * Gets wether the color grading effect is enabled.
  95384. */
  95385. /**
  95386. * Gets wether the color grading effect is enabled.
  95387. */
  95388. cameraColorGradingEnabled: boolean;
  95389. /**
  95390. * Gets wether tonemapping is enabled or not.
  95391. */
  95392. /**
  95393. * Sets wether tonemapping is enabled or not
  95394. */
  95395. cameraToneMappingEnabled: boolean;
  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. /**
  95402. * The camera exposure used on this material.
  95403. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95404. * This corresponds to a photographic exposure.
  95405. */
  95406. cameraExposure: number;
  95407. /**
  95408. * Gets The camera contrast used on this material.
  95409. */
  95410. /**
  95411. * Sets The camera contrast used on this material.
  95412. */
  95413. cameraContrast: number;
  95414. /**
  95415. * Gets the Color Grading 2D Lookup Texture.
  95416. */
  95417. /**
  95418. * Sets the Color Grading 2D Lookup Texture.
  95419. */
  95420. cameraColorGradingTexture: Nullable<BaseTexture>;
  95421. /**
  95422. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95423. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95424. * 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;
  95425. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95426. */
  95427. /**
  95428. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95429. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95430. * 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;
  95431. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95432. */
  95433. cameraColorCurves: Nullable<ColorCurves>;
  95434. /**
  95435. * Custom callback helping to override the default shader used in the material.
  95436. */
  95437. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95438. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95439. protected _worldViewProjectionMatrix: Matrix;
  95440. protected _globalAmbientColor: Color3;
  95441. protected _useLogarithmicDepth: boolean;
  95442. /**
  95443. * Instantiates a new standard material.
  95444. * This is the default material used in Babylon. It is the best trade off between quality
  95445. * and performances.
  95446. * @see http://doc.babylonjs.com/babylon101/materials
  95447. * @param name Define the name of the material in the scene
  95448. * @param scene Define the scene the material belong to
  95449. */
  95450. constructor(name: string, scene: Scene);
  95451. /**
  95452. * Gets a boolean indicating that current material needs to register RTT
  95453. */
  95454. readonly hasRenderTargetTextures: boolean;
  95455. /**
  95456. * Gets the current class name of the material e.g. "StandardMaterial"
  95457. * Mainly use in serialization.
  95458. * @returns the class name
  95459. */
  95460. getClassName(): string;
  95461. /**
  95462. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95463. * You can try switching to logarithmic depth.
  95464. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95465. */
  95466. useLogarithmicDepth: boolean;
  95467. /**
  95468. * Specifies if the material will require alpha blending
  95469. * @returns a boolean specifying if alpha blending is needed
  95470. */
  95471. needAlphaBlending(): boolean;
  95472. /**
  95473. * Specifies if this material should be rendered in alpha test mode
  95474. * @returns a boolean specifying if an alpha test is needed.
  95475. */
  95476. needAlphaTesting(): boolean;
  95477. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95478. /**
  95479. * Get the texture used for alpha test purpose.
  95480. * @returns the diffuse texture in case of the standard material.
  95481. */
  95482. getAlphaTestTexture(): Nullable<BaseTexture>;
  95483. /**
  95484. * Get if the submesh is ready to be used and all its information available.
  95485. * Child classes can use it to update shaders
  95486. * @param mesh defines the mesh to check
  95487. * @param subMesh defines which submesh to check
  95488. * @param useInstances specifies that instances should be used
  95489. * @returns a boolean indicating that the submesh is ready or not
  95490. */
  95491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95492. /**
  95493. * Builds the material UBO layouts.
  95494. * Used internally during the effect preparation.
  95495. */
  95496. buildUniformLayout(): void;
  95497. /**
  95498. * Unbinds the material from the mesh
  95499. */
  95500. unbind(): void;
  95501. /**
  95502. * Binds the submesh to this material by preparing the effect and shader to draw
  95503. * @param world defines the world transformation matrix
  95504. * @param mesh defines the mesh containing the submesh
  95505. * @param subMesh defines the submesh to bind the material to
  95506. */
  95507. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95508. /**
  95509. * Get the list of animatables in the material.
  95510. * @returns the list of animatables object used in the material
  95511. */
  95512. getAnimatables(): IAnimatable[];
  95513. /**
  95514. * Gets the active textures from the material
  95515. * @returns an array of textures
  95516. */
  95517. getActiveTextures(): BaseTexture[];
  95518. /**
  95519. * Specifies if the material uses a texture
  95520. * @param texture defines the texture to check against the material
  95521. * @returns a boolean specifying if the material uses the texture
  95522. */
  95523. hasTexture(texture: BaseTexture): boolean;
  95524. /**
  95525. * Disposes the material
  95526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95528. */
  95529. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95530. /**
  95531. * Makes a duplicate of the material, and gives it a new name
  95532. * @param name defines the new name for the duplicated material
  95533. * @returns the cloned material
  95534. */
  95535. clone(name: string): StandardMaterial;
  95536. /**
  95537. * Serializes this material in a JSON representation
  95538. * @returns the serialized material object
  95539. */
  95540. serialize(): any;
  95541. /**
  95542. * Creates a standard material from parsed material data
  95543. * @param source defines the JSON representation of the material
  95544. * @param scene defines the hosting scene
  95545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95546. * @returns a new standard material
  95547. */
  95548. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95549. /**
  95550. * Are diffuse textures enabled in the application.
  95551. */
  95552. static DiffuseTextureEnabled: boolean;
  95553. /**
  95554. * Are ambient textures enabled in the application.
  95555. */
  95556. static AmbientTextureEnabled: boolean;
  95557. /**
  95558. * Are opacity textures enabled in the application.
  95559. */
  95560. static OpacityTextureEnabled: boolean;
  95561. /**
  95562. * Are reflection textures enabled in the application.
  95563. */
  95564. static ReflectionTextureEnabled: boolean;
  95565. /**
  95566. * Are emissive textures enabled in the application.
  95567. */
  95568. static EmissiveTextureEnabled: boolean;
  95569. /**
  95570. * Are specular textures enabled in the application.
  95571. */
  95572. static SpecularTextureEnabled: boolean;
  95573. /**
  95574. * Are bump textures enabled in the application.
  95575. */
  95576. static BumpTextureEnabled: boolean;
  95577. /**
  95578. * Are lightmap textures enabled in the application.
  95579. */
  95580. static LightmapTextureEnabled: boolean;
  95581. /**
  95582. * Are refraction textures enabled in the application.
  95583. */
  95584. static RefractionTextureEnabled: boolean;
  95585. /**
  95586. * Are color grading textures enabled in the application.
  95587. */
  95588. static ColorGradingTextureEnabled: boolean;
  95589. /**
  95590. * Are fresnels enabled in the application.
  95591. */
  95592. static FresnelEnabled: boolean;
  95593. }
  95594. }
  95595. declare module BABYLON {
  95596. /**
  95597. * A class extending Texture allowing drawing on a texture
  95598. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95599. */
  95600. export class DynamicTexture extends Texture {
  95601. private _generateMipMaps;
  95602. private _canvas;
  95603. private _context;
  95604. private _engine;
  95605. /**
  95606. * Creates a DynamicTexture
  95607. * @param name defines the name of the texture
  95608. * @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
  95609. * @param scene defines the scene where you want the texture
  95610. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95611. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95612. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95613. */
  95614. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95615. /**
  95616. * Get the current class name of the texture useful for serialization or dynamic coding.
  95617. * @returns "DynamicTexture"
  95618. */
  95619. getClassName(): string;
  95620. /**
  95621. * Gets the current state of canRescale
  95622. */
  95623. readonly canRescale: boolean;
  95624. private _recreate;
  95625. /**
  95626. * Scales the texture
  95627. * @param ratio the scale factor to apply to both width and height
  95628. */
  95629. scale(ratio: number): void;
  95630. /**
  95631. * Resizes the texture
  95632. * @param width the new width
  95633. * @param height the new height
  95634. */
  95635. scaleTo(width: number, height: number): void;
  95636. /**
  95637. * Gets the context of the canvas used by the texture
  95638. * @returns the canvas context of the dynamic texture
  95639. */
  95640. getContext(): CanvasRenderingContext2D;
  95641. /**
  95642. * Clears the texture
  95643. */
  95644. clear(): void;
  95645. /**
  95646. * Updates the texture
  95647. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95648. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95649. */
  95650. update(invertY?: boolean, premulAlpha?: boolean): void;
  95651. /**
  95652. * Draws text onto the texture
  95653. * @param text defines the text to be drawn
  95654. * @param x defines the placement of the text from the left
  95655. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95656. * @param font defines the font to be used with font-style, font-size, font-name
  95657. * @param color defines the color used for the text
  95658. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95659. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95660. * @param update defines whether texture is immediately update (default is true)
  95661. */
  95662. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95663. /**
  95664. * Clones the texture
  95665. * @returns the clone of the texture.
  95666. */
  95667. clone(): DynamicTexture;
  95668. /**
  95669. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95670. * @returns a serialized dynamic texture object
  95671. */
  95672. serialize(): any;
  95673. /** @hidden */
  95674. _rebuild(): void;
  95675. }
  95676. }
  95677. declare module BABYLON {
  95678. /** @hidden */
  95679. export var imageProcessingPixelShader: {
  95680. name: string;
  95681. shader: string;
  95682. };
  95683. }
  95684. declare module BABYLON {
  95685. /**
  95686. * ImageProcessingPostProcess
  95687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95688. */
  95689. export class ImageProcessingPostProcess extends PostProcess {
  95690. /**
  95691. * Default configuration related to image processing available in the PBR Material.
  95692. */
  95693. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95694. /**
  95695. * Gets the image processing configuration used either in this material.
  95696. */
  95697. /**
  95698. * Sets the Default image processing configuration used either in the this material.
  95699. *
  95700. * If sets to null, the scene one is in use.
  95701. */
  95702. imageProcessingConfiguration: ImageProcessingConfiguration;
  95703. /**
  95704. * Keep track of the image processing observer to allow dispose and replace.
  95705. */
  95706. private _imageProcessingObserver;
  95707. /**
  95708. * Attaches a new image processing configuration to the PBR Material.
  95709. * @param configuration
  95710. */
  95711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95712. /**
  95713. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95714. */
  95715. /**
  95716. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95717. */
  95718. colorCurves: Nullable<ColorCurves>;
  95719. /**
  95720. * Gets wether the color curves effect is enabled.
  95721. */
  95722. /**
  95723. * Sets wether the color curves effect is enabled.
  95724. */
  95725. colorCurvesEnabled: boolean;
  95726. /**
  95727. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95728. */
  95729. /**
  95730. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95731. */
  95732. colorGradingTexture: Nullable<BaseTexture>;
  95733. /**
  95734. * Gets wether the color grading effect is enabled.
  95735. */
  95736. /**
  95737. * Gets wether the color grading effect is enabled.
  95738. */
  95739. colorGradingEnabled: boolean;
  95740. /**
  95741. * Gets exposure used in the effect.
  95742. */
  95743. /**
  95744. * Sets exposure used in the effect.
  95745. */
  95746. exposure: number;
  95747. /**
  95748. * Gets wether tonemapping is enabled or not.
  95749. */
  95750. /**
  95751. * Sets wether tonemapping is enabled or not
  95752. */
  95753. toneMappingEnabled: boolean;
  95754. /**
  95755. * Gets the type of tone mapping effect.
  95756. */
  95757. /**
  95758. * Sets the type of tone mapping effect.
  95759. */
  95760. toneMappingType: number;
  95761. /**
  95762. * Gets contrast used in the effect.
  95763. */
  95764. /**
  95765. * Sets contrast used in the effect.
  95766. */
  95767. contrast: number;
  95768. /**
  95769. * Gets Vignette stretch size.
  95770. */
  95771. /**
  95772. * Sets Vignette stretch size.
  95773. */
  95774. vignetteStretch: number;
  95775. /**
  95776. * Gets Vignette centre X Offset.
  95777. */
  95778. /**
  95779. * Sets Vignette centre X Offset.
  95780. */
  95781. vignetteCentreX: number;
  95782. /**
  95783. * Gets Vignette centre Y Offset.
  95784. */
  95785. /**
  95786. * Sets Vignette centre Y Offset.
  95787. */
  95788. vignetteCentreY: number;
  95789. /**
  95790. * Gets Vignette weight or intensity of the vignette effect.
  95791. */
  95792. /**
  95793. * Sets Vignette weight or intensity of the vignette effect.
  95794. */
  95795. vignetteWeight: number;
  95796. /**
  95797. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95798. * if vignetteEnabled is set to true.
  95799. */
  95800. /**
  95801. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95802. * if vignetteEnabled is set to true.
  95803. */
  95804. vignetteColor: Color4;
  95805. /**
  95806. * Gets Camera field of view used by the Vignette effect.
  95807. */
  95808. /**
  95809. * Sets Camera field of view used by the Vignette effect.
  95810. */
  95811. vignetteCameraFov: number;
  95812. /**
  95813. * Gets the vignette blend mode allowing different kind of effect.
  95814. */
  95815. /**
  95816. * Sets the vignette blend mode allowing different kind of effect.
  95817. */
  95818. vignetteBlendMode: number;
  95819. /**
  95820. * Gets wether the vignette effect is enabled.
  95821. */
  95822. /**
  95823. * Sets wether the vignette effect is enabled.
  95824. */
  95825. vignetteEnabled: boolean;
  95826. private _fromLinearSpace;
  95827. /**
  95828. * Gets wether the input of the processing is in Gamma or Linear Space.
  95829. */
  95830. /**
  95831. * Sets wether the input of the processing is in Gamma or Linear Space.
  95832. */
  95833. fromLinearSpace: boolean;
  95834. /**
  95835. * Defines cache preventing GC.
  95836. */
  95837. private _defines;
  95838. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95839. /**
  95840. * "ImageProcessingPostProcess"
  95841. * @returns "ImageProcessingPostProcess"
  95842. */
  95843. getClassName(): string;
  95844. protected _updateParameters(): void;
  95845. dispose(camera?: Camera): void;
  95846. }
  95847. }
  95848. declare module BABYLON {
  95849. /**
  95850. * Class containing static functions to help procedurally build meshes
  95851. */
  95852. export class GroundBuilder {
  95853. /**
  95854. * Creates a ground mesh
  95855. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95856. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95858. * @param name defines the name of the mesh
  95859. * @param options defines the options used to create the mesh
  95860. * @param scene defines the hosting scene
  95861. * @returns the ground mesh
  95862. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95863. */
  95864. static CreateGround(name: string, options: {
  95865. width?: number;
  95866. height?: number;
  95867. subdivisions?: number;
  95868. subdivisionsX?: number;
  95869. subdivisionsY?: number;
  95870. updatable?: boolean;
  95871. }, scene: any): Mesh;
  95872. /**
  95873. * Creates a tiled ground mesh
  95874. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95875. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95876. * * 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
  95877. * * 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
  95878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95879. * @param name defines the name of the mesh
  95880. * @param options defines the options used to create the mesh
  95881. * @param scene defines the hosting scene
  95882. * @returns the tiled ground mesh
  95883. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95884. */
  95885. static CreateTiledGround(name: string, options: {
  95886. xmin: number;
  95887. zmin: number;
  95888. xmax: number;
  95889. zmax: number;
  95890. subdivisions?: {
  95891. w: number;
  95892. h: number;
  95893. };
  95894. precision?: {
  95895. w: number;
  95896. h: number;
  95897. };
  95898. updatable?: boolean;
  95899. }, scene: Scene): Mesh;
  95900. /**
  95901. * Creates a ground mesh from a height map
  95902. * * The parameter `url` sets the URL of the height map image resource.
  95903. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95904. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95905. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95906. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95907. * * 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.
  95908. * * 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).
  95909. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95911. * @param name defines the name of the mesh
  95912. * @param url defines the url to the height map
  95913. * @param options defines the options used to create the mesh
  95914. * @param scene defines the hosting scene
  95915. * @returns the ground mesh
  95916. * @see https://doc.babylonjs.com/babylon101/height_map
  95917. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95918. */
  95919. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95920. width?: number;
  95921. height?: number;
  95922. subdivisions?: number;
  95923. minHeight?: number;
  95924. maxHeight?: number;
  95925. colorFilter?: Color3;
  95926. alphaFilter?: number;
  95927. updatable?: boolean;
  95928. onReady?: (mesh: GroundMesh) => void;
  95929. }, scene: Scene): GroundMesh;
  95930. }
  95931. }
  95932. declare module BABYLON {
  95933. /**
  95934. * Class containing static functions to help procedurally build meshes
  95935. */
  95936. export class TorusBuilder {
  95937. /**
  95938. * Creates a torus mesh
  95939. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95940. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95941. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95943. * * If you create a double-sided mesh, you can choose what parts of 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
  95944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95945. * @param name defines the name of the mesh
  95946. * @param options defines the options used to create the mesh
  95947. * @param scene defines the hosting scene
  95948. * @returns the torus mesh
  95949. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95950. */
  95951. static CreateTorus(name: string, options: {
  95952. diameter?: number;
  95953. thickness?: number;
  95954. tessellation?: number;
  95955. updatable?: boolean;
  95956. sideOrientation?: number;
  95957. frontUVs?: Vector4;
  95958. backUVs?: Vector4;
  95959. }, scene: any): Mesh;
  95960. }
  95961. }
  95962. declare module BABYLON {
  95963. /**
  95964. * Class containing static functions to help procedurally build meshes
  95965. */
  95966. export class CylinderBuilder {
  95967. /**
  95968. * Creates a cylinder or a cone mesh
  95969. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95970. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95971. * * 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.
  95972. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95973. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95974. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95975. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95976. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95977. * * 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).
  95978. * * 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
  95979. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95980. * * 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
  95981. * * 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.
  95982. * * If `enclose` is false, a ring surface is one element.
  95983. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95984. * * 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
  95985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95986. * * If you create a double-sided mesh, you can choose what parts of 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
  95987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95988. * @param name defines the name of the mesh
  95989. * @param options defines the options used to create the mesh
  95990. * @param scene defines the hosting scene
  95991. * @returns the cylinder mesh
  95992. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95993. */
  95994. static CreateCylinder(name: string, options: {
  95995. height?: number;
  95996. diameterTop?: number;
  95997. diameterBottom?: number;
  95998. diameter?: number;
  95999. tessellation?: number;
  96000. subdivisions?: number;
  96001. arc?: number;
  96002. faceColors?: Color4[];
  96003. faceUV?: Vector4[];
  96004. updatable?: boolean;
  96005. hasRings?: boolean;
  96006. enclose?: boolean;
  96007. sideOrientation?: number;
  96008. frontUVs?: Vector4;
  96009. backUVs?: Vector4;
  96010. }, scene: any): Mesh;
  96011. }
  96012. }
  96013. declare module BABYLON {
  96014. /**
  96015. * Manager for handling gamepads
  96016. */
  96017. export class GamepadManager {
  96018. private _scene?;
  96019. private _babylonGamepads;
  96020. private _oneGamepadConnected;
  96021. /** @hidden */
  96022. _isMonitoring: boolean;
  96023. private _gamepadEventSupported;
  96024. private _gamepadSupport;
  96025. /**
  96026. * observable to be triggered when the gamepad controller has been connected
  96027. */
  96028. onGamepadConnectedObservable: Observable<Gamepad>;
  96029. /**
  96030. * observable to be triggered when the gamepad controller has been disconnected
  96031. */
  96032. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96033. private _onGamepadConnectedEvent;
  96034. private _onGamepadDisconnectedEvent;
  96035. /**
  96036. * Initializes the gamepad manager
  96037. * @param _scene BabylonJS scene
  96038. */
  96039. constructor(_scene?: Scene | undefined);
  96040. /**
  96041. * The gamepads in the game pad manager
  96042. */
  96043. readonly gamepads: Gamepad[];
  96044. /**
  96045. * Get the gamepad controllers based on type
  96046. * @param type The type of gamepad controller
  96047. * @returns Nullable gamepad
  96048. */
  96049. getGamepadByType(type?: number): Nullable<Gamepad>;
  96050. /**
  96051. * Disposes the gamepad manager
  96052. */
  96053. dispose(): void;
  96054. private _addNewGamepad;
  96055. private _startMonitoringGamepads;
  96056. private _stopMonitoringGamepads;
  96057. /** @hidden */
  96058. _checkGamepadsStatus(): void;
  96059. private _updateGamepadObjects;
  96060. }
  96061. }
  96062. declare module BABYLON {
  96063. interface Scene {
  96064. /** @hidden */
  96065. _gamepadManager: Nullable<GamepadManager>;
  96066. /**
  96067. * Gets the gamepad manager associated with the scene
  96068. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96069. */
  96070. gamepadManager: GamepadManager;
  96071. }
  96072. /**
  96073. * Interface representing a free camera inputs manager
  96074. */
  96075. interface FreeCameraInputsManager {
  96076. /**
  96077. * Adds gamepad input support to the FreeCameraInputsManager.
  96078. * @returns the FreeCameraInputsManager
  96079. */
  96080. addGamepad(): FreeCameraInputsManager;
  96081. }
  96082. /**
  96083. * Interface representing an arc rotate camera inputs manager
  96084. */
  96085. interface ArcRotateCameraInputsManager {
  96086. /**
  96087. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96088. * @returns the camera inputs manager
  96089. */
  96090. addGamepad(): ArcRotateCameraInputsManager;
  96091. }
  96092. /**
  96093. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96094. */
  96095. export class GamepadSystemSceneComponent implements ISceneComponent {
  96096. /**
  96097. * The component name helpfull to identify the component in the list of scene components.
  96098. */
  96099. readonly name: string;
  96100. /**
  96101. * The scene the component belongs to.
  96102. */
  96103. scene: Scene;
  96104. /**
  96105. * Creates a new instance of the component for the given scene
  96106. * @param scene Defines the scene to register the component in
  96107. */
  96108. constructor(scene: Scene);
  96109. /**
  96110. * Registers the component in a given scene
  96111. */
  96112. register(): void;
  96113. /**
  96114. * Rebuilds the elements related to this component in case of
  96115. * context lost for instance.
  96116. */
  96117. rebuild(): void;
  96118. /**
  96119. * Disposes the component and the associated ressources
  96120. */
  96121. dispose(): void;
  96122. private _beforeCameraUpdate;
  96123. }
  96124. }
  96125. declare module BABYLON {
  96126. /**
  96127. * Options to modify the vr teleportation behavior.
  96128. */
  96129. export interface VRTeleportationOptions {
  96130. /**
  96131. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96132. */
  96133. floorMeshName?: string;
  96134. /**
  96135. * A list of meshes to be used as the teleportation floor. (default: empty)
  96136. */
  96137. floorMeshes?: Mesh[];
  96138. }
  96139. /**
  96140. * Options to modify the vr experience helper's behavior.
  96141. */
  96142. export interface VRExperienceHelperOptions extends WebVROptions {
  96143. /**
  96144. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96145. */
  96146. createDeviceOrientationCamera?: boolean;
  96147. /**
  96148. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96149. */
  96150. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96151. /**
  96152. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96153. */
  96154. laserToggle?: boolean;
  96155. /**
  96156. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96157. */
  96158. floorMeshes?: Mesh[];
  96159. /**
  96160. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96161. */
  96162. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96163. }
  96164. /**
  96165. * Event containing information after VR has been entered
  96166. */
  96167. export class OnAfterEnteringVRObservableEvent {
  96168. /**
  96169. * If entering vr was successful
  96170. */
  96171. success: boolean;
  96172. }
  96173. /**
  96174. * Helps to quickly add VR support to an existing scene.
  96175. * See http://doc.babylonjs.com/how_to/webvr_helper
  96176. */
  96177. export class VRExperienceHelper {
  96178. /** Options to modify the vr experience helper's behavior. */
  96179. webVROptions: VRExperienceHelperOptions;
  96180. private _scene;
  96181. private _position;
  96182. private _btnVR;
  96183. private _btnVRDisplayed;
  96184. private _webVRsupported;
  96185. private _webVRready;
  96186. private _webVRrequesting;
  96187. private _webVRpresenting;
  96188. private _hasEnteredVR;
  96189. private _fullscreenVRpresenting;
  96190. private _canvas;
  96191. private _webVRCamera;
  96192. private _vrDeviceOrientationCamera;
  96193. private _deviceOrientationCamera;
  96194. private _existingCamera;
  96195. private _onKeyDown;
  96196. private _onVrDisplayPresentChange;
  96197. private _onVRDisplayChanged;
  96198. private _onVRRequestPresentStart;
  96199. private _onVRRequestPresentComplete;
  96200. /**
  96201. * Observable raised right before entering VR.
  96202. */
  96203. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96204. /**
  96205. * Observable raised when entering VR has completed.
  96206. */
  96207. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96208. /**
  96209. * Observable raised when exiting VR.
  96210. */
  96211. onExitingVRObservable: Observable<VRExperienceHelper>;
  96212. /**
  96213. * Observable raised when controller mesh is loaded.
  96214. */
  96215. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96216. /** Return this.onEnteringVRObservable
  96217. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96218. */
  96219. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96220. /** Return this.onExitingVRObservable
  96221. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96222. */
  96223. readonly onExitingVR: Observable<VRExperienceHelper>;
  96224. /** Return this.onControllerMeshLoadedObservable
  96225. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96226. */
  96227. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96228. private _rayLength;
  96229. private _useCustomVRButton;
  96230. private _teleportationRequested;
  96231. private _teleportActive;
  96232. private _floorMeshName;
  96233. private _floorMeshesCollection;
  96234. private _rotationAllowed;
  96235. private _teleportBackwardsVector;
  96236. private _teleportationTarget;
  96237. private _isDefaultTeleportationTarget;
  96238. private _postProcessMove;
  96239. private _teleportationFillColor;
  96240. private _teleportationBorderColor;
  96241. private _rotationAngle;
  96242. private _haloCenter;
  96243. private _cameraGazer;
  96244. private _padSensibilityUp;
  96245. private _padSensibilityDown;
  96246. private _leftController;
  96247. private _rightController;
  96248. /**
  96249. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96250. */
  96251. onNewMeshSelected: Observable<AbstractMesh>;
  96252. /**
  96253. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96254. */
  96255. onNewMeshPicked: Observable<PickingInfo>;
  96256. private _circleEase;
  96257. /**
  96258. * Observable raised before camera teleportation
  96259. */
  96260. onBeforeCameraTeleport: Observable<Vector3>;
  96261. /**
  96262. * Observable raised after camera teleportation
  96263. */
  96264. onAfterCameraTeleport: Observable<Vector3>;
  96265. /**
  96266. * Observable raised when current selected mesh gets unselected
  96267. */
  96268. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96269. private _raySelectionPredicate;
  96270. /**
  96271. * To be optionaly changed by user to define custom ray selection
  96272. */
  96273. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96274. /**
  96275. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96276. */
  96277. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96278. /**
  96279. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96280. */
  96281. teleportationEnabled: boolean;
  96282. private _defaultHeight;
  96283. private _teleportationInitialized;
  96284. private _interactionsEnabled;
  96285. private _interactionsRequested;
  96286. private _displayGaze;
  96287. private _displayLaserPointer;
  96288. /**
  96289. * The mesh used to display where the user is going to teleport.
  96290. */
  96291. /**
  96292. * Sets the mesh to be used to display where the user is going to teleport.
  96293. */
  96294. teleportationTarget: Mesh;
  96295. /**
  96296. * 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
  96297. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96298. * See http://doc.babylonjs.com/resources/baking_transformations
  96299. */
  96300. gazeTrackerMesh: Mesh;
  96301. /**
  96302. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96303. */
  96304. updateGazeTrackerScale: boolean;
  96305. /**
  96306. * If the gaze trackers color should be updated when selecting meshes
  96307. */
  96308. updateGazeTrackerColor: boolean;
  96309. /**
  96310. * The gaze tracking mesh corresponding to the left controller
  96311. */
  96312. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96313. /**
  96314. * The gaze tracking mesh corresponding to the right controller
  96315. */
  96316. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96317. /**
  96318. * If the ray of the gaze should be displayed.
  96319. */
  96320. /**
  96321. * Sets if the ray of the gaze should be displayed.
  96322. */
  96323. displayGaze: boolean;
  96324. /**
  96325. * If the ray of the LaserPointer should be displayed.
  96326. */
  96327. /**
  96328. * Sets if the ray of the LaserPointer should be displayed.
  96329. */
  96330. displayLaserPointer: boolean;
  96331. /**
  96332. * The deviceOrientationCamera used as the camera when not in VR.
  96333. */
  96334. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96335. /**
  96336. * Based on the current WebVR support, returns the current VR camera used.
  96337. */
  96338. readonly currentVRCamera: Nullable<Camera>;
  96339. /**
  96340. * The webVRCamera which is used when in VR.
  96341. */
  96342. readonly webVRCamera: WebVRFreeCamera;
  96343. /**
  96344. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96345. */
  96346. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96347. private readonly _teleportationRequestInitiated;
  96348. /**
  96349. * Defines wether or not Pointer lock should be requested when switching to
  96350. * full screen.
  96351. */
  96352. requestPointerLockOnFullScreen: boolean;
  96353. /**
  96354. * Instantiates a VRExperienceHelper.
  96355. * Helps to quickly add VR support to an existing scene.
  96356. * @param scene The scene the VRExperienceHelper belongs to.
  96357. * @param webVROptions Options to modify the vr experience helper's behavior.
  96358. */
  96359. constructor(scene: Scene,
  96360. /** Options to modify the vr experience helper's behavior. */
  96361. webVROptions?: VRExperienceHelperOptions);
  96362. private _onDefaultMeshLoaded;
  96363. private _onResize;
  96364. private _onFullscreenChange;
  96365. /**
  96366. * Gets a value indicating if we are currently in VR mode.
  96367. */
  96368. readonly isInVRMode: boolean;
  96369. private onVrDisplayPresentChange;
  96370. private onVRDisplayChanged;
  96371. private moveButtonToBottomRight;
  96372. private displayVRButton;
  96373. private updateButtonVisibility;
  96374. private _cachedAngularSensibility;
  96375. /**
  96376. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96377. * Otherwise, will use the fullscreen API.
  96378. */
  96379. enterVR(): void;
  96380. /**
  96381. * Attempt to exit VR, or fullscreen.
  96382. */
  96383. exitVR(): void;
  96384. /**
  96385. * The position of the vr experience helper.
  96386. */
  96387. /**
  96388. * Sets the position of the vr experience helper.
  96389. */
  96390. position: Vector3;
  96391. /**
  96392. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96393. */
  96394. enableInteractions(): void;
  96395. private readonly _noControllerIsActive;
  96396. private beforeRender;
  96397. private _isTeleportationFloor;
  96398. /**
  96399. * Adds a floor mesh to be used for teleportation.
  96400. * @param floorMesh the mesh to be used for teleportation.
  96401. */
  96402. addFloorMesh(floorMesh: Mesh): void;
  96403. /**
  96404. * Removes a floor mesh from being used for teleportation.
  96405. * @param floorMesh the mesh to be removed.
  96406. */
  96407. removeFloorMesh(floorMesh: Mesh): void;
  96408. /**
  96409. * Enables interactions and teleportation using the VR controllers and gaze.
  96410. * @param vrTeleportationOptions options to modify teleportation behavior.
  96411. */
  96412. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96413. private _onNewGamepadConnected;
  96414. private _tryEnableInteractionOnController;
  96415. private _onNewGamepadDisconnected;
  96416. private _enableInteractionOnController;
  96417. private _checkTeleportWithRay;
  96418. private _checkRotate;
  96419. private _checkTeleportBackwards;
  96420. private _enableTeleportationOnController;
  96421. private _createTeleportationCircles;
  96422. private _displayTeleportationTarget;
  96423. private _hideTeleportationTarget;
  96424. private _rotateCamera;
  96425. private _moveTeleportationSelectorTo;
  96426. private _workingVector;
  96427. private _workingQuaternion;
  96428. private _workingMatrix;
  96429. /**
  96430. * Teleports the users feet to the desired location
  96431. * @param location The location where the user's feet should be placed
  96432. */
  96433. teleportCamera(location: Vector3): void;
  96434. private _convertNormalToDirectionOfRay;
  96435. private _castRayAndSelectObject;
  96436. private _notifySelectedMeshUnselected;
  96437. /**
  96438. * Sets the color of the laser ray from the vr controllers.
  96439. * @param color new color for the ray.
  96440. */
  96441. changeLaserColor(color: Color3): void;
  96442. /**
  96443. * Sets the color of the ray from the vr headsets gaze.
  96444. * @param color new color for the ray.
  96445. */
  96446. changeGazeColor(color: Color3): void;
  96447. /**
  96448. * Exits VR and disposes of the vr experience helper
  96449. */
  96450. dispose(): void;
  96451. /**
  96452. * Gets the name of the VRExperienceHelper class
  96453. * @returns "VRExperienceHelper"
  96454. */
  96455. getClassName(): string;
  96456. }
  96457. }
  96458. declare module BABYLON {
  96459. /**
  96460. * Manages an XRSession
  96461. * @see https://doc.babylonjs.com/how_to/webxr
  96462. */
  96463. export class WebXRSessionManager implements IDisposable {
  96464. private scene;
  96465. /**
  96466. * Fires every time a new xrFrame arrives which can be used to update the camera
  96467. */
  96468. onXRFrameObservable: Observable<any>;
  96469. /**
  96470. * Fires when the xr session is ended either by the device or manually done
  96471. */
  96472. onXRSessionEnded: Observable<any>;
  96473. /** @hidden */
  96474. _xrSession: XRSession;
  96475. /** @hidden */
  96476. _frameOfReference: XRFrameOfReference;
  96477. /** @hidden */
  96478. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96479. /** @hidden */
  96480. _currentXRFrame: Nullable<XRFrame>;
  96481. private _xrNavigator;
  96482. private _xrDevice;
  96483. private _tmpMatrix;
  96484. /**
  96485. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96486. * @param scene The scene which the session should be created for
  96487. */
  96488. constructor(scene: Scene);
  96489. /**
  96490. * Initializes the manager
  96491. * After initialization enterXR can be called to start an XR session
  96492. * @returns Promise which resolves after it is initialized
  96493. */
  96494. initializeAsync(): Promise<void>;
  96495. /**
  96496. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96497. * @param sessionCreationOptions xr options to create the session with
  96498. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96499. * @returns Promise which resolves after it enters XR
  96500. */
  96501. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96502. /**
  96503. * Stops the xrSession and restores the renderloop
  96504. * @returns Promise which resolves after it exits XR
  96505. */
  96506. exitXRAsync(): Promise<void>;
  96507. /**
  96508. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96509. * @param ray ray to cast into the environment
  96510. * @returns Promise which resolves with a collision point in the environment if it exists
  96511. */
  96512. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96513. /**
  96514. * Checks if a session would be supported for the creation options specified
  96515. * @param options creation options to check if they are supported
  96516. * @returns true if supported
  96517. */
  96518. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96519. /**
  96520. * @hidden
  96521. * Converts the render layer of xrSession to a render target
  96522. * @param session session to create render target for
  96523. * @param scene scene the new render target should be created for
  96524. */
  96525. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96526. /**
  96527. * Disposes of the session manager
  96528. */
  96529. dispose(): void;
  96530. }
  96531. }
  96532. declare module BABYLON {
  96533. /**
  96534. * WebXR Camera which holds the views for the xrSession
  96535. * @see https://doc.babylonjs.com/how_to/webxr
  96536. */
  96537. export class WebXRCamera extends FreeCamera {
  96538. private static _TmpMatrix;
  96539. /**
  96540. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96541. * @param name the name of the camera
  96542. * @param scene the scene to add the camera to
  96543. */
  96544. constructor(name: string, scene: Scene);
  96545. private _updateNumberOfRigCameras;
  96546. /** @hidden */
  96547. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96548. /**
  96549. * Updates the cameras position from the current pose information of the XR session
  96550. * @param xrSessionManager the session containing pose information
  96551. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96552. */
  96553. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96554. }
  96555. }
  96556. declare module BABYLON {
  96557. /**
  96558. * States of the webXR experience
  96559. */
  96560. export enum WebXRState {
  96561. /**
  96562. * Transitioning to being in XR mode
  96563. */
  96564. ENTERING_XR = 0,
  96565. /**
  96566. * Transitioning to non XR mode
  96567. */
  96568. EXITING_XR = 1,
  96569. /**
  96570. * In XR mode and presenting
  96571. */
  96572. IN_XR = 2,
  96573. /**
  96574. * Not entered XR mode
  96575. */
  96576. NOT_IN_XR = 3
  96577. }
  96578. /**
  96579. * Helper class used to enable XR
  96580. * @see https://doc.babylonjs.com/how_to/webxr
  96581. */
  96582. export class WebXRExperienceHelper implements IDisposable {
  96583. private scene;
  96584. /**
  96585. * 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
  96586. */
  96587. container: AbstractMesh;
  96588. /**
  96589. * Camera used to render xr content
  96590. */
  96591. camera: WebXRCamera;
  96592. /**
  96593. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96594. */
  96595. state: WebXRState;
  96596. private _setState;
  96597. private static _TmpVector;
  96598. /**
  96599. * Fires when the state of the experience helper has changed
  96600. */
  96601. onStateChangedObservable: Observable<WebXRState>;
  96602. /** @hidden */
  96603. _sessionManager: WebXRSessionManager;
  96604. private _nonVRCamera;
  96605. private _originalSceneAutoClear;
  96606. private _supported;
  96607. /**
  96608. * Creates the experience helper
  96609. * @param scene the scene to attach the experience helper to
  96610. * @returns a promise for the experience helper
  96611. */
  96612. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96613. /**
  96614. * Creates a WebXRExperienceHelper
  96615. * @param scene The scene the helper should be created in
  96616. */
  96617. private constructor();
  96618. /**
  96619. * Exits XR mode and returns the scene to its original state
  96620. * @returns promise that resolves after xr mode has exited
  96621. */
  96622. exitXRAsync(): Promise<void>;
  96623. /**
  96624. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96625. * @param sessionCreationOptions options for the XR session
  96626. * @param frameOfReference frame of reference of the XR session
  96627. * @returns promise that resolves after xr mode has entered
  96628. */
  96629. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96630. /**
  96631. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96632. * @param ray ray to cast into the environment
  96633. * @returns Promise which resolves with a collision point in the environment if it exists
  96634. */
  96635. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96636. /**
  96637. * Updates the global position of the camera by moving the camera's container
  96638. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96639. * @param position The desired global position of the camera
  96640. */
  96641. setPositionOfCameraUsingContainer(position: Vector3): void;
  96642. /**
  96643. * Rotates the xr camera by rotating the camera's container around the camera's position
  96644. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96645. * @param rotation the desired quaternion rotation to apply to the camera
  96646. */
  96647. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96648. /**
  96649. * Checks if the creation options are supported by the xr session
  96650. * @param options creation options
  96651. * @returns true if supported
  96652. */
  96653. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96654. /**
  96655. * Disposes of the experience helper
  96656. */
  96657. dispose(): void;
  96658. }
  96659. }
  96660. declare module BABYLON {
  96661. /**
  96662. * Button which can be used to enter a different mode of XR
  96663. */
  96664. export class WebXREnterExitUIButton {
  96665. /** button element */
  96666. element: HTMLElement;
  96667. /** XR initialization options for the button */
  96668. initializationOptions: XRSessionCreationOptions;
  96669. /**
  96670. * Creates a WebXREnterExitUIButton
  96671. * @param element button element
  96672. * @param initializationOptions XR initialization options for the button
  96673. */
  96674. constructor(
  96675. /** button element */
  96676. element: HTMLElement,
  96677. /** XR initialization options for the button */
  96678. initializationOptions: XRSessionCreationOptions);
  96679. /**
  96680. * Overwritable function which can be used to update the button's visuals when the state changes
  96681. * @param activeButton the current active button in the UI
  96682. */
  96683. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96684. }
  96685. /**
  96686. * Options to create the webXR UI
  96687. */
  96688. export class WebXREnterExitUIOptions {
  96689. /**
  96690. * Context to enter xr with
  96691. */
  96692. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96693. /**
  96694. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96695. */
  96696. customButtons?: Array<WebXREnterExitUIButton>;
  96697. }
  96698. /**
  96699. * UI to allow the user to enter/exit XR mode
  96700. */
  96701. export class WebXREnterExitUI implements IDisposable {
  96702. private scene;
  96703. private _overlay;
  96704. private _buttons;
  96705. private _activeButton;
  96706. /**
  96707. * Fired every time the active button is changed.
  96708. *
  96709. * When xr is entered via a button that launches xr that button will be the callback parameter
  96710. *
  96711. * When exiting xr the callback parameter will be null)
  96712. */
  96713. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96714. /**
  96715. * Creates UI to allow the user to enter/exit XR mode
  96716. * @param scene the scene to add the ui to
  96717. * @param helper the xr experience helper to enter/exit xr with
  96718. * @param options options to configure the UI
  96719. * @returns the created ui
  96720. */
  96721. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96722. private constructor();
  96723. private _updateButtons;
  96724. /**
  96725. * Disposes of the object
  96726. */
  96727. dispose(): void;
  96728. }
  96729. }
  96730. declare module BABYLON {
  96731. /**
  96732. * Represents an XR input
  96733. */
  96734. export class WebXRController {
  96735. /**
  96736. * 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
  96737. */
  96738. grip?: AbstractMesh;
  96739. /**
  96740. * Pointer which can be used to select objects or attach a visible laser to
  96741. */
  96742. pointer: AbstractMesh;
  96743. /**
  96744. * Creates the controller
  96745. * @see https://doc.babylonjs.com/how_to/webxr
  96746. * @param scene the scene which the controller should be associated to
  96747. */
  96748. constructor(scene: Scene);
  96749. /**
  96750. * Disposes of the object
  96751. */
  96752. dispose(): void;
  96753. }
  96754. /**
  96755. * XR input used to track XR inputs such as controllers/rays
  96756. */
  96757. export class WebXRInput implements IDisposable {
  96758. private helper;
  96759. /**
  96760. * XR controllers being tracked
  96761. */
  96762. controllers: Array<WebXRController>;
  96763. private _tmpMatrix;
  96764. private _frameObserver;
  96765. /**
  96766. * Initializes the WebXRInput
  96767. * @param helper experience helper which the input should be created for
  96768. */
  96769. constructor(helper: WebXRExperienceHelper);
  96770. /**
  96771. * Disposes of the object
  96772. */
  96773. dispose(): void;
  96774. }
  96775. }
  96776. declare module BABYLON {
  96777. /**
  96778. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96779. */
  96780. export class WebXRManagedOutputCanvas implements IDisposable {
  96781. private _canvas;
  96782. /**
  96783. * xrpresent context of the canvas which can be used to display/mirror xr content
  96784. */
  96785. canvasContext: Nullable<WebGLRenderingContext>;
  96786. /**
  96787. * Initializes the canvas to be added/removed upon entering/exiting xr
  96788. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96789. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96790. */
  96791. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96792. /**
  96793. * Disposes of the object
  96794. */
  96795. dispose(): void;
  96796. private _setManagedOutputCanvas;
  96797. private _addCanvas;
  96798. private _removeCanvas;
  96799. }
  96800. }
  96801. declare module BABYLON {
  96802. /**
  96803. * Contains an array of blocks representing the octree
  96804. */
  96805. export interface IOctreeContainer<T> {
  96806. /**
  96807. * Blocks within the octree
  96808. */
  96809. blocks: Array<OctreeBlock<T>>;
  96810. }
  96811. /**
  96812. * Class used to store a cell in an octree
  96813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96814. */
  96815. export class OctreeBlock<T> {
  96816. /**
  96817. * Gets the content of the current block
  96818. */
  96819. entries: T[];
  96820. /**
  96821. * Gets the list of block children
  96822. */
  96823. blocks: Array<OctreeBlock<T>>;
  96824. private _depth;
  96825. private _maxDepth;
  96826. private _capacity;
  96827. private _minPoint;
  96828. private _maxPoint;
  96829. private _boundingVectors;
  96830. private _creationFunc;
  96831. /**
  96832. * Creates a new block
  96833. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96834. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96835. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96836. * @param depth defines the current depth of this block in the octree
  96837. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96838. * @param creationFunc defines a callback to call when an element is added to the block
  96839. */
  96840. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96841. /**
  96842. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96843. */
  96844. readonly capacity: number;
  96845. /**
  96846. * Gets the minimum vector (in world space) of the block's bounding box
  96847. */
  96848. readonly minPoint: Vector3;
  96849. /**
  96850. * Gets the maximum vector (in world space) of the block's bounding box
  96851. */
  96852. readonly maxPoint: Vector3;
  96853. /**
  96854. * Add a new element to this block
  96855. * @param entry defines the element to add
  96856. */
  96857. addEntry(entry: T): void;
  96858. /**
  96859. * Remove an element from this block
  96860. * @param entry defines the element to remove
  96861. */
  96862. removeEntry(entry: T): void;
  96863. /**
  96864. * Add an array of elements to this block
  96865. * @param entries defines the array of elements to add
  96866. */
  96867. addEntries(entries: T[]): void;
  96868. /**
  96869. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96870. * @param frustumPlanes defines the frustum planes to test
  96871. * @param selection defines the array to store current content if selection is positive
  96872. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96873. */
  96874. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96875. /**
  96876. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96877. * @param sphereCenter defines the bounding sphere center
  96878. * @param sphereRadius defines the bounding sphere radius
  96879. * @param selection defines the array to store current content if selection is positive
  96880. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96881. */
  96882. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96883. /**
  96884. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96885. * @param ray defines the ray to test with
  96886. * @param selection defines the array to store current content if selection is positive
  96887. */
  96888. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96889. /**
  96890. * Subdivide the content into child blocks (this block will then be empty)
  96891. */
  96892. createInnerBlocks(): void;
  96893. /**
  96894. * @hidden
  96895. */
  96896. 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;
  96897. }
  96898. }
  96899. declare module BABYLON {
  96900. /**
  96901. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96902. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96903. */
  96904. export class Octree<T> {
  96905. /** 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.) */
  96906. maxDepth: number;
  96907. /**
  96908. * Blocks within the octree containing objects
  96909. */
  96910. blocks: Array<OctreeBlock<T>>;
  96911. /**
  96912. * Content stored in the octree
  96913. */
  96914. dynamicContent: T[];
  96915. private _maxBlockCapacity;
  96916. private _selectionContent;
  96917. private _creationFunc;
  96918. /**
  96919. * Creates a octree
  96920. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96921. * @param creationFunc function to be used to instatiate the octree
  96922. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96923. * @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.)
  96924. */
  96925. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96926. /** 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.) */
  96927. maxDepth?: number);
  96928. /**
  96929. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96930. * @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);
  96931. * @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);
  96932. * @param entries meshes to be added to the octree blocks
  96933. */
  96934. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96935. /**
  96936. * Adds a mesh to the octree
  96937. * @param entry Mesh to add to the octree
  96938. */
  96939. addMesh(entry: T): void;
  96940. /**
  96941. * Remove an element from the octree
  96942. * @param entry defines the element to remove
  96943. */
  96944. removeMesh(entry: T): void;
  96945. /**
  96946. * Selects an array of meshes within the frustum
  96947. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96948. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96949. * @returns array of meshes within the frustum
  96950. */
  96951. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96952. /**
  96953. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96954. * @param sphereCenter defines the bounding sphere center
  96955. * @param sphereRadius defines the bounding sphere radius
  96956. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96957. * @returns an array of objects that intersect the sphere
  96958. */
  96959. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96960. /**
  96961. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96962. * @param ray defines the ray to test with
  96963. * @returns array of intersected objects
  96964. */
  96965. intersectsRay(ray: Ray): SmartArray<T>;
  96966. /**
  96967. * Adds a mesh into the octree block if it intersects the block
  96968. */
  96969. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96970. /**
  96971. * Adds a submesh into the octree block if it intersects the block
  96972. */
  96973. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96974. }
  96975. }
  96976. declare module BABYLON {
  96977. interface Scene {
  96978. /**
  96979. * @hidden
  96980. * Backing Filed
  96981. */
  96982. _selectionOctree: Octree<AbstractMesh>;
  96983. /**
  96984. * Gets the octree used to boost mesh selection (picking)
  96985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96986. */
  96987. selectionOctree: Octree<AbstractMesh>;
  96988. /**
  96989. * Creates or updates the octree used to boost selection (picking)
  96990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96991. * @param maxCapacity defines the maximum capacity per leaf
  96992. * @param maxDepth defines the maximum depth of the octree
  96993. * @returns an octree of AbstractMesh
  96994. */
  96995. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96996. }
  96997. interface AbstractMesh {
  96998. /**
  96999. * @hidden
  97000. * Backing Field
  97001. */
  97002. _submeshesOctree: Octree<SubMesh>;
  97003. /**
  97004. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97005. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97006. * @param maxCapacity defines the maximum size of each block (64 by default)
  97007. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97008. * @returns the new octree
  97009. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97011. */
  97012. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97013. }
  97014. /**
  97015. * Defines the octree scene component responsible to manage any octrees
  97016. * in a given scene.
  97017. */
  97018. export class OctreeSceneComponent {
  97019. /**
  97020. * The component name helpfull to identify the component in the list of scene components.
  97021. */
  97022. readonly name: string;
  97023. /**
  97024. * The scene the component belongs to.
  97025. */
  97026. scene: Scene;
  97027. /**
  97028. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97029. */
  97030. readonly checksIsEnabled: boolean;
  97031. /**
  97032. * Creates a new instance of the component for the given scene
  97033. * @param scene Defines the scene to register the component in
  97034. */
  97035. constructor(scene: Scene);
  97036. /**
  97037. * Registers the component in a given scene
  97038. */
  97039. register(): void;
  97040. /**
  97041. * Return the list of active meshes
  97042. * @returns the list of active meshes
  97043. */
  97044. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97045. /**
  97046. * Return the list of active sub meshes
  97047. * @param mesh The mesh to get the candidates sub meshes from
  97048. * @returns the list of active sub meshes
  97049. */
  97050. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97051. private _tempRay;
  97052. /**
  97053. * Return the list of sub meshes intersecting with a given local ray
  97054. * @param mesh defines the mesh to find the submesh for
  97055. * @param localRay defines the ray in local space
  97056. * @returns the list of intersecting sub meshes
  97057. */
  97058. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97059. /**
  97060. * Return the list of sub meshes colliding with a collider
  97061. * @param mesh defines the mesh to find the submesh for
  97062. * @param collider defines the collider to evaluate the collision against
  97063. * @returns the list of colliding sub meshes
  97064. */
  97065. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97066. /**
  97067. * Rebuilds the elements related to this component in case of
  97068. * context lost for instance.
  97069. */
  97070. rebuild(): void;
  97071. /**
  97072. * Disposes the component and the associated ressources.
  97073. */
  97074. dispose(): void;
  97075. }
  97076. }
  97077. declare module BABYLON {
  97078. /**
  97079. * Class containing static functions to help procedurally build meshes
  97080. */
  97081. export class LinesBuilder {
  97082. /**
  97083. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97084. * * 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
  97085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97086. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97087. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97088. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97090. * * 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
  97091. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97094. * @param name defines the name of the new line system
  97095. * @param options defines the options used to create the line system
  97096. * @param scene defines the hosting scene
  97097. * @returns a new line system mesh
  97098. */
  97099. static CreateLineSystem(name: string, options: {
  97100. lines: Vector3[][];
  97101. updatable?: boolean;
  97102. instance?: Nullable<LinesMesh>;
  97103. colors?: Nullable<Color4[][]>;
  97104. useVertexAlpha?: boolean;
  97105. }, scene: Nullable<Scene>): LinesMesh;
  97106. /**
  97107. * Creates a line mesh
  97108. * 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
  97109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97110. * * The parameter `points` is an array successive Vector3
  97111. * * 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
  97112. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97113. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97114. * * When updating an instance, remember that only point positions can change, not the number of points
  97115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97117. * @param name defines the name of the new line system
  97118. * @param options defines the options used to create the line system
  97119. * @param scene defines the hosting scene
  97120. * @returns a new line mesh
  97121. */
  97122. static CreateLines(name: string, options: {
  97123. points: Vector3[];
  97124. updatable?: boolean;
  97125. instance?: Nullable<LinesMesh>;
  97126. colors?: Color4[];
  97127. useVertexAlpha?: boolean;
  97128. }, scene?: Nullable<Scene>): LinesMesh;
  97129. /**
  97130. * Creates a dashed line mesh
  97131. * * 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
  97132. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97133. * * The parameter `points` is an array successive Vector3
  97134. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97135. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97136. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97137. * * 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
  97138. * * When updating an instance, remember that only point positions can change, not the number of points
  97139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97140. * @param name defines the name of the mesh
  97141. * @param options defines the options used to create the mesh
  97142. * @param scene defines the hosting scene
  97143. * @returns the dashed line mesh
  97144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97145. */
  97146. static CreateDashedLines(name: string, options: {
  97147. points: Vector3[];
  97148. dashSize?: number;
  97149. gapSize?: number;
  97150. dashNb?: number;
  97151. updatable?: boolean;
  97152. instance?: LinesMesh;
  97153. }, scene?: Nullable<Scene>): LinesMesh;
  97154. }
  97155. }
  97156. declare module BABYLON {
  97157. /**
  97158. * Renders a layer on top of an existing scene
  97159. */
  97160. export class UtilityLayerRenderer implements IDisposable {
  97161. /** the original scene that will be rendered on top of */
  97162. originalScene: Scene;
  97163. private _pointerCaptures;
  97164. private _lastPointerEvents;
  97165. private static _DefaultUtilityLayer;
  97166. private static _DefaultKeepDepthUtilityLayer;
  97167. /**
  97168. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97169. */
  97170. pickUtilitySceneFirst: boolean;
  97171. /**
  97172. * 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)
  97173. */
  97174. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97175. /**
  97176. * 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)
  97177. */
  97178. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97179. /**
  97180. * The scene that is rendered on top of the original scene
  97181. */
  97182. utilityLayerScene: Scene;
  97183. /**
  97184. * If the utility layer should automatically be rendered on top of existing scene
  97185. */
  97186. shouldRender: boolean;
  97187. /**
  97188. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97189. */
  97190. onlyCheckPointerDownEvents: boolean;
  97191. /**
  97192. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97193. */
  97194. processAllEvents: boolean;
  97195. /**
  97196. * Observable raised when the pointer move from the utility layer scene to the main scene
  97197. */
  97198. onPointerOutObservable: Observable<number>;
  97199. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97200. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97201. private _afterRenderObserver;
  97202. private _sceneDisposeObserver;
  97203. private _originalPointerObserver;
  97204. /**
  97205. * Instantiates a UtilityLayerRenderer
  97206. * @param originalScene the original scene that will be rendered on top of
  97207. * @param handleEvents boolean indicating if the utility layer should handle events
  97208. */
  97209. constructor(
  97210. /** the original scene that will be rendered on top of */
  97211. originalScene: Scene, handleEvents?: boolean);
  97212. private _notifyObservers;
  97213. /**
  97214. * Renders the utility layers scene on top of the original scene
  97215. */
  97216. render(): void;
  97217. /**
  97218. * Disposes of the renderer
  97219. */
  97220. dispose(): void;
  97221. private _updateCamera;
  97222. }
  97223. }
  97224. declare module BABYLON {
  97225. /**
  97226. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97227. */
  97228. export class Gizmo implements IDisposable {
  97229. /** The utility layer the gizmo will be added to */
  97230. gizmoLayer: UtilityLayerRenderer;
  97231. /**
  97232. * The root mesh of the gizmo
  97233. */
  97234. _rootMesh: Mesh;
  97235. private _attachedMesh;
  97236. /**
  97237. * Ratio for the scale of the gizmo (Default: 1)
  97238. */
  97239. scaleRatio: number;
  97240. private _tmpMatrix;
  97241. /**
  97242. * If a custom mesh has been set (Default: false)
  97243. */
  97244. protected _customMeshSet: boolean;
  97245. /**
  97246. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97247. * * When set, interactions will be enabled
  97248. */
  97249. attachedMesh: Nullable<AbstractMesh>;
  97250. /**
  97251. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97252. * @param mesh The mesh to replace the default mesh of the gizmo
  97253. */
  97254. setCustomMesh(mesh: Mesh): void;
  97255. /**
  97256. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97257. */
  97258. updateGizmoRotationToMatchAttachedMesh: boolean;
  97259. /**
  97260. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97261. */
  97262. updateGizmoPositionToMatchAttachedMesh: boolean;
  97263. /**
  97264. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97265. */
  97266. protected _updateScale: boolean;
  97267. protected _interactionsEnabled: boolean;
  97268. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97269. private _beforeRenderObserver;
  97270. /**
  97271. * Creates a gizmo
  97272. * @param gizmoLayer The utility layer the gizmo will be added to
  97273. */
  97274. constructor(
  97275. /** The utility layer the gizmo will be added to */
  97276. gizmoLayer?: UtilityLayerRenderer);
  97277. private _tempVector;
  97278. /**
  97279. * @hidden
  97280. * Updates the gizmo to match the attached mesh's position/rotation
  97281. */
  97282. protected _update(): void;
  97283. /**
  97284. * Disposes of the gizmo
  97285. */
  97286. dispose(): void;
  97287. }
  97288. }
  97289. declare module BABYLON {
  97290. /**
  97291. * Single axis drag gizmo
  97292. */
  97293. export class AxisDragGizmo extends Gizmo {
  97294. /**
  97295. * Drag behavior responsible for the gizmos dragging interactions
  97296. */
  97297. dragBehavior: PointerDragBehavior;
  97298. private _pointerObserver;
  97299. /**
  97300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97301. */
  97302. snapDistance: number;
  97303. /**
  97304. * Event that fires each time the gizmo snaps to a new location.
  97305. * * snapDistance is the the change in distance
  97306. */
  97307. onSnapObservable: Observable<{
  97308. snapDistance: number;
  97309. }>;
  97310. /** @hidden */
  97311. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97312. /** @hidden */
  97313. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97314. /**
  97315. * Creates an AxisDragGizmo
  97316. * @param gizmoLayer The utility layer the gizmo will be added to
  97317. * @param dragAxis The axis which the gizmo will be able to drag on
  97318. * @param color The color of the gizmo
  97319. */
  97320. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97321. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97322. /**
  97323. * Disposes of the gizmo
  97324. */
  97325. dispose(): void;
  97326. }
  97327. }
  97328. declare module BABYLON.Debug {
  97329. /**
  97330. * The Axes viewer will show 3 axes in a specific point in space
  97331. */
  97332. export class AxesViewer {
  97333. private _xAxis;
  97334. private _yAxis;
  97335. private _zAxis;
  97336. private _scaleLinesFactor;
  97337. private _instanced;
  97338. /**
  97339. * Gets the hosting scene
  97340. */
  97341. scene: Scene;
  97342. /**
  97343. * Gets or sets a number used to scale line length
  97344. */
  97345. scaleLines: number;
  97346. /** Gets the node hierarchy used to render x-axis */
  97347. readonly xAxis: TransformNode;
  97348. /** Gets the node hierarchy used to render y-axis */
  97349. readonly yAxis: TransformNode;
  97350. /** Gets the node hierarchy used to render z-axis */
  97351. readonly zAxis: TransformNode;
  97352. /**
  97353. * Creates a new AxesViewer
  97354. * @param scene defines the hosting scene
  97355. * @param scaleLines defines a number used to scale line length (1 by default)
  97356. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97357. * @param xAxis defines the node hierarchy used to render the x-axis
  97358. * @param yAxis defines the node hierarchy used to render the y-axis
  97359. * @param zAxis defines the node hierarchy used to render the z-axis
  97360. */
  97361. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97362. /**
  97363. * Force the viewer to update
  97364. * @param position defines the position of the viewer
  97365. * @param xaxis defines the x axis of the viewer
  97366. * @param yaxis defines the y axis of the viewer
  97367. * @param zaxis defines the z axis of the viewer
  97368. */
  97369. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97370. /**
  97371. * Creates an instance of this axes viewer.
  97372. * @returns a new axes viewer with instanced meshes
  97373. */
  97374. createInstance(): AxesViewer;
  97375. /** Releases resources */
  97376. dispose(): void;
  97377. private static _SetRenderingGroupId;
  97378. }
  97379. }
  97380. declare module BABYLON.Debug {
  97381. /**
  97382. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97383. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97384. */
  97385. export class BoneAxesViewer extends AxesViewer {
  97386. /**
  97387. * Gets or sets the target mesh where to display the axes viewer
  97388. */
  97389. mesh: Nullable<Mesh>;
  97390. /**
  97391. * Gets or sets the target bone where to display the axes viewer
  97392. */
  97393. bone: Nullable<Bone>;
  97394. /** Gets current position */
  97395. pos: Vector3;
  97396. /** Gets direction of X axis */
  97397. xaxis: Vector3;
  97398. /** Gets direction of Y axis */
  97399. yaxis: Vector3;
  97400. /** Gets direction of Z axis */
  97401. zaxis: Vector3;
  97402. /**
  97403. * Creates a new BoneAxesViewer
  97404. * @param scene defines the hosting scene
  97405. * @param bone defines the target bone
  97406. * @param mesh defines the target mesh
  97407. * @param scaleLines defines a scaling factor for line length (1 by default)
  97408. */
  97409. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97410. /**
  97411. * Force the viewer to update
  97412. */
  97413. update(): void;
  97414. /** Releases resources */
  97415. dispose(): void;
  97416. }
  97417. }
  97418. declare module BABYLON {
  97419. /**
  97420. * Interface used to define scene explorer extensibility option
  97421. */
  97422. export interface IExplorerExtensibilityOption {
  97423. /**
  97424. * Define the option label
  97425. */
  97426. label: string;
  97427. /**
  97428. * Defines the action to execute on click
  97429. */
  97430. action: (entity: any) => void;
  97431. }
  97432. /**
  97433. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97434. */
  97435. export interface IExplorerExtensibilityGroup {
  97436. /**
  97437. * Defines a predicate to test if a given type mut be extended
  97438. */
  97439. predicate: (entity: any) => boolean;
  97440. /**
  97441. * Gets the list of options added to a type
  97442. */
  97443. entries: IExplorerExtensibilityOption[];
  97444. }
  97445. /**
  97446. * Interface used to define the options to use to create the Inspector
  97447. */
  97448. export interface IInspectorOptions {
  97449. /**
  97450. * Display in overlay mode (default: false)
  97451. */
  97452. overlay?: boolean;
  97453. /**
  97454. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97455. */
  97456. globalRoot?: HTMLElement;
  97457. /**
  97458. * Display the Scene explorer
  97459. */
  97460. showExplorer?: boolean;
  97461. /**
  97462. * Display the property inspector
  97463. */
  97464. showInspector?: boolean;
  97465. /**
  97466. * Display in embed mode (both panes on the right)
  97467. */
  97468. embedMode?: boolean;
  97469. /**
  97470. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97471. */
  97472. handleResize?: boolean;
  97473. /**
  97474. * Allow the panes to popup (default: true)
  97475. */
  97476. enablePopup?: boolean;
  97477. /**
  97478. * Allow the panes to be closed by users (default: true)
  97479. */
  97480. enableClose?: boolean;
  97481. /**
  97482. * Optional list of extensibility entries
  97483. */
  97484. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97485. /**
  97486. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97487. */
  97488. inspectorURL?: string;
  97489. }
  97490. interface Scene {
  97491. /**
  97492. * @hidden
  97493. * Backing field
  97494. */
  97495. _debugLayer: DebugLayer;
  97496. /**
  97497. * Gets the debug layer (aka Inspector) associated with the scene
  97498. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97499. */
  97500. debugLayer: DebugLayer;
  97501. }
  97502. /**
  97503. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97504. * what is happening in your scene
  97505. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97506. */
  97507. export class DebugLayer {
  97508. /**
  97509. * Define the url to get the inspector script from.
  97510. * By default it uses the babylonjs CDN.
  97511. * @ignoreNaming
  97512. */
  97513. static InspectorURL: string;
  97514. private _scene;
  97515. private BJSINSPECTOR;
  97516. /**
  97517. * Observable triggered when a property is changed through the inspector.
  97518. */
  97519. onPropertyChangedObservable: Observable<{
  97520. object: any;
  97521. property: string;
  97522. value: any;
  97523. initialValue: any;
  97524. }>;
  97525. /**
  97526. * Instantiates a new debug layer.
  97527. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97528. * what is happening in your scene
  97529. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97530. * @param scene Defines the scene to inspect
  97531. */
  97532. constructor(scene: Scene);
  97533. /** Creates the inspector window. */
  97534. private _createInspector;
  97535. /**
  97536. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97537. * @param entity defines the entity to select
  97538. * @param lineContainerTitle defines the specific block to highlight
  97539. */
  97540. select(entity: any, lineContainerTitle?: string): void;
  97541. /** Get the inspector from bundle or global */
  97542. private _getGlobalInspector;
  97543. /**
  97544. * Get if the inspector is visible or not.
  97545. * @returns true if visible otherwise, false
  97546. */
  97547. isVisible(): boolean;
  97548. /**
  97549. * Hide the inspector and close its window.
  97550. */
  97551. hide(): void;
  97552. /**
  97553. * Launch the debugLayer.
  97554. * @param config Define the configuration of the inspector
  97555. * @return a promise fulfilled when the debug layer is visible
  97556. */
  97557. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97558. }
  97559. }
  97560. declare module BABYLON {
  97561. /**
  97562. * Class containing static functions to help procedurally build meshes
  97563. */
  97564. export class BoxBuilder {
  97565. /**
  97566. * Creates a box mesh
  97567. * * The parameter `size` sets the size (float) of each box side (default 1)
  97568. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97569. * * 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)
  97570. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97572. * * If you create a double-sided mesh, you can choose what parts of 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
  97573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97574. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97575. * @param name defines the name of the mesh
  97576. * @param options defines the options used to create the mesh
  97577. * @param scene defines the hosting scene
  97578. * @returns the box mesh
  97579. */
  97580. static CreateBox(name: string, options: {
  97581. size?: number;
  97582. width?: number;
  97583. height?: number;
  97584. depth?: number;
  97585. faceUV?: Vector4[];
  97586. faceColors?: Color4[];
  97587. sideOrientation?: number;
  97588. frontUVs?: Vector4;
  97589. backUVs?: Vector4;
  97590. updatable?: boolean;
  97591. }, scene?: Nullable<Scene>): Mesh;
  97592. }
  97593. }
  97594. declare module BABYLON {
  97595. /**
  97596. * Class containing static functions to help procedurally build meshes
  97597. */
  97598. export class SphereBuilder {
  97599. /**
  97600. * Creates a sphere mesh
  97601. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97602. * * 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`)
  97603. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97604. * * 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
  97605. * * 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)
  97606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97607. * * If you create a double-sided mesh, you can choose what parts of 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
  97608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97609. * @param name defines the name of the mesh
  97610. * @param options defines the options used to create the mesh
  97611. * @param scene defines the hosting scene
  97612. * @returns the sphere mesh
  97613. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97614. */
  97615. static CreateSphere(name: string, options: {
  97616. segments?: number;
  97617. diameter?: number;
  97618. diameterX?: number;
  97619. diameterY?: number;
  97620. diameterZ?: number;
  97621. arc?: number;
  97622. slice?: number;
  97623. sideOrientation?: number;
  97624. frontUVs?: Vector4;
  97625. backUVs?: Vector4;
  97626. updatable?: boolean;
  97627. }, scene: any): Mesh;
  97628. }
  97629. }
  97630. declare module BABYLON.Debug {
  97631. /**
  97632. * Used to show the physics impostor around the specific mesh
  97633. */
  97634. export class PhysicsViewer {
  97635. /** @hidden */
  97636. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97637. /** @hidden */
  97638. protected _meshes: Array<Nullable<AbstractMesh>>;
  97639. /** @hidden */
  97640. protected _scene: Nullable<Scene>;
  97641. /** @hidden */
  97642. protected _numMeshes: number;
  97643. /** @hidden */
  97644. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97645. private _renderFunction;
  97646. private _utilityLayer;
  97647. private _debugBoxMesh;
  97648. private _debugSphereMesh;
  97649. private _debugMaterial;
  97650. /**
  97651. * Creates a new PhysicsViewer
  97652. * @param scene defines the hosting scene
  97653. */
  97654. constructor(scene: Scene);
  97655. /** @hidden */
  97656. protected _updateDebugMeshes(): void;
  97657. /**
  97658. * Renders a specified physic impostor
  97659. * @param impostor defines the impostor to render
  97660. * @returns the new debug mesh used to render the impostor
  97661. */
  97662. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97663. /**
  97664. * Hides a specified physic impostor
  97665. * @param impostor defines the impostor to hide
  97666. */
  97667. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97668. private _getDebugMaterial;
  97669. private _getDebugBoxMesh;
  97670. private _getDebugSphereMesh;
  97671. private _getDebugMesh;
  97672. /** Releases all resources */
  97673. dispose(): void;
  97674. }
  97675. }
  97676. declare module BABYLON {
  97677. /**
  97678. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97679. * in order to better appreciate the issue one might have.
  97680. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97681. */
  97682. export class RayHelper {
  97683. /**
  97684. * Defines the ray we are currently tryin to visualize.
  97685. */
  97686. ray: Nullable<Ray>;
  97687. private _renderPoints;
  97688. private _renderLine;
  97689. private _renderFunction;
  97690. private _scene;
  97691. private _updateToMeshFunction;
  97692. private _attachedToMesh;
  97693. private _meshSpaceDirection;
  97694. private _meshSpaceOrigin;
  97695. /**
  97696. * Helper function to create a colored helper in a scene in one line.
  97697. * @param ray Defines the ray we are currently tryin to visualize
  97698. * @param scene Defines the scene the ray is used in
  97699. * @param color Defines the color we want to see the ray in
  97700. * @returns The newly created ray helper.
  97701. */
  97702. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97703. /**
  97704. * Instantiate a new ray helper.
  97705. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97706. * in order to better appreciate the issue one might have.
  97707. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97708. * @param ray Defines the ray we are currently tryin to visualize
  97709. */
  97710. constructor(ray: Ray);
  97711. /**
  97712. * Shows the ray we are willing to debug.
  97713. * @param scene Defines the scene the ray needs to be rendered in
  97714. * @param color Defines the color the ray needs to be rendered in
  97715. */
  97716. show(scene: Scene, color?: Color3): void;
  97717. /**
  97718. * Hides the ray we are debugging.
  97719. */
  97720. hide(): void;
  97721. private _render;
  97722. /**
  97723. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97724. * @param mesh Defines the mesh we want the helper attached to
  97725. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97726. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97727. * @param length Defines the length of the ray
  97728. */
  97729. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97730. /**
  97731. * Detach the ray helper from the mesh it has previously been attached to.
  97732. */
  97733. detachFromMesh(): void;
  97734. private _updateToMesh;
  97735. /**
  97736. * Dispose the helper and release its associated resources.
  97737. */
  97738. dispose(): void;
  97739. }
  97740. }
  97741. declare module BABYLON.Debug {
  97742. /**
  97743. * Class used to render a debug view of a given skeleton
  97744. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97745. */
  97746. export class SkeletonViewer {
  97747. /** defines the skeleton to render */
  97748. skeleton: Skeleton;
  97749. /** defines the mesh attached to the skeleton */
  97750. mesh: AbstractMesh;
  97751. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97752. autoUpdateBonesMatrices: boolean;
  97753. /** defines the rendering group id to use with the viewer */
  97754. renderingGroupId: number;
  97755. /** Gets or sets the color used to render the skeleton */
  97756. color: Color3;
  97757. private _scene;
  97758. private _debugLines;
  97759. private _debugMesh;
  97760. private _isEnabled;
  97761. private _renderFunction;
  97762. private _utilityLayer;
  97763. /**
  97764. * Returns the mesh used to render the bones
  97765. */
  97766. readonly debugMesh: Nullable<LinesMesh>;
  97767. /**
  97768. * Creates a new SkeletonViewer
  97769. * @param skeleton defines the skeleton to render
  97770. * @param mesh defines the mesh attached to the skeleton
  97771. * @param scene defines the hosting scene
  97772. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97773. * @param renderingGroupId defines the rendering group id to use with the viewer
  97774. */
  97775. constructor(
  97776. /** defines the skeleton to render */
  97777. skeleton: Skeleton,
  97778. /** defines the mesh attached to the skeleton */
  97779. mesh: AbstractMesh, scene: Scene,
  97780. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97781. autoUpdateBonesMatrices?: boolean,
  97782. /** defines the rendering group id to use with the viewer */
  97783. renderingGroupId?: number);
  97784. /** Gets or sets a boolean indicating if the viewer is enabled */
  97785. isEnabled: boolean;
  97786. private _getBonePosition;
  97787. private _getLinesForBonesWithLength;
  97788. private _getLinesForBonesNoLength;
  97789. /** Update the viewer to sync with current skeleton state */
  97790. update(): void;
  97791. /** Release associated resources */
  97792. dispose(): void;
  97793. }
  97794. }
  97795. declare module BABYLON {
  97796. /**
  97797. * Options to create the null engine
  97798. */
  97799. export class NullEngineOptions {
  97800. /**
  97801. * Render width (Default: 512)
  97802. */
  97803. renderWidth: number;
  97804. /**
  97805. * Render height (Default: 256)
  97806. */
  97807. renderHeight: number;
  97808. /**
  97809. * Texture size (Default: 512)
  97810. */
  97811. textureSize: number;
  97812. /**
  97813. * If delta time between frames should be constant
  97814. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97815. */
  97816. deterministicLockstep: boolean;
  97817. /**
  97818. * Maximum about of steps between frames (Default: 4)
  97819. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97820. */
  97821. lockstepMaxSteps: number;
  97822. }
  97823. /**
  97824. * The null engine class provides support for headless version of babylon.js.
  97825. * This can be used in server side scenario or for testing purposes
  97826. */
  97827. export class NullEngine extends Engine {
  97828. private _options;
  97829. /**
  97830. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97831. */
  97832. isDeterministicLockStep(): boolean;
  97833. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97834. getLockstepMaxSteps(): number;
  97835. /**
  97836. * Sets hardware scaling, used to save performance if needed
  97837. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97838. */
  97839. getHardwareScalingLevel(): number;
  97840. constructor(options?: NullEngineOptions);
  97841. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97842. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97843. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97844. getRenderWidth(useScreen?: boolean): number;
  97845. getRenderHeight(useScreen?: boolean): number;
  97846. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97847. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97848. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97849. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97850. bindSamplers(effect: Effect): void;
  97851. enableEffect(effect: Effect): void;
  97852. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97853. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97854. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97855. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97856. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97857. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97858. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97859. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97860. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97861. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97862. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97863. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97864. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97865. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97866. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97867. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97868. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97869. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97870. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97871. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97872. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97873. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97874. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97875. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97876. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97877. bindBuffers(vertexBuffers: {
  97878. [key: string]: VertexBuffer;
  97879. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97880. wipeCaches(bruteForce?: boolean): void;
  97881. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97882. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97883. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97884. /** @hidden */
  97885. _createTexture(): WebGLTexture;
  97886. /** @hidden */
  97887. _releaseTexture(texture: InternalTexture): void;
  97888. 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;
  97889. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97890. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97891. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97892. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97893. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97894. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97895. areAllEffectsReady(): boolean;
  97896. /**
  97897. * @hidden
  97898. * Get the current error code of the webGL context
  97899. * @returns the error code
  97900. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97901. */
  97902. getError(): number;
  97903. /** @hidden */
  97904. _getUnpackAlignement(): number;
  97905. /** @hidden */
  97906. _unpackFlipY(value: boolean): void;
  97907. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97908. /**
  97909. * Updates a dynamic vertex buffer.
  97910. * @param vertexBuffer the vertex buffer to update
  97911. * @param data the data used to update the vertex buffer
  97912. * @param byteOffset the byte offset of the data (optional)
  97913. * @param byteLength the byte length of the data (optional)
  97914. */
  97915. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97916. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97917. /** @hidden */
  97918. _bindTexture(channel: number, texture: InternalTexture): void;
  97919. /** @hidden */
  97920. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97921. releaseEffects(): void;
  97922. displayLoadingUI(): void;
  97923. hideLoadingUI(): void;
  97924. /** @hidden */
  97925. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97926. /** @hidden */
  97927. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97928. /** @hidden */
  97929. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97930. /** @hidden */
  97931. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97932. }
  97933. }
  97934. declare module BABYLON {
  97935. /** @hidden */
  97936. export class _OcclusionDataStorage {
  97937. /** @hidden */
  97938. occlusionInternalRetryCounter: number;
  97939. /** @hidden */
  97940. isOcclusionQueryInProgress: boolean;
  97941. /** @hidden */
  97942. isOccluded: boolean;
  97943. /** @hidden */
  97944. occlusionRetryCount: number;
  97945. /** @hidden */
  97946. occlusionType: number;
  97947. /** @hidden */
  97948. occlusionQueryAlgorithmType: number;
  97949. }
  97950. interface Engine {
  97951. /**
  97952. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97953. * @return the new query
  97954. */
  97955. createQuery(): WebGLQuery;
  97956. /**
  97957. * Delete and release a webGL query
  97958. * @param query defines the query to delete
  97959. * @return the current engine
  97960. */
  97961. deleteQuery(query: WebGLQuery): Engine;
  97962. /**
  97963. * Check if a given query has resolved and got its value
  97964. * @param query defines the query to check
  97965. * @returns true if the query got its value
  97966. */
  97967. isQueryResultAvailable(query: WebGLQuery): boolean;
  97968. /**
  97969. * Gets the value of a given query
  97970. * @param query defines the query to check
  97971. * @returns the value of the query
  97972. */
  97973. getQueryResult(query: WebGLQuery): number;
  97974. /**
  97975. * Initiates an occlusion query
  97976. * @param algorithmType defines the algorithm to use
  97977. * @param query defines the query to use
  97978. * @returns the current engine
  97979. * @see http://doc.babylonjs.com/features/occlusionquery
  97980. */
  97981. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97982. /**
  97983. * Ends an occlusion query
  97984. * @see http://doc.babylonjs.com/features/occlusionquery
  97985. * @param algorithmType defines the algorithm to use
  97986. * @returns the current engine
  97987. */
  97988. endOcclusionQuery(algorithmType: number): Engine;
  97989. /**
  97990. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97991. * Please note that only one query can be issued at a time
  97992. * @returns a time token used to track the time span
  97993. */
  97994. startTimeQuery(): Nullable<_TimeToken>;
  97995. /**
  97996. * Ends a time query
  97997. * @param token defines the token used to measure the time span
  97998. * @returns the time spent (in ns)
  97999. */
  98000. endTimeQuery(token: _TimeToken): int;
  98001. /** @hidden */
  98002. _currentNonTimestampToken: Nullable<_TimeToken>;
  98003. /** @hidden */
  98004. _createTimeQuery(): WebGLQuery;
  98005. /** @hidden */
  98006. _deleteTimeQuery(query: WebGLQuery): void;
  98007. /** @hidden */
  98008. _getGlAlgorithmType(algorithmType: number): number;
  98009. /** @hidden */
  98010. _getTimeQueryResult(query: WebGLQuery): any;
  98011. /** @hidden */
  98012. _getTimeQueryAvailability(query: WebGLQuery): any;
  98013. }
  98014. interface AbstractMesh {
  98015. /**
  98016. * Backing filed
  98017. * @hidden
  98018. */
  98019. __occlusionDataStorage: _OcclusionDataStorage;
  98020. /**
  98021. * Access property
  98022. * @hidden
  98023. */
  98024. _occlusionDataStorage: _OcclusionDataStorage;
  98025. /**
  98026. * 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.
  98027. * The default value is -1 which means don't break the query and wait till the result
  98028. * @see http://doc.babylonjs.com/features/occlusionquery
  98029. */
  98030. occlusionRetryCount: number;
  98031. /**
  98032. * 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:
  98033. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98034. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98035. * * 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.
  98036. * @see http://doc.babylonjs.com/features/occlusionquery
  98037. */
  98038. occlusionType: number;
  98039. /**
  98040. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98041. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98042. * * 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.
  98043. * @see http://doc.babylonjs.com/features/occlusionquery
  98044. */
  98045. occlusionQueryAlgorithmType: number;
  98046. /**
  98047. * 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
  98048. * @see http://doc.babylonjs.com/features/occlusionquery
  98049. */
  98050. isOccluded: boolean;
  98051. /**
  98052. * Flag to check the progress status of the query
  98053. * @see http://doc.babylonjs.com/features/occlusionquery
  98054. */
  98055. isOcclusionQueryInProgress: boolean;
  98056. }
  98057. }
  98058. declare module BABYLON {
  98059. /** @hidden */
  98060. export var _forceTransformFeedbackToBundle: boolean;
  98061. interface Engine {
  98062. /**
  98063. * Creates a webGL transform feedback object
  98064. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98065. * @returns the webGL transform feedback object
  98066. */
  98067. createTransformFeedback(): WebGLTransformFeedback;
  98068. /**
  98069. * Delete a webGL transform feedback object
  98070. * @param value defines the webGL transform feedback object to delete
  98071. */
  98072. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98073. /**
  98074. * Bind a webGL transform feedback object to the webgl context
  98075. * @param value defines the webGL transform feedback object to bind
  98076. */
  98077. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98078. /**
  98079. * Begins a transform feedback operation
  98080. * @param usePoints defines if points or triangles must be used
  98081. */
  98082. beginTransformFeedback(usePoints: boolean): void;
  98083. /**
  98084. * Ends a transform feedback operation
  98085. */
  98086. endTransformFeedback(): void;
  98087. /**
  98088. * Specify the varyings to use with transform feedback
  98089. * @param program defines the associated webGL program
  98090. * @param value defines the list of strings representing the varying names
  98091. */
  98092. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98093. /**
  98094. * Bind a webGL buffer for a transform feedback operation
  98095. * @param value defines the webGL buffer to bind
  98096. */
  98097. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98098. }
  98099. }
  98100. declare module BABYLON {
  98101. /**
  98102. * Gather the list of clipboard event types as constants.
  98103. */
  98104. export class ClipboardEventTypes {
  98105. /**
  98106. * The clipboard event is fired when a copy command is active (pressed).
  98107. */
  98108. static readonly COPY: number;
  98109. /**
  98110. * The clipboard event is fired when a cut command is active (pressed).
  98111. */
  98112. static readonly CUT: number;
  98113. /**
  98114. * The clipboard event is fired when a paste command is active (pressed).
  98115. */
  98116. static readonly PASTE: number;
  98117. }
  98118. /**
  98119. * This class is used to store clipboard related info for the onClipboardObservable event.
  98120. */
  98121. export class ClipboardInfo {
  98122. /**
  98123. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98124. */
  98125. type: number;
  98126. /**
  98127. * Defines the related dom event
  98128. */
  98129. event: ClipboardEvent;
  98130. /**
  98131. *Creates an instance of ClipboardInfo.
  98132. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98133. * @param event Defines the related dom event
  98134. */
  98135. constructor(
  98136. /**
  98137. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98138. */
  98139. type: number,
  98140. /**
  98141. * Defines the related dom event
  98142. */
  98143. event: ClipboardEvent);
  98144. /**
  98145. * Get the clipboard event's type from the keycode.
  98146. * @param keyCode Defines the keyCode for the current keyboard event.
  98147. * @return {number}
  98148. */
  98149. static GetTypeFromCharacter(keyCode: number): number;
  98150. }
  98151. }
  98152. declare module BABYLON {
  98153. /**
  98154. * Class used to represent data loading progression
  98155. */
  98156. export class SceneLoaderProgressEvent {
  98157. /** defines if data length to load can be evaluated */
  98158. readonly lengthComputable: boolean;
  98159. /** defines the loaded data length */
  98160. readonly loaded: number;
  98161. /** defines the data length to load */
  98162. readonly total: number;
  98163. /**
  98164. * Create a new progress event
  98165. * @param lengthComputable defines if data length to load can be evaluated
  98166. * @param loaded defines the loaded data length
  98167. * @param total defines the data length to load
  98168. */
  98169. constructor(
  98170. /** defines if data length to load can be evaluated */
  98171. lengthComputable: boolean,
  98172. /** defines the loaded data length */
  98173. loaded: number,
  98174. /** defines the data length to load */
  98175. total: number);
  98176. /**
  98177. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98178. * @param event defines the source event
  98179. * @returns a new SceneLoaderProgressEvent
  98180. */
  98181. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98182. }
  98183. /**
  98184. * Interface used by SceneLoader plugins to define supported file extensions
  98185. */
  98186. export interface ISceneLoaderPluginExtensions {
  98187. /**
  98188. * Defines the list of supported extensions
  98189. */
  98190. [extension: string]: {
  98191. isBinary: boolean;
  98192. };
  98193. }
  98194. /**
  98195. * Interface used by SceneLoader plugin factory
  98196. */
  98197. export interface ISceneLoaderPluginFactory {
  98198. /**
  98199. * Defines the name of the factory
  98200. */
  98201. name: string;
  98202. /**
  98203. * Function called to create a new plugin
  98204. * @return the new plugin
  98205. */
  98206. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98207. /**
  98208. * Boolean indicating if the plugin can direct load specific data
  98209. */
  98210. canDirectLoad?: (data: string) => boolean;
  98211. }
  98212. /**
  98213. * Interface used to define a SceneLoader plugin
  98214. */
  98215. export interface ISceneLoaderPlugin {
  98216. /**
  98217. * The friendly name of this plugin.
  98218. */
  98219. name: string;
  98220. /**
  98221. * The file extensions supported by this plugin.
  98222. */
  98223. extensions: string | ISceneLoaderPluginExtensions;
  98224. /**
  98225. * Import meshes into a scene.
  98226. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98227. * @param scene The scene to import into
  98228. * @param data The data to import
  98229. * @param rootUrl The root url for scene and resources
  98230. * @param meshes The meshes array to import into
  98231. * @param particleSystems The particle systems array to import into
  98232. * @param skeletons The skeletons array to import into
  98233. * @param onError The callback when import fails
  98234. * @returns True if successful or false otherwise
  98235. */
  98236. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98237. /**
  98238. * Load into a scene.
  98239. * @param scene The scene to load into
  98240. * @param data The data to import
  98241. * @param rootUrl The root url for scene and resources
  98242. * @param onError The callback when import fails
  98243. * @returns true if successful or false otherwise
  98244. */
  98245. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98246. /**
  98247. * The callback that returns true if the data can be directly loaded.
  98248. */
  98249. canDirectLoad?: (data: string) => boolean;
  98250. /**
  98251. * The callback that allows custom handling of the root url based on the response url.
  98252. */
  98253. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98254. /**
  98255. * Load into an asset container.
  98256. * @param scene The scene to load into
  98257. * @param data The data to import
  98258. * @param rootUrl The root url for scene and resources
  98259. * @param onError The callback when import fails
  98260. * @returns The loaded asset container
  98261. */
  98262. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98263. }
  98264. /**
  98265. * Interface used to define an async SceneLoader plugin
  98266. */
  98267. export interface ISceneLoaderPluginAsync {
  98268. /**
  98269. * The friendly name of this plugin.
  98270. */
  98271. name: string;
  98272. /**
  98273. * The file extensions supported by this plugin.
  98274. */
  98275. extensions: string | ISceneLoaderPluginExtensions;
  98276. /**
  98277. * Import meshes into a scene.
  98278. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98279. * @param scene The scene to import into
  98280. * @param data The data to import
  98281. * @param rootUrl The root url for scene and resources
  98282. * @param onProgress The callback when the load progresses
  98283. * @param fileName Defines the name of the file to load
  98284. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98285. */
  98286. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98287. meshes: AbstractMesh[];
  98288. particleSystems: IParticleSystem[];
  98289. skeletons: Skeleton[];
  98290. animationGroups: AnimationGroup[];
  98291. }>;
  98292. /**
  98293. * Load into a scene.
  98294. * @param scene The scene to load into
  98295. * @param data The data to import
  98296. * @param rootUrl The root url for scene and resources
  98297. * @param onProgress The callback when the load progresses
  98298. * @param fileName Defines the name of the file to load
  98299. * @returns Nothing
  98300. */
  98301. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98302. /**
  98303. * The callback that returns true if the data can be directly loaded.
  98304. */
  98305. canDirectLoad?: (data: string) => boolean;
  98306. /**
  98307. * The callback that allows custom handling of the root url based on the response url.
  98308. */
  98309. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98310. /**
  98311. * Load into an asset container.
  98312. * @param scene The scene to load into
  98313. * @param data The data to import
  98314. * @param rootUrl The root url for scene and resources
  98315. * @param onProgress The callback when the load progresses
  98316. * @param fileName Defines the name of the file to load
  98317. * @returns The loaded asset container
  98318. */
  98319. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98320. }
  98321. /**
  98322. * Class used to load scene from various file formats using registered plugins
  98323. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98324. */
  98325. export class SceneLoader {
  98326. /**
  98327. * No logging while loading
  98328. */
  98329. static readonly NO_LOGGING: number;
  98330. /**
  98331. * Minimal logging while loading
  98332. */
  98333. static readonly MINIMAL_LOGGING: number;
  98334. /**
  98335. * Summary logging while loading
  98336. */
  98337. static readonly SUMMARY_LOGGING: number;
  98338. /**
  98339. * Detailled logging while loading
  98340. */
  98341. static readonly DETAILED_LOGGING: number;
  98342. /**
  98343. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98344. */
  98345. static ForceFullSceneLoadingForIncremental: boolean;
  98346. /**
  98347. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98348. */
  98349. static ShowLoadingScreen: boolean;
  98350. /**
  98351. * Defines the current logging level (while loading the scene)
  98352. * @ignorenaming
  98353. */
  98354. static loggingLevel: number;
  98355. /**
  98356. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98357. */
  98358. static CleanBoneMatrixWeights: boolean;
  98359. /**
  98360. * Event raised when a plugin is used to load a scene
  98361. */
  98362. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98363. private static _registeredPlugins;
  98364. private static _getDefaultPlugin;
  98365. private static _getPluginForExtension;
  98366. private static _getPluginForDirectLoad;
  98367. private static _getPluginForFilename;
  98368. private static _getDirectLoad;
  98369. private static _loadData;
  98370. private static _getFileInfo;
  98371. /**
  98372. * Gets a plugin that can load the given extension
  98373. * @param extension defines the extension to load
  98374. * @returns a plugin or null if none works
  98375. */
  98376. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98377. /**
  98378. * Gets a boolean indicating that the given extension can be loaded
  98379. * @param extension defines the extension to load
  98380. * @returns true if the extension is supported
  98381. */
  98382. static IsPluginForExtensionAvailable(extension: string): boolean;
  98383. /**
  98384. * Adds a new plugin to the list of registered plugins
  98385. * @param plugin defines the plugin to add
  98386. */
  98387. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98388. /**
  98389. * Import meshes into a scene
  98390. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98391. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  98392. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  98393. * @param scene the instance of BABYLON.Scene to append to
  98394. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98395. * @param onProgress a callback with a progress event for each file being loaded
  98396. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98397. * @param pluginExtension the extension used to determine the plugin
  98398. * @returns The loaded plugin
  98399. */
  98400. 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>;
  98401. /**
  98402. * Import meshes into a scene
  98403. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98404. * @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)
  98405. * @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)
  98406. * @param scene the instance of BABYLON.Scene to append to
  98407. * @param onProgress a callback with a progress event for each file being loaded
  98408. * @param pluginExtension the extension used to determine the plugin
  98409. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98410. */
  98411. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98412. meshes: AbstractMesh[];
  98413. particleSystems: IParticleSystem[];
  98414. skeletons: Skeleton[];
  98415. animationGroups: AnimationGroup[];
  98416. }>;
  98417. /**
  98418. * Load a scene
  98419. * @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)
  98420. * @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)
  98421. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98422. * @param onSuccess a callback with the scene when import succeeds
  98423. * @param onProgress a callback with a progress event for each file being loaded
  98424. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98425. * @param pluginExtension the extension used to determine the plugin
  98426. * @returns The loaded plugin
  98427. */
  98428. 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>;
  98429. /**
  98430. * Load a scene
  98431. * @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)
  98432. * @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)
  98433. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98434. * @param onProgress a callback with a progress event for each file being loaded
  98435. * @param pluginExtension the extension used to determine the plugin
  98436. * @returns The loaded scene
  98437. */
  98438. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98439. /**
  98440. * Append a scene
  98441. * @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)
  98442. * @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)
  98443. * @param scene is the instance of BABYLON.Scene to append to
  98444. * @param onSuccess a callback with the scene when import succeeds
  98445. * @param onProgress a callback with a progress event for each file being loaded
  98446. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98447. * @param pluginExtension the extension used to determine the plugin
  98448. * @returns The loaded plugin
  98449. */
  98450. 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>;
  98451. /**
  98452. * Append a scene
  98453. * @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)
  98454. * @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)
  98455. * @param scene is the instance of BABYLON.Scene to append to
  98456. * @param onProgress a callback with a progress event for each file being loaded
  98457. * @param pluginExtension the extension used to determine the plugin
  98458. * @returns The given scene
  98459. */
  98460. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98461. /**
  98462. * Load a scene into an asset container
  98463. * @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)
  98464. * @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)
  98465. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98466. * @param onSuccess a callback with the scene when import succeeds
  98467. * @param onProgress a callback with a progress event for each file being loaded
  98468. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98469. * @param pluginExtension the extension used to determine the plugin
  98470. * @returns The loaded plugin
  98471. */
  98472. 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>;
  98473. /**
  98474. * Load a scene into an asset container
  98475. * @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)
  98476. * @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)
  98477. * @param scene is the instance of Scene to append to
  98478. * @param onProgress a callback with a progress event for each file being loaded
  98479. * @param pluginExtension the extension used to determine the plugin
  98480. * @returns The loaded asset container
  98481. */
  98482. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98483. }
  98484. }
  98485. declare module BABYLON {
  98486. /**
  98487. * Google Daydream controller
  98488. */
  98489. export class DaydreamController extends WebVRController {
  98490. /**
  98491. * Base Url for the controller model.
  98492. */
  98493. static MODEL_BASE_URL: string;
  98494. /**
  98495. * File name for the controller model.
  98496. */
  98497. static MODEL_FILENAME: string;
  98498. /**
  98499. * Gamepad Id prefix used to identify Daydream Controller.
  98500. */
  98501. static readonly GAMEPAD_ID_PREFIX: string;
  98502. /**
  98503. * Creates a new DaydreamController from a gamepad
  98504. * @param vrGamepad the gamepad that the controller should be created from
  98505. */
  98506. constructor(vrGamepad: any);
  98507. /**
  98508. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98509. * @param scene scene in which to add meshes
  98510. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98511. */
  98512. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98513. /**
  98514. * Called once for each button that changed state since the last frame
  98515. * @param buttonIdx Which button index changed
  98516. * @param state New state of the button
  98517. * @param changes Which properties on the state changed since last frame
  98518. */
  98519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98520. }
  98521. }
  98522. declare module BABYLON {
  98523. /**
  98524. * Gear VR Controller
  98525. */
  98526. export class GearVRController extends WebVRController {
  98527. /**
  98528. * Base Url for the controller model.
  98529. */
  98530. static MODEL_BASE_URL: string;
  98531. /**
  98532. * File name for the controller model.
  98533. */
  98534. static MODEL_FILENAME: string;
  98535. /**
  98536. * Gamepad Id prefix used to identify this controller.
  98537. */
  98538. static readonly GAMEPAD_ID_PREFIX: string;
  98539. private readonly _buttonIndexToObservableNameMap;
  98540. /**
  98541. * Creates a new GearVRController from a gamepad
  98542. * @param vrGamepad the gamepad that the controller should be created from
  98543. */
  98544. constructor(vrGamepad: any);
  98545. /**
  98546. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98547. * @param scene scene in which to add meshes
  98548. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98549. */
  98550. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98551. /**
  98552. * Called once for each button that changed state since the last frame
  98553. * @param buttonIdx Which button index changed
  98554. * @param state New state of the button
  98555. * @param changes Which properties on the state changed since last frame
  98556. */
  98557. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98558. }
  98559. }
  98560. declare module BABYLON {
  98561. /**
  98562. * Generic Controller
  98563. */
  98564. export class GenericController extends WebVRController {
  98565. /**
  98566. * Base Url for the controller model.
  98567. */
  98568. static readonly MODEL_BASE_URL: string;
  98569. /**
  98570. * File name for the controller model.
  98571. */
  98572. static readonly MODEL_FILENAME: string;
  98573. /**
  98574. * Creates a new GenericController from a gamepad
  98575. * @param vrGamepad the gamepad that the controller should be created from
  98576. */
  98577. constructor(vrGamepad: any);
  98578. /**
  98579. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98580. * @param scene scene in which to add meshes
  98581. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98582. */
  98583. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98584. /**
  98585. * Called once for each button that changed state since the last frame
  98586. * @param buttonIdx Which button index changed
  98587. * @param state New state of the button
  98588. * @param changes Which properties on the state changed since last frame
  98589. */
  98590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98591. }
  98592. }
  98593. declare module BABYLON {
  98594. /**
  98595. * Oculus Touch Controller
  98596. */
  98597. export class OculusTouchController extends WebVRController {
  98598. /**
  98599. * Base Url for the controller model.
  98600. */
  98601. static MODEL_BASE_URL: string;
  98602. /**
  98603. * File name for the left controller model.
  98604. */
  98605. static MODEL_LEFT_FILENAME: string;
  98606. /**
  98607. * File name for the right controller model.
  98608. */
  98609. static MODEL_RIGHT_FILENAME: string;
  98610. /**
  98611. * Fired when the secondary trigger on this controller is modified
  98612. */
  98613. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98614. /**
  98615. * Fired when the thumb rest on this controller is modified
  98616. */
  98617. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98618. /**
  98619. * Creates a new OculusTouchController from a gamepad
  98620. * @param vrGamepad the gamepad that the controller should be created from
  98621. */
  98622. constructor(vrGamepad: any);
  98623. /**
  98624. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98625. * @param scene scene in which to add meshes
  98626. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98627. */
  98628. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98629. /**
  98630. * Fired when the A button on this controller is modified
  98631. */
  98632. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98633. /**
  98634. * Fired when the B button on this controller is modified
  98635. */
  98636. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98637. /**
  98638. * Fired when the X button on this controller is modified
  98639. */
  98640. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98641. /**
  98642. * Fired when the Y button on this controller is modified
  98643. */
  98644. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98645. /**
  98646. * Called once for each button that changed state since the last frame
  98647. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98648. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98649. * 2) secondary trigger (same)
  98650. * 3) A (right) X (left), touch, pressed = value
  98651. * 4) B / Y
  98652. * 5) thumb rest
  98653. * @param buttonIdx Which button index changed
  98654. * @param state New state of the button
  98655. * @param changes Which properties on the state changed since last frame
  98656. */
  98657. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98658. }
  98659. }
  98660. declare module BABYLON {
  98661. /**
  98662. * Vive Controller
  98663. */
  98664. export class ViveController extends WebVRController {
  98665. /**
  98666. * Base Url for the controller model.
  98667. */
  98668. static MODEL_BASE_URL: string;
  98669. /**
  98670. * File name for the controller model.
  98671. */
  98672. static MODEL_FILENAME: string;
  98673. /**
  98674. * Creates a new ViveController from a gamepad
  98675. * @param vrGamepad the gamepad that the controller should be created from
  98676. */
  98677. constructor(vrGamepad: any);
  98678. /**
  98679. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98680. * @param scene scene in which to add meshes
  98681. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98682. */
  98683. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98684. /**
  98685. * Fired when the left button on this controller is modified
  98686. */
  98687. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98688. /**
  98689. * Fired when the right button on this controller is modified
  98690. */
  98691. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98692. /**
  98693. * Fired when the menu button on this controller is modified
  98694. */
  98695. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98696. /**
  98697. * Called once for each button that changed state since the last frame
  98698. * Vive mapping:
  98699. * 0: touchpad
  98700. * 1: trigger
  98701. * 2: left AND right buttons
  98702. * 3: menu button
  98703. * @param buttonIdx Which button index changed
  98704. * @param state New state of the button
  98705. * @param changes Which properties on the state changed since last frame
  98706. */
  98707. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98708. }
  98709. }
  98710. declare module BABYLON {
  98711. /**
  98712. * Defines the WindowsMotionController object that the state of the windows motion controller
  98713. */
  98714. export class WindowsMotionController extends WebVRController {
  98715. /**
  98716. * The base url used to load the left and right controller models
  98717. */
  98718. static MODEL_BASE_URL: string;
  98719. /**
  98720. * The name of the left controller model file
  98721. */
  98722. static MODEL_LEFT_FILENAME: string;
  98723. /**
  98724. * The name of the right controller model file
  98725. */
  98726. static MODEL_RIGHT_FILENAME: string;
  98727. /**
  98728. * The controller name prefix for this controller type
  98729. */
  98730. static readonly GAMEPAD_ID_PREFIX: string;
  98731. /**
  98732. * The controller id pattern for this controller type
  98733. */
  98734. private static readonly GAMEPAD_ID_PATTERN;
  98735. private _loadedMeshInfo;
  98736. private readonly _mapping;
  98737. /**
  98738. * Fired when the trackpad on this controller is clicked
  98739. */
  98740. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98741. /**
  98742. * Fired when the trackpad on this controller is modified
  98743. */
  98744. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98745. /**
  98746. * The current x and y values of this controller's trackpad
  98747. */
  98748. trackpad: StickValues;
  98749. /**
  98750. * Creates a new WindowsMotionController from a gamepad
  98751. * @param vrGamepad the gamepad that the controller should be created from
  98752. */
  98753. constructor(vrGamepad: any);
  98754. /**
  98755. * Fired when the trigger on this controller is modified
  98756. */
  98757. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98758. /**
  98759. * Fired when the menu button on this controller is modified
  98760. */
  98761. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98762. /**
  98763. * Fired when the grip button on this controller is modified
  98764. */
  98765. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98766. /**
  98767. * Fired when the thumbstick button on this controller is modified
  98768. */
  98769. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98770. /**
  98771. * Fired when the touchpad button on this controller is modified
  98772. */
  98773. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98774. /**
  98775. * Fired when the touchpad values on this controller are modified
  98776. */
  98777. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98778. private _updateTrackpad;
  98779. /**
  98780. * Called once per frame by the engine.
  98781. */
  98782. update(): void;
  98783. /**
  98784. * Called once for each button that changed state since the last frame
  98785. * @param buttonIdx Which button index changed
  98786. * @param state New state of the button
  98787. * @param changes Which properties on the state changed since last frame
  98788. */
  98789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98790. /**
  98791. * Moves the buttons on the controller mesh based on their current state
  98792. * @param buttonName the name of the button to move
  98793. * @param buttonValue the value of the button which determines the buttons new position
  98794. */
  98795. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98796. /**
  98797. * Moves the axis on the controller mesh based on its current state
  98798. * @param axis the index of the axis
  98799. * @param axisValue the value of the axis which determines the meshes new position
  98800. * @hidden
  98801. */
  98802. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98803. /**
  98804. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98805. * @param scene scene in which to add meshes
  98806. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98807. */
  98808. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98809. /**
  98810. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98811. * can be transformed by button presses and axes values, based on this._mapping.
  98812. *
  98813. * @param scene scene in which the meshes exist
  98814. * @param meshes list of meshes that make up the controller model to process
  98815. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98816. */
  98817. private processModel;
  98818. private createMeshInfo;
  98819. /**
  98820. * Gets the ray of the controller in the direction the controller is pointing
  98821. * @param length the length the resulting ray should be
  98822. * @returns a ray in the direction the controller is pointing
  98823. */
  98824. getForwardRay(length?: number): Ray;
  98825. /**
  98826. * Disposes of the controller
  98827. */
  98828. dispose(): void;
  98829. }
  98830. }
  98831. declare module BABYLON {
  98832. /**
  98833. * Single axis scale gizmo
  98834. */
  98835. export class AxisScaleGizmo extends Gizmo {
  98836. private _coloredMaterial;
  98837. /**
  98838. * Drag behavior responsible for the gizmos dragging interactions
  98839. */
  98840. dragBehavior: PointerDragBehavior;
  98841. private _pointerObserver;
  98842. /**
  98843. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98844. */
  98845. snapDistance: number;
  98846. /**
  98847. * Event that fires each time the gizmo snaps to a new location.
  98848. * * snapDistance is the the change in distance
  98849. */
  98850. onSnapObservable: Observable<{
  98851. snapDistance: number;
  98852. }>;
  98853. /**
  98854. * If the scaling operation should be done on all axis (default: false)
  98855. */
  98856. uniformScaling: boolean;
  98857. /**
  98858. * Creates an AxisScaleGizmo
  98859. * @param gizmoLayer The utility layer the gizmo will be added to
  98860. * @param dragAxis The axis which the gizmo will be able to scale on
  98861. * @param color The color of the gizmo
  98862. */
  98863. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98865. /**
  98866. * Disposes of the gizmo
  98867. */
  98868. dispose(): void;
  98869. /**
  98870. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98871. * @param mesh The mesh to replace the default mesh of the gizmo
  98872. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98873. */
  98874. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98875. }
  98876. }
  98877. declare module BABYLON {
  98878. /**
  98879. * Bounding box gizmo
  98880. */
  98881. export class BoundingBoxGizmo extends Gizmo {
  98882. private _lineBoundingBox;
  98883. private _rotateSpheresParent;
  98884. private _scaleBoxesParent;
  98885. private _boundingDimensions;
  98886. private _renderObserver;
  98887. private _pointerObserver;
  98888. private _scaleDragSpeed;
  98889. private _tmpQuaternion;
  98890. private _tmpVector;
  98891. private _tmpRotationMatrix;
  98892. /**
  98893. * 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)
  98894. */
  98895. ignoreChildren: boolean;
  98896. /**
  98897. * 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)
  98898. */
  98899. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98900. /**
  98901. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98902. */
  98903. rotationSphereSize: number;
  98904. /**
  98905. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98906. */
  98907. scaleBoxSize: number;
  98908. /**
  98909. * 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)
  98910. */
  98911. fixedDragMeshScreenSize: boolean;
  98912. /**
  98913. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98914. */
  98915. fixedDragMeshScreenSizeDistanceFactor: number;
  98916. /**
  98917. * Fired when a rotation sphere or scale box is dragged
  98918. */
  98919. onDragStartObservable: Observable<{}>;
  98920. /**
  98921. * Fired when a scale box is dragged
  98922. */
  98923. onScaleBoxDragObservable: Observable<{}>;
  98924. /**
  98925. * Fired when a scale box drag is ended
  98926. */
  98927. onScaleBoxDragEndObservable: Observable<{}>;
  98928. /**
  98929. * Fired when a rotation sphere is dragged
  98930. */
  98931. onRotationSphereDragObservable: Observable<{}>;
  98932. /**
  98933. * Fired when a rotation sphere drag is ended
  98934. */
  98935. onRotationSphereDragEndObservable: Observable<{}>;
  98936. /**
  98937. * 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)
  98938. */
  98939. scalePivot: Nullable<Vector3>;
  98940. private _anchorMesh;
  98941. private _existingMeshScale;
  98942. private _dragMesh;
  98943. private pointerDragBehavior;
  98944. private coloredMaterial;
  98945. private hoverColoredMaterial;
  98946. /**
  98947. * Sets the color of the bounding box gizmo
  98948. * @param color the color to set
  98949. */
  98950. setColor(color: Color3): void;
  98951. /**
  98952. * Creates an BoundingBoxGizmo
  98953. * @param gizmoLayer The utility layer the gizmo will be added to
  98954. * @param color The color of the gizmo
  98955. */
  98956. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98957. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98958. private _selectNode;
  98959. /**
  98960. * Updates the bounding box information for the Gizmo
  98961. */
  98962. updateBoundingBox(): void;
  98963. private _updateRotationSpheres;
  98964. private _updateScaleBoxes;
  98965. /**
  98966. * Enables rotation on the specified axis and disables rotation on the others
  98967. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98968. */
  98969. setEnabledRotationAxis(axis: string): void;
  98970. /**
  98971. * Enables/disables scaling
  98972. * @param enable if scaling should be enabled
  98973. */
  98974. setEnabledScaling(enable: boolean): void;
  98975. private _updateDummy;
  98976. /**
  98977. * Enables a pointer drag behavior on the bounding box of the gizmo
  98978. */
  98979. enableDragBehavior(): void;
  98980. /**
  98981. * Disposes of the gizmo
  98982. */
  98983. dispose(): void;
  98984. /**
  98985. * 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)
  98986. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98987. * @returns the bounding box mesh with the passed in mesh as a child
  98988. */
  98989. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98990. /**
  98991. * CustomMeshes are not supported by this gizmo
  98992. * @param mesh The mesh to replace the default mesh of the gizmo
  98993. */
  98994. setCustomMesh(mesh: Mesh): void;
  98995. }
  98996. }
  98997. declare module BABYLON {
  98998. /**
  98999. * Single plane rotation gizmo
  99000. */
  99001. export class PlaneRotationGizmo extends Gizmo {
  99002. /**
  99003. * Drag behavior responsible for the gizmos dragging interactions
  99004. */
  99005. dragBehavior: PointerDragBehavior;
  99006. private _pointerObserver;
  99007. /**
  99008. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99009. */
  99010. snapDistance: number;
  99011. /**
  99012. * Event that fires each time the gizmo snaps to a new location.
  99013. * * snapDistance is the the change in distance
  99014. */
  99015. onSnapObservable: Observable<{
  99016. snapDistance: number;
  99017. }>;
  99018. /**
  99019. * Creates a PlaneRotationGizmo
  99020. * @param gizmoLayer The utility layer the gizmo will be added to
  99021. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99022. * @param color The color of the gizmo
  99023. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99024. */
  99025. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99026. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99027. /**
  99028. * Disposes of the gizmo
  99029. */
  99030. dispose(): void;
  99031. }
  99032. }
  99033. declare module BABYLON {
  99034. /**
  99035. * Gizmo that enables rotating a mesh along 3 axis
  99036. */
  99037. export class RotationGizmo extends Gizmo {
  99038. /**
  99039. * Internal gizmo used for interactions on the x axis
  99040. */
  99041. xGizmo: PlaneRotationGizmo;
  99042. /**
  99043. * Internal gizmo used for interactions on the y axis
  99044. */
  99045. yGizmo: PlaneRotationGizmo;
  99046. /**
  99047. * Internal gizmo used for interactions on the z axis
  99048. */
  99049. zGizmo: PlaneRotationGizmo;
  99050. /** Fires an event when any of it's sub gizmos are dragged */
  99051. onDragStartObservable: Observable<{}>;
  99052. /** Fires an event when any of it's sub gizmos are released from dragging */
  99053. onDragEndObservable: Observable<{}>;
  99054. attachedMesh: Nullable<AbstractMesh>;
  99055. /**
  99056. * Creates a RotationGizmo
  99057. * @param gizmoLayer The utility layer the gizmo will be added to
  99058. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99059. */
  99060. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99061. updateGizmoRotationToMatchAttachedMesh: boolean;
  99062. /**
  99063. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99064. */
  99065. snapDistance: number;
  99066. /**
  99067. * Ratio for the scale of the gizmo (Default: 1)
  99068. */
  99069. scaleRatio: number;
  99070. /**
  99071. * Disposes of the gizmo
  99072. */
  99073. dispose(): void;
  99074. /**
  99075. * CustomMeshes are not supported by this gizmo
  99076. * @param mesh The mesh to replace the default mesh of the gizmo
  99077. */
  99078. setCustomMesh(mesh: Mesh): void;
  99079. }
  99080. }
  99081. declare module BABYLON {
  99082. /**
  99083. * Gizmo that enables dragging a mesh along 3 axis
  99084. */
  99085. export class PositionGizmo extends Gizmo {
  99086. /**
  99087. * Internal gizmo used for interactions on the x axis
  99088. */
  99089. xGizmo: AxisDragGizmo;
  99090. /**
  99091. * Internal gizmo used for interactions on the y axis
  99092. */
  99093. yGizmo: AxisDragGizmo;
  99094. /**
  99095. * Internal gizmo used for interactions on the z axis
  99096. */
  99097. zGizmo: AxisDragGizmo;
  99098. /** Fires an event when any of it's sub gizmos are dragged */
  99099. onDragStartObservable: Observable<{}>;
  99100. /** Fires an event when any of it's sub gizmos are released from dragging */
  99101. onDragEndObservable: Observable<{}>;
  99102. attachedMesh: Nullable<AbstractMesh>;
  99103. /**
  99104. * Creates a PositionGizmo
  99105. * @param gizmoLayer The utility layer the gizmo will be added to
  99106. */
  99107. constructor(gizmoLayer?: UtilityLayerRenderer);
  99108. updateGizmoRotationToMatchAttachedMesh: boolean;
  99109. /**
  99110. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99111. */
  99112. snapDistance: number;
  99113. /**
  99114. * Ratio for the scale of the gizmo (Default: 1)
  99115. */
  99116. scaleRatio: number;
  99117. /**
  99118. * Disposes of the gizmo
  99119. */
  99120. dispose(): void;
  99121. /**
  99122. * CustomMeshes are not supported by this gizmo
  99123. * @param mesh The mesh to replace the default mesh of the gizmo
  99124. */
  99125. setCustomMesh(mesh: Mesh): void;
  99126. }
  99127. }
  99128. declare module BABYLON {
  99129. /**
  99130. * Class containing static functions to help procedurally build meshes
  99131. */
  99132. export class PolyhedronBuilder {
  99133. /**
  99134. * Creates a polyhedron mesh
  99135. * * 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
  99136. * * The parameter `size` (positive float, default 1) sets the polygon size
  99137. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99138. * * 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`
  99139. * * 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
  99140. * * 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)`)
  99141. * * 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
  99142. * * 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
  99143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99144. * * If you create a double-sided mesh, you can choose what parts of 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
  99145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99146. * @param name defines the name of the mesh
  99147. * @param options defines the options used to create the mesh
  99148. * @param scene defines the hosting scene
  99149. * @returns the polyhedron mesh
  99150. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99151. */
  99152. static CreatePolyhedron(name: string, options: {
  99153. type?: number;
  99154. size?: number;
  99155. sizeX?: number;
  99156. sizeY?: number;
  99157. sizeZ?: number;
  99158. custom?: any;
  99159. faceUV?: Vector4[];
  99160. faceColors?: Color4[];
  99161. flat?: boolean;
  99162. updatable?: boolean;
  99163. sideOrientation?: number;
  99164. frontUVs?: Vector4;
  99165. backUVs?: Vector4;
  99166. }, scene: Scene): Mesh;
  99167. }
  99168. }
  99169. declare module BABYLON {
  99170. /**
  99171. * Gizmo that enables scaling a mesh along 3 axis
  99172. */
  99173. export class ScaleGizmo extends Gizmo {
  99174. /**
  99175. * Internal gizmo used for interactions on the x axis
  99176. */
  99177. xGizmo: AxisScaleGizmo;
  99178. /**
  99179. * Internal gizmo used for interactions on the y axis
  99180. */
  99181. yGizmo: AxisScaleGizmo;
  99182. /**
  99183. * Internal gizmo used for interactions on the z axis
  99184. */
  99185. zGizmo: AxisScaleGizmo;
  99186. /**
  99187. * Internal gizmo used to scale all axis equally
  99188. */
  99189. uniformScaleGizmo: AxisScaleGizmo;
  99190. /** Fires an event when any of it's sub gizmos are dragged */
  99191. onDragStartObservable: Observable<{}>;
  99192. /** Fires an event when any of it's sub gizmos are released from dragging */
  99193. onDragEndObservable: Observable<{}>;
  99194. attachedMesh: Nullable<AbstractMesh>;
  99195. /**
  99196. * Creates a ScaleGizmo
  99197. * @param gizmoLayer The utility layer the gizmo will be added to
  99198. */
  99199. constructor(gizmoLayer?: UtilityLayerRenderer);
  99200. updateGizmoRotationToMatchAttachedMesh: boolean;
  99201. /**
  99202. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99203. */
  99204. snapDistance: number;
  99205. /**
  99206. * Ratio for the scale of the gizmo (Default: 1)
  99207. */
  99208. scaleRatio: number;
  99209. /**
  99210. * Disposes of the gizmo
  99211. */
  99212. dispose(): void;
  99213. }
  99214. }
  99215. declare module BABYLON {
  99216. /**
  99217. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99218. */
  99219. export class GizmoManager implements IDisposable {
  99220. private scene;
  99221. /**
  99222. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99223. */
  99224. gizmos: {
  99225. positionGizmo: Nullable<PositionGizmo>;
  99226. rotationGizmo: Nullable<RotationGizmo>;
  99227. scaleGizmo: Nullable<ScaleGizmo>;
  99228. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99229. };
  99230. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99231. clearGizmoOnEmptyPointerEvent: boolean;
  99232. /** Fires an event when the manager is attached to a mesh */
  99233. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99234. private _gizmosEnabled;
  99235. private _pointerObserver;
  99236. private _attachedMesh;
  99237. private _boundingBoxColor;
  99238. private _defaultUtilityLayer;
  99239. private _defaultKeepDepthUtilityLayer;
  99240. /**
  99241. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99242. */
  99243. boundingBoxDragBehavior: SixDofDragBehavior;
  99244. /**
  99245. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99246. */
  99247. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99248. /**
  99249. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99250. */
  99251. usePointerToAttachGizmos: boolean;
  99252. /**
  99253. * Instatiates a gizmo manager
  99254. * @param scene the scene to overlay the gizmos on top of
  99255. */
  99256. constructor(scene: Scene);
  99257. /**
  99258. * Attaches a set of gizmos to the specified mesh
  99259. * @param mesh The mesh the gizmo's should be attached to
  99260. */
  99261. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99262. /**
  99263. * If the position gizmo is enabled
  99264. */
  99265. positionGizmoEnabled: boolean;
  99266. /**
  99267. * If the rotation gizmo is enabled
  99268. */
  99269. rotationGizmoEnabled: boolean;
  99270. /**
  99271. * If the scale gizmo is enabled
  99272. */
  99273. scaleGizmoEnabled: boolean;
  99274. /**
  99275. * If the boundingBox gizmo is enabled
  99276. */
  99277. boundingBoxGizmoEnabled: boolean;
  99278. /**
  99279. * Disposes of the gizmo manager
  99280. */
  99281. dispose(): void;
  99282. }
  99283. }
  99284. declare module BABYLON {
  99285. /**
  99286. * Gizmo that enables viewing a light
  99287. */
  99288. export class LightGizmo extends Gizmo {
  99289. private _box;
  99290. /**
  99291. * Creates a LightGizmo
  99292. * @param gizmoLayer The utility layer the gizmo will be added to
  99293. */
  99294. constructor(gizmoLayer?: UtilityLayerRenderer);
  99295. private _light;
  99296. /**
  99297. * The light that the gizmo is attached to
  99298. */
  99299. light: Nullable<Light>;
  99300. /**
  99301. * @hidden
  99302. * Updates the gizmo to match the attached mesh's position/rotation
  99303. */
  99304. protected _update(): void;
  99305. }
  99306. }
  99307. declare module BABYLON {
  99308. /** @hidden */
  99309. export var backgroundFragmentDeclaration: {
  99310. name: string;
  99311. shader: string;
  99312. };
  99313. }
  99314. declare module BABYLON {
  99315. /** @hidden */
  99316. export var backgroundUboDeclaration: {
  99317. name: string;
  99318. shader: string;
  99319. };
  99320. }
  99321. declare module BABYLON {
  99322. /** @hidden */
  99323. export var backgroundPixelShader: {
  99324. name: string;
  99325. shader: string;
  99326. };
  99327. }
  99328. declare module BABYLON {
  99329. /** @hidden */
  99330. export var backgroundVertexDeclaration: {
  99331. name: string;
  99332. shader: string;
  99333. };
  99334. }
  99335. declare module BABYLON {
  99336. /** @hidden */
  99337. export var backgroundVertexShader: {
  99338. name: string;
  99339. shader: string;
  99340. };
  99341. }
  99342. declare module BABYLON {
  99343. /**
  99344. * Background material used to create an efficient environement around your scene.
  99345. */
  99346. export class BackgroundMaterial extends PushMaterial {
  99347. /**
  99348. * Standard reflectance value at parallel view angle.
  99349. */
  99350. static StandardReflectance0: number;
  99351. /**
  99352. * Standard reflectance value at grazing angle.
  99353. */
  99354. static StandardReflectance90: number;
  99355. protected _primaryColor: Color3;
  99356. /**
  99357. * Key light Color (multiply against the environement texture)
  99358. */
  99359. primaryColor: Color3;
  99360. protected __perceptualColor: Nullable<Color3>;
  99361. /**
  99362. * Experimental Internal Use Only.
  99363. *
  99364. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99365. * This acts as a helper to set the primary color to a more "human friendly" value.
  99366. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99367. * output color as close as possible from the chosen value.
  99368. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99369. * part of lighting setup.)
  99370. */
  99371. _perceptualColor: Nullable<Color3>;
  99372. protected _primaryColorShadowLevel: float;
  99373. /**
  99374. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99375. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99376. */
  99377. primaryColorShadowLevel: float;
  99378. protected _primaryColorHighlightLevel: float;
  99379. /**
  99380. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99381. * The primary color is used at the level chosen to define what the white area would look.
  99382. */
  99383. primaryColorHighlightLevel: float;
  99384. protected _reflectionTexture: Nullable<BaseTexture>;
  99385. /**
  99386. * Reflection Texture used in the material.
  99387. * Should be author in a specific way for the best result (refer to the documentation).
  99388. */
  99389. reflectionTexture: Nullable<BaseTexture>;
  99390. protected _reflectionBlur: float;
  99391. /**
  99392. * Reflection Texture level of blur.
  99393. *
  99394. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99395. * texture twice.
  99396. */
  99397. reflectionBlur: float;
  99398. protected _diffuseTexture: Nullable<BaseTexture>;
  99399. /**
  99400. * Diffuse Texture used in the material.
  99401. * Should be author in a specific way for the best result (refer to the documentation).
  99402. */
  99403. diffuseTexture: Nullable<BaseTexture>;
  99404. protected _shadowLights: Nullable<IShadowLight[]>;
  99405. /**
  99406. * Specify the list of lights casting shadow on the material.
  99407. * All scene shadow lights will be included if null.
  99408. */
  99409. shadowLights: Nullable<IShadowLight[]>;
  99410. protected _shadowLevel: float;
  99411. /**
  99412. * Helps adjusting the shadow to a softer level if required.
  99413. * 0 means black shadows and 1 means no shadows.
  99414. */
  99415. shadowLevel: float;
  99416. protected _sceneCenter: Vector3;
  99417. /**
  99418. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99419. * It is usually zero but might be interesting to modify according to your setup.
  99420. */
  99421. sceneCenter: Vector3;
  99422. protected _opacityFresnel: boolean;
  99423. /**
  99424. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99425. * This helps ensuring a nice transition when the camera goes under the ground.
  99426. */
  99427. opacityFresnel: boolean;
  99428. protected _reflectionFresnel: boolean;
  99429. /**
  99430. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99431. * This helps adding a mirror texture on the ground.
  99432. */
  99433. reflectionFresnel: boolean;
  99434. protected _reflectionFalloffDistance: number;
  99435. /**
  99436. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99437. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99438. */
  99439. reflectionFalloffDistance: number;
  99440. protected _reflectionAmount: number;
  99441. /**
  99442. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99443. */
  99444. reflectionAmount: number;
  99445. protected _reflectionReflectance0: number;
  99446. /**
  99447. * This specifies the weight of the reflection at grazing angle.
  99448. */
  99449. reflectionReflectance0: number;
  99450. protected _reflectionReflectance90: number;
  99451. /**
  99452. * This specifies the weight of the reflection at a perpendicular point of view.
  99453. */
  99454. reflectionReflectance90: number;
  99455. /**
  99456. * Sets the reflection reflectance fresnel values according to the default standard
  99457. * empirically know to work well :-)
  99458. */
  99459. reflectionStandardFresnelWeight: number;
  99460. protected _useRGBColor: boolean;
  99461. /**
  99462. * Helps to directly use the maps channels instead of their level.
  99463. */
  99464. useRGBColor: boolean;
  99465. protected _enableNoise: boolean;
  99466. /**
  99467. * This helps reducing the banding effect that could occur on the background.
  99468. */
  99469. enableNoise: boolean;
  99470. /**
  99471. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99472. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99473. * Recommended to be keep at 1.0 except for special cases.
  99474. */
  99475. fovMultiplier: number;
  99476. private _fovMultiplier;
  99477. /**
  99478. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99479. */
  99480. useEquirectangularFOV: boolean;
  99481. private _maxSimultaneousLights;
  99482. /**
  99483. * Number of Simultaneous lights allowed on the material.
  99484. */
  99485. maxSimultaneousLights: int;
  99486. /**
  99487. * Default configuration related to image processing available in the Background Material.
  99488. */
  99489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99490. /**
  99491. * Keep track of the image processing observer to allow dispose and replace.
  99492. */
  99493. private _imageProcessingObserver;
  99494. /**
  99495. * Attaches a new image processing configuration to the PBR Material.
  99496. * @param configuration (if null the scene configuration will be use)
  99497. */
  99498. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99499. /**
  99500. * Gets the image processing configuration used either in this material.
  99501. */
  99502. /**
  99503. * Sets the Default image processing configuration used either in the this material.
  99504. *
  99505. * If sets to null, the scene one is in use.
  99506. */
  99507. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99508. /**
  99509. * Gets wether the color curves effect is enabled.
  99510. */
  99511. /**
  99512. * Sets wether the color curves effect is enabled.
  99513. */
  99514. cameraColorCurvesEnabled: boolean;
  99515. /**
  99516. * Gets wether the color grading effect is enabled.
  99517. */
  99518. /**
  99519. * Gets wether the color grading effect is enabled.
  99520. */
  99521. cameraColorGradingEnabled: boolean;
  99522. /**
  99523. * Gets wether tonemapping is enabled or not.
  99524. */
  99525. /**
  99526. * Sets wether tonemapping is enabled or not
  99527. */
  99528. cameraToneMappingEnabled: boolean;
  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. /**
  99535. * The camera exposure used on this material.
  99536. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99537. * This corresponds to a photographic exposure.
  99538. */
  99539. cameraExposure: float;
  99540. /**
  99541. * Gets The camera contrast used on this material.
  99542. */
  99543. /**
  99544. * Sets The camera contrast used on this material.
  99545. */
  99546. cameraContrast: float;
  99547. /**
  99548. * Gets the Color Grading 2D Lookup Texture.
  99549. */
  99550. /**
  99551. * Sets the Color Grading 2D Lookup Texture.
  99552. */
  99553. cameraColorGradingTexture: Nullable<BaseTexture>;
  99554. /**
  99555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99557. * 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;
  99558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99559. */
  99560. /**
  99561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99563. * 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;
  99564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99565. */
  99566. cameraColorCurves: Nullable<ColorCurves>;
  99567. /**
  99568. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99569. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99570. */
  99571. switchToBGR: boolean;
  99572. private _renderTargets;
  99573. private _reflectionControls;
  99574. private _white;
  99575. private _primaryShadowColor;
  99576. private _primaryHighlightColor;
  99577. /**
  99578. * Instantiates a Background Material in the given scene
  99579. * @param name The friendly name of the material
  99580. * @param scene The scene to add the material to
  99581. */
  99582. constructor(name: string, scene: Scene);
  99583. /**
  99584. * Gets a boolean indicating that current material needs to register RTT
  99585. */
  99586. readonly hasRenderTargetTextures: boolean;
  99587. /**
  99588. * The entire material has been created in order to prevent overdraw.
  99589. * @returns false
  99590. */
  99591. needAlphaTesting(): boolean;
  99592. /**
  99593. * The entire material has been created in order to prevent overdraw.
  99594. * @returns true if blending is enable
  99595. */
  99596. needAlphaBlending(): boolean;
  99597. /**
  99598. * Checks wether the material is ready to be rendered for a given mesh.
  99599. * @param mesh The mesh to render
  99600. * @param subMesh The submesh to check against
  99601. * @param useInstances Specify wether or not the material is used with instances
  99602. * @returns true if all the dependencies are ready (Textures, Effects...)
  99603. */
  99604. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99605. /**
  99606. * Compute the primary color according to the chosen perceptual color.
  99607. */
  99608. private _computePrimaryColorFromPerceptualColor;
  99609. /**
  99610. * Compute the highlights and shadow colors according to their chosen levels.
  99611. */
  99612. private _computePrimaryColors;
  99613. /**
  99614. * Build the uniform buffer used in the material.
  99615. */
  99616. buildUniformLayout(): void;
  99617. /**
  99618. * Unbind the material.
  99619. */
  99620. unbind(): void;
  99621. /**
  99622. * Bind only the world matrix to the material.
  99623. * @param world The world matrix to bind.
  99624. */
  99625. bindOnlyWorldMatrix(world: Matrix): void;
  99626. /**
  99627. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99628. * @param world The world matrix to bind.
  99629. * @param subMesh The submesh to bind for.
  99630. */
  99631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99632. /**
  99633. * Dispose the material.
  99634. * @param forceDisposeEffect Force disposal of the associated effect.
  99635. * @param forceDisposeTextures Force disposal of the associated textures.
  99636. */
  99637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99638. /**
  99639. * Clones the material.
  99640. * @param name The cloned name.
  99641. * @returns The cloned material.
  99642. */
  99643. clone(name: string): BackgroundMaterial;
  99644. /**
  99645. * Serializes the current material to its JSON representation.
  99646. * @returns The JSON representation.
  99647. */
  99648. serialize(): any;
  99649. /**
  99650. * Gets the class name of the material
  99651. * @returns "BackgroundMaterial"
  99652. */
  99653. getClassName(): string;
  99654. /**
  99655. * Parse a JSON input to create back a background material.
  99656. * @param source The JSON data to parse
  99657. * @param scene The scene to create the parsed material in
  99658. * @param rootUrl The root url of the assets the material depends upon
  99659. * @returns the instantiated BackgroundMaterial.
  99660. */
  99661. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99662. }
  99663. }
  99664. declare module BABYLON {
  99665. /**
  99666. * Represents the different options available during the creation of
  99667. * a Environment helper.
  99668. *
  99669. * This can control the default ground, skybox and image processing setup of your scene.
  99670. */
  99671. export interface IEnvironmentHelperOptions {
  99672. /**
  99673. * Specifies wether or not to create a ground.
  99674. * True by default.
  99675. */
  99676. createGround: boolean;
  99677. /**
  99678. * Specifies the ground size.
  99679. * 15 by default.
  99680. */
  99681. groundSize: number;
  99682. /**
  99683. * The texture used on the ground for the main color.
  99684. * Comes from the BabylonJS CDN by default.
  99685. *
  99686. * Remarks: Can be either a texture or a url.
  99687. */
  99688. groundTexture: string | BaseTexture;
  99689. /**
  99690. * The color mixed in the ground texture by default.
  99691. * BabylonJS clearColor by default.
  99692. */
  99693. groundColor: Color3;
  99694. /**
  99695. * Specifies the ground opacity.
  99696. * 1 by default.
  99697. */
  99698. groundOpacity: number;
  99699. /**
  99700. * Enables the ground to receive shadows.
  99701. * True by default.
  99702. */
  99703. enableGroundShadow: boolean;
  99704. /**
  99705. * Helps preventing the shadow to be fully black on the ground.
  99706. * 0.5 by default.
  99707. */
  99708. groundShadowLevel: number;
  99709. /**
  99710. * Creates a mirror texture attach to the ground.
  99711. * false by default.
  99712. */
  99713. enableGroundMirror: boolean;
  99714. /**
  99715. * Specifies the ground mirror size ratio.
  99716. * 0.3 by default as the default kernel is 64.
  99717. */
  99718. groundMirrorSizeRatio: number;
  99719. /**
  99720. * Specifies the ground mirror blur kernel size.
  99721. * 64 by default.
  99722. */
  99723. groundMirrorBlurKernel: number;
  99724. /**
  99725. * Specifies the ground mirror visibility amount.
  99726. * 1 by default
  99727. */
  99728. groundMirrorAmount: number;
  99729. /**
  99730. * Specifies the ground mirror reflectance weight.
  99731. * This uses the standard weight of the background material to setup the fresnel effect
  99732. * of the mirror.
  99733. * 1 by default.
  99734. */
  99735. groundMirrorFresnelWeight: number;
  99736. /**
  99737. * Specifies the ground mirror Falloff distance.
  99738. * This can helps reducing the size of the reflection.
  99739. * 0 by Default.
  99740. */
  99741. groundMirrorFallOffDistance: number;
  99742. /**
  99743. * Specifies the ground mirror texture type.
  99744. * Unsigned Int by Default.
  99745. */
  99746. groundMirrorTextureType: number;
  99747. /**
  99748. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99749. * the shown objects.
  99750. */
  99751. groundYBias: number;
  99752. /**
  99753. * Specifies wether or not to create a skybox.
  99754. * True by default.
  99755. */
  99756. createSkybox: boolean;
  99757. /**
  99758. * Specifies the skybox size.
  99759. * 20 by default.
  99760. */
  99761. skyboxSize: number;
  99762. /**
  99763. * The texture used on the skybox for the main color.
  99764. * Comes from the BabylonJS CDN by default.
  99765. *
  99766. * Remarks: Can be either a texture or a url.
  99767. */
  99768. skyboxTexture: string | BaseTexture;
  99769. /**
  99770. * The color mixed in the skybox texture by default.
  99771. * BabylonJS clearColor by default.
  99772. */
  99773. skyboxColor: Color3;
  99774. /**
  99775. * The background rotation around the Y axis of the scene.
  99776. * This helps aligning the key lights of your scene with the background.
  99777. * 0 by default.
  99778. */
  99779. backgroundYRotation: number;
  99780. /**
  99781. * Compute automatically the size of the elements to best fit with the scene.
  99782. */
  99783. sizeAuto: boolean;
  99784. /**
  99785. * Default position of the rootMesh if autoSize is not true.
  99786. */
  99787. rootPosition: Vector3;
  99788. /**
  99789. * Sets up the image processing in the scene.
  99790. * true by default.
  99791. */
  99792. setupImageProcessing: boolean;
  99793. /**
  99794. * The texture used as your environment texture in the scene.
  99795. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99796. *
  99797. * Remarks: Can be either a texture or a url.
  99798. */
  99799. environmentTexture: string | BaseTexture;
  99800. /**
  99801. * The value of the exposure to apply to the scene.
  99802. * 0.6 by default if setupImageProcessing is true.
  99803. */
  99804. cameraExposure: number;
  99805. /**
  99806. * The value of the contrast to apply to the scene.
  99807. * 1.6 by default if setupImageProcessing is true.
  99808. */
  99809. cameraContrast: number;
  99810. /**
  99811. * Specifies wether or not tonemapping should be enabled in the scene.
  99812. * true by default if setupImageProcessing is true.
  99813. */
  99814. toneMappingEnabled: boolean;
  99815. }
  99816. /**
  99817. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99818. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99819. * It also helps with the default setup of your imageProcessing configuration.
  99820. */
  99821. export class EnvironmentHelper {
  99822. /**
  99823. * Default ground texture URL.
  99824. */
  99825. private static _groundTextureCDNUrl;
  99826. /**
  99827. * Default skybox texture URL.
  99828. */
  99829. private static _skyboxTextureCDNUrl;
  99830. /**
  99831. * Default environment texture URL.
  99832. */
  99833. private static _environmentTextureCDNUrl;
  99834. /**
  99835. * Creates the default options for the helper.
  99836. */
  99837. private static _getDefaultOptions;
  99838. private _rootMesh;
  99839. /**
  99840. * Gets the root mesh created by the helper.
  99841. */
  99842. readonly rootMesh: Mesh;
  99843. private _skybox;
  99844. /**
  99845. * Gets the skybox created by the helper.
  99846. */
  99847. readonly skybox: Nullable<Mesh>;
  99848. private _skyboxTexture;
  99849. /**
  99850. * Gets the skybox texture created by the helper.
  99851. */
  99852. readonly skyboxTexture: Nullable<BaseTexture>;
  99853. private _skyboxMaterial;
  99854. /**
  99855. * Gets the skybox material created by the helper.
  99856. */
  99857. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99858. private _ground;
  99859. /**
  99860. * Gets the ground mesh created by the helper.
  99861. */
  99862. readonly ground: Nullable<Mesh>;
  99863. private _groundTexture;
  99864. /**
  99865. * Gets the ground texture created by the helper.
  99866. */
  99867. readonly groundTexture: Nullable<BaseTexture>;
  99868. private _groundMirror;
  99869. /**
  99870. * Gets the ground mirror created by the helper.
  99871. */
  99872. readonly groundMirror: Nullable<MirrorTexture>;
  99873. /**
  99874. * Gets the ground mirror render list to helps pushing the meshes
  99875. * you wish in the ground reflection.
  99876. */
  99877. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99878. private _groundMaterial;
  99879. /**
  99880. * Gets the ground material created by the helper.
  99881. */
  99882. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99883. /**
  99884. * Stores the creation options.
  99885. */
  99886. private readonly _scene;
  99887. private _options;
  99888. /**
  99889. * This observable will be notified with any error during the creation of the environment,
  99890. * mainly texture creation errors.
  99891. */
  99892. onErrorObservable: Observable<{
  99893. message?: string;
  99894. exception?: any;
  99895. }>;
  99896. /**
  99897. * constructor
  99898. * @param options Defines the options we want to customize the helper
  99899. * @param scene The scene to add the material to
  99900. */
  99901. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99902. /**
  99903. * Updates the background according to the new options
  99904. * @param options
  99905. */
  99906. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99907. /**
  99908. * Sets the primary color of all the available elements.
  99909. * @param color the main color to affect to the ground and the background
  99910. */
  99911. setMainColor(color: Color3): void;
  99912. /**
  99913. * Setup the image processing according to the specified options.
  99914. */
  99915. private _setupImageProcessing;
  99916. /**
  99917. * Setup the environment texture according to the specified options.
  99918. */
  99919. private _setupEnvironmentTexture;
  99920. /**
  99921. * Setup the background according to the specified options.
  99922. */
  99923. private _setupBackground;
  99924. /**
  99925. * Get the scene sizes according to the setup.
  99926. */
  99927. private _getSceneSize;
  99928. /**
  99929. * Setup the ground according to the specified options.
  99930. */
  99931. private _setupGround;
  99932. /**
  99933. * Setup the ground material according to the specified options.
  99934. */
  99935. private _setupGroundMaterial;
  99936. /**
  99937. * Setup the ground diffuse texture according to the specified options.
  99938. */
  99939. private _setupGroundDiffuseTexture;
  99940. /**
  99941. * Setup the ground mirror texture according to the specified options.
  99942. */
  99943. private _setupGroundMirrorTexture;
  99944. /**
  99945. * Setup the ground to receive the mirror texture.
  99946. */
  99947. private _setupMirrorInGroundMaterial;
  99948. /**
  99949. * Setup the skybox according to the specified options.
  99950. */
  99951. private _setupSkybox;
  99952. /**
  99953. * Setup the skybox material according to the specified options.
  99954. */
  99955. private _setupSkyboxMaterial;
  99956. /**
  99957. * Setup the skybox reflection texture according to the specified options.
  99958. */
  99959. private _setupSkyboxReflectionTexture;
  99960. private _errorHandler;
  99961. /**
  99962. * Dispose all the elements created by the Helper.
  99963. */
  99964. dispose(): void;
  99965. }
  99966. }
  99967. declare module BABYLON {
  99968. /**
  99969. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99970. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99971. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99972. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99973. */
  99974. export class PhotoDome extends TransformNode {
  99975. private _useDirectMapping;
  99976. /**
  99977. * The texture being displayed on the sphere
  99978. */
  99979. protected _photoTexture: Texture;
  99980. /**
  99981. * Gets or sets the texture being displayed on the sphere
  99982. */
  99983. photoTexture: Texture;
  99984. /**
  99985. * Observable raised when an error occured while loading the 360 image
  99986. */
  99987. onLoadErrorObservable: Observable<string>;
  99988. /**
  99989. * The skybox material
  99990. */
  99991. protected _material: BackgroundMaterial;
  99992. /**
  99993. * The surface used for the skybox
  99994. */
  99995. protected _mesh: Mesh;
  99996. /**
  99997. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99998. * Also see the options.resolution property.
  99999. */
  100000. fovMultiplier: number;
  100001. /**
  100002. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100003. * @param name Element's name, child elements will append suffixes for their own names.
  100004. * @param urlsOfPhoto defines the url of the photo to display
  100005. * @param options defines an object containing optional or exposed sub element properties
  100006. * @param onError defines a callback called when an error occured while loading the texture
  100007. */
  100008. constructor(name: string, urlOfPhoto: string, options: {
  100009. resolution?: number;
  100010. size?: number;
  100011. useDirectMapping?: boolean;
  100012. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100013. /**
  100014. * Releases resources associated with this node.
  100015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100017. */
  100018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100019. }
  100020. }
  100021. declare module BABYLON {
  100022. /**
  100023. * Class used to host texture specific utilities
  100024. */
  100025. export class TextureTools {
  100026. /**
  100027. * Uses the GPU to create a copy texture rescaled at a given size
  100028. * @param texture Texture to copy from
  100029. * @param width defines the desired width
  100030. * @param height defines the desired height
  100031. * @param useBilinearMode defines if bilinear mode has to be used
  100032. * @return the generated texture
  100033. */
  100034. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100035. /**
  100036. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100037. * @param scene defines the hosting scene
  100038. * @returns the environment BRDF texture
  100039. */
  100040. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100041. private static _environmentBRDFBase64Texture;
  100042. }
  100043. }
  100044. declare module BABYLON {
  100045. /**
  100046. * @hidden
  100047. */
  100048. export interface IMaterialClearCoatDefines {
  100049. CLEARCOAT: boolean;
  100050. CLEARCOAT_DEFAULTIOR: boolean;
  100051. CLEARCOAT_TEXTURE: boolean;
  100052. CLEARCOAT_TEXTUREDIRECTUV: number;
  100053. CLEARCOAT_BUMP: boolean;
  100054. CLEARCOAT_BUMPDIRECTUV: number;
  100055. CLEARCOAT_TINT: boolean;
  100056. CLEARCOAT_TINT_TEXTURE: boolean;
  100057. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100058. /** @hidden */
  100059. _areTexturesDirty: boolean;
  100060. }
  100061. /**
  100062. * Define the code related to the clear coat parameters of the pbr material.
  100063. */
  100064. export class PBRClearCoatConfiguration {
  100065. /**
  100066. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100067. * The default fits with a polyurethane material.
  100068. */
  100069. private static readonly _DefaultIndiceOfRefraction;
  100070. private _isEnabled;
  100071. /**
  100072. * Defines if the clear coat is enabled in the material.
  100073. */
  100074. isEnabled: boolean;
  100075. /**
  100076. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100077. */
  100078. intensity: number;
  100079. /**
  100080. * Defines the clear coat layer roughness.
  100081. */
  100082. roughness: number;
  100083. private _indiceOfRefraction;
  100084. /**
  100085. * Defines the indice of refraction of the clear coat.
  100086. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100087. * The default fits with a polyurethane material.
  100088. * Changing the default value is more performance intensive.
  100089. */
  100090. indiceOfRefraction: number;
  100091. private _texture;
  100092. /**
  100093. * Stores the clear coat values in a texture.
  100094. */
  100095. texture: Nullable<BaseTexture>;
  100096. private _bumpTexture;
  100097. /**
  100098. * Define the clear coat specific bump texture.
  100099. */
  100100. bumpTexture: Nullable<BaseTexture>;
  100101. private _isTintEnabled;
  100102. /**
  100103. * Defines if the clear coat tint is enabled in the material.
  100104. */
  100105. isTintEnabled: boolean;
  100106. /**
  100107. * Defines if the clear coat tint is enabled in the material.
  100108. * This is only use if tint is enabled
  100109. */
  100110. tintColor: Color3;
  100111. /**
  100112. * Defines if the distance at which the tint color should be found in the
  100113. * clear coat media.
  100114. * This is only use if tint is enabled
  100115. */
  100116. tintColorAtDistance: number;
  100117. /**
  100118. * Defines the clear coat layer thickness.
  100119. * This is only use if tint is enabled
  100120. */
  100121. tintThickness: number;
  100122. private _tintTexture;
  100123. /**
  100124. * Stores the clear tint values in a texture.
  100125. * rgb is tint
  100126. * a is a thickness factor
  100127. */
  100128. tintTexture: Nullable<BaseTexture>;
  100129. /** @hidden */
  100130. private _internalMarkAllSubMeshesAsTexturesDirty;
  100131. /** @hidden */
  100132. _markAllSubMeshesAsTexturesDirty(): void;
  100133. /**
  100134. * Instantiate a new istance of clear coat configuration.
  100135. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100136. */
  100137. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100138. /**
  100139. * Specifies that the submesh is ready to be used.
  100140. * @param defines the list of "defines" to update.
  100141. * @param scene defines the scene the material belongs to.
  100142. * @param engine defines the engine the material belongs to.
  100143. * @param disableBumpMap defines wether the material disables bump or not.
  100144. * @returns - boolean indicating that the submesh is ready or not.
  100145. */
  100146. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100147. /**
  100148. * Checks to see if a texture is used in the material.
  100149. * @param defines the list of "defines" to update.
  100150. * @param scene defines the scene to the material belongs to.
  100151. */
  100152. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100153. /**
  100154. * Binds the material data.
  100155. * @param uniformBuffer defines the Uniform buffer to fill in.
  100156. * @param scene defines the scene the material belongs to.
  100157. * @param engine defines the engine the material belongs to.
  100158. * @param disableBumpMap defines wether the material disables bump or not.
  100159. * @param isFrozen defines wether the material is frozen or not.
  100160. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100161. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100162. */
  100163. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100164. /**
  100165. * Checks to see if a texture is used in the material.
  100166. * @param texture - Base texture to use.
  100167. * @returns - Boolean specifying if a texture is used in the material.
  100168. */
  100169. hasTexture(texture: BaseTexture): boolean;
  100170. /**
  100171. * Returns an array of the actively used textures.
  100172. * @param activeTextures Array of BaseTextures
  100173. */
  100174. getActiveTextures(activeTextures: BaseTexture[]): void;
  100175. /**
  100176. * Returns the animatable textures.
  100177. * @param animatables Array of animatable textures.
  100178. */
  100179. getAnimatables(animatables: IAnimatable[]): void;
  100180. /**
  100181. * Disposes the resources of the material.
  100182. * @param forceDisposeTextures - Forces the disposal of all textures.
  100183. */
  100184. dispose(forceDisposeTextures?: boolean): void;
  100185. /**
  100186. * Get the current class name of the texture useful for serialization or dynamic coding.
  100187. * @returns "PBRClearCoatConfiguration"
  100188. */
  100189. getClassName(): string;
  100190. /**
  100191. * Makes a duplicate of the current configuration into another one.
  100192. * @param clearCoatConfiguration define the config where to copy the info
  100193. */
  100194. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100195. /**
  100196. * Serializes this clear coat configuration.
  100197. * @returns - An object with the serialized config.
  100198. */
  100199. serialize(): any;
  100200. /**
  100201. * Parses a Clear Coat Configuration from a serialized object.
  100202. * @param source - Serialized object.
  100203. */
  100204. parse(source: any): void;
  100205. /**
  100206. * Add fallbacks to the effect fallbacks list.
  100207. * @param defines defines the Base texture to use.
  100208. * @param fallbacks defines the current fallback list.
  100209. * @param currentRank defines the current fallback rank.
  100210. * @returns the new fallback rank.
  100211. */
  100212. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100213. /**
  100214. * Add the required uniforms to the current list.
  100215. * @param uniforms defines the current uniform list.
  100216. */
  100217. static AddUniforms(uniforms: string[]): void;
  100218. /**
  100219. * Add the required samplers to the current list.
  100220. * @param samplers defines the current sampler list.
  100221. */
  100222. static AddSamplers(samplers: string[]): void;
  100223. /**
  100224. * Add the required uniforms to the current buffer.
  100225. * @param uniformBuffer defines the current uniform buffer.
  100226. */
  100227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100228. }
  100229. }
  100230. declare module BABYLON {
  100231. /**
  100232. * @hidden
  100233. */
  100234. export interface IMaterialAnisotropicDefines {
  100235. ANISOTROPIC: boolean;
  100236. MAINUV1: boolean;
  100237. _areMiscDirty: boolean;
  100238. _needUVs: boolean;
  100239. }
  100240. /**
  100241. * Define the code related to the anisotropic parameters of the pbr material.
  100242. */
  100243. export class PBRAnisotropicConfiguration {
  100244. private _isEnabled;
  100245. /**
  100246. * Defines if the anisotropy is enabled in the material.
  100247. */
  100248. isEnabled: boolean;
  100249. /**
  100250. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100251. */
  100252. intensity: number;
  100253. /**
  100254. * Defines if the effect is along the tangents or bitangents.
  100255. * By default, the effect is "strectching" the highlights along the tangents.
  100256. */
  100257. followTangents: boolean;
  100258. /** @hidden */
  100259. private _internalMarkAllSubMeshesAsMiscDirty;
  100260. /** @hidden */
  100261. _markAllSubMeshesAsMiscDirty(): void;
  100262. /**
  100263. * Instantiate a new istance of clear coat configuration.
  100264. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100265. */
  100266. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100267. /**
  100268. * Checks to see if a texture is used in the material.
  100269. * @param defines the list of "defines" to update.
  100270. * @param mesh the mesh we are preparing the defines for.
  100271. */
  100272. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  100273. /**
  100274. * Binds the material data.
  100275. * @param uniformBuffer defines the Uniform buffer to fill in.
  100276. * @param isFrozen defines wether the material is frozen or not.
  100277. */
  100278. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  100279. /**
  100280. * Get the current class name of the texture useful for serialization or dynamic coding.
  100281. * @returns "PBRAnisotropicConfiguration"
  100282. */
  100283. getClassName(): string;
  100284. /**
  100285. * Makes a duplicate of the current configuration into another one.
  100286. * @param anisotropicConfiguration define the config where to copy the info
  100287. */
  100288. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100289. /**
  100290. * Serializes this clear coat configuration.
  100291. * @returns - An object with the serialized config.
  100292. */
  100293. serialize(): any;
  100294. /**
  100295. * Parses a Clear Coat Configuration from a serialized object.
  100296. * @param source - Serialized object.
  100297. */
  100298. parse(source: any): void;
  100299. /**
  100300. * Add fallbacks to the effect fallbacks list.
  100301. * @param defines defines the Base texture to use.
  100302. * @param fallbacks defines the current fallback list.
  100303. * @param currentRank defines the current fallback rank.
  100304. * @returns the new fallback rank.
  100305. */
  100306. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100307. /**
  100308. * Add the required uniforms to the current list.
  100309. * @param uniforms defines the current uniform list.
  100310. */
  100311. static AddUniforms(uniforms: string[]): void;
  100312. /**
  100313. * Add the required uniforms to the current buffer.
  100314. * @param uniformBuffer defines the current uniform buffer.
  100315. */
  100316. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100317. }
  100318. }
  100319. declare module BABYLON {
  100320. /**
  100321. * @hidden
  100322. */
  100323. export interface IMaterialBRDFDefines {
  100324. BRDF_V_HEIGHT_CORRELATED: boolean;
  100325. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100326. /** @hidden */
  100327. _areMiscDirty: boolean;
  100328. }
  100329. /**
  100330. * Define the code related to the BRDF parameters of the pbr material.
  100331. */
  100332. export class PBRBRDFConfiguration {
  100333. private _useEnergyConservation;
  100334. /**
  100335. * Defines if the material uses energy conservation.
  100336. */
  100337. useEnergyConservation: boolean;
  100338. private _useSmithVisibilityHeightCorrelated;
  100339. /**
  100340. * LEGACY Mode set to false
  100341. * Defines if the material uses height smith correlated visibility term.
  100342. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100343. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100344. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100345. * Not relying on height correlated will also disable energy conservation.
  100346. */
  100347. useSmithVisibilityHeightCorrelated: boolean;
  100348. /** @hidden */
  100349. private _internalMarkAllSubMeshesAsMiscDirty;
  100350. /** @hidden */
  100351. _markAllSubMeshesAsMiscDirty(): void;
  100352. /**
  100353. * Instantiate a new istance of clear coat configuration.
  100354. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100355. */
  100356. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100357. /**
  100358. * Checks to see if a texture is used in the material.
  100359. * @param defines the list of "defines" to update.
  100360. */
  100361. prepareDefines(defines: IMaterialBRDFDefines): void;
  100362. /**
  100363. * Get the current class name of the texture useful for serialization or dynamic coding.
  100364. * @returns "PBRClearCoatConfiguration"
  100365. */
  100366. getClassName(): string;
  100367. /**
  100368. * Makes a duplicate of the current configuration into another one.
  100369. * @param brdfConfiguration define the config where to copy the info
  100370. */
  100371. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100372. /**
  100373. * Serializes this BRDF configuration.
  100374. * @returns - An object with the serialized config.
  100375. */
  100376. serialize(): any;
  100377. /**
  100378. * Parses a BRDF Configuration from a serialized object.
  100379. * @param source - Serialized object.
  100380. */
  100381. parse(source: any): void;
  100382. }
  100383. }
  100384. declare module BABYLON {
  100385. /** @hidden */
  100386. export var pbrFragmentDeclaration: {
  100387. name: string;
  100388. shader: string;
  100389. };
  100390. }
  100391. declare module BABYLON {
  100392. /** @hidden */
  100393. export var pbrUboDeclaration: {
  100394. name: string;
  100395. shader: string;
  100396. };
  100397. }
  100398. declare module BABYLON {
  100399. /** @hidden */
  100400. export var pbrFunctions: {
  100401. name: string;
  100402. shader: string;
  100403. };
  100404. }
  100405. declare module BABYLON {
  100406. /** @hidden */
  100407. export var harmonicsFunctions: {
  100408. name: string;
  100409. shader: string;
  100410. };
  100411. }
  100412. declare module BABYLON {
  100413. /** @hidden */
  100414. export var pbrPreLightingFunctions: {
  100415. name: string;
  100416. shader: string;
  100417. };
  100418. }
  100419. declare module BABYLON {
  100420. /** @hidden */
  100421. export var pbrFalloffLightingFunctions: {
  100422. name: string;
  100423. shader: string;
  100424. };
  100425. }
  100426. declare module BABYLON {
  100427. /** @hidden */
  100428. export var pbrLightingFunctions: {
  100429. name: string;
  100430. shader: string;
  100431. };
  100432. }
  100433. declare module BABYLON {
  100434. /** @hidden */
  100435. export var pbrDebug: {
  100436. name: string;
  100437. shader: string;
  100438. };
  100439. }
  100440. declare module BABYLON {
  100441. /** @hidden */
  100442. export var pbrPixelShader: {
  100443. name: string;
  100444. shader: string;
  100445. };
  100446. }
  100447. declare module BABYLON {
  100448. /** @hidden */
  100449. export var pbrVertexDeclaration: {
  100450. name: string;
  100451. shader: string;
  100452. };
  100453. }
  100454. declare module BABYLON {
  100455. /** @hidden */
  100456. export var pbrVertexShader: {
  100457. name: string;
  100458. shader: string;
  100459. };
  100460. }
  100461. declare module BABYLON {
  100462. /**
  100463. * The Physically based material base class of BJS.
  100464. *
  100465. * This offers the main features of a standard PBR material.
  100466. * For more information, please refer to the documentation :
  100467. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100468. */
  100469. export abstract class PBRBaseMaterial extends PushMaterial {
  100470. /**
  100471. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100472. */
  100473. static readonly PBRMATERIAL_OPAQUE: number;
  100474. /**
  100475. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100476. */
  100477. static readonly PBRMATERIAL_ALPHATEST: number;
  100478. /**
  100479. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100480. */
  100481. static readonly PBRMATERIAL_ALPHABLEND: number;
  100482. /**
  100483. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100484. * They are also discarded below the alpha cutoff threshold to improve performances.
  100485. */
  100486. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100487. /**
  100488. * Defines the default value of how much AO map is occluding the analytical lights
  100489. * (point spot...).
  100490. */
  100491. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100492. /**
  100493. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100494. */
  100495. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100496. /**
  100497. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100498. * to enhance interoperability with other engines.
  100499. */
  100500. static readonly LIGHTFALLOFF_GLTF: number;
  100501. /**
  100502. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100503. * to enhance interoperability with other materials.
  100504. */
  100505. static readonly LIGHTFALLOFF_STANDARD: number;
  100506. /**
  100507. * Intensity of the direct lights e.g. the four lights available in your scene.
  100508. * This impacts both the direct diffuse and specular highlights.
  100509. */
  100510. protected _directIntensity: number;
  100511. /**
  100512. * Intensity of the emissive part of the material.
  100513. * This helps controlling the emissive effect without modifying the emissive color.
  100514. */
  100515. protected _emissiveIntensity: number;
  100516. /**
  100517. * Intensity of the environment e.g. how much the environment will light the object
  100518. * either through harmonics for rough material or through the refelction for shiny ones.
  100519. */
  100520. protected _environmentIntensity: number;
  100521. /**
  100522. * This is a special control allowing the reduction of the specular highlights coming from the
  100523. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100524. */
  100525. protected _specularIntensity: number;
  100526. /**
  100527. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100528. */
  100529. private _lightingInfos;
  100530. /**
  100531. * Debug Control allowing disabling the bump map on this material.
  100532. */
  100533. protected _disableBumpMap: boolean;
  100534. /**
  100535. * AKA Diffuse Texture in standard nomenclature.
  100536. */
  100537. protected _albedoTexture: BaseTexture;
  100538. /**
  100539. * AKA Occlusion Texture in other nomenclature.
  100540. */
  100541. protected _ambientTexture: BaseTexture;
  100542. /**
  100543. * AKA Occlusion Texture Intensity in other nomenclature.
  100544. */
  100545. protected _ambientTextureStrength: number;
  100546. /**
  100547. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100548. * 1 means it completely occludes it
  100549. * 0 mean it has no impact
  100550. */
  100551. protected _ambientTextureImpactOnAnalyticalLights: number;
  100552. /**
  100553. * Stores the alpha values in a texture.
  100554. */
  100555. protected _opacityTexture: BaseTexture;
  100556. /**
  100557. * Stores the reflection values in a texture.
  100558. */
  100559. protected _reflectionTexture: BaseTexture;
  100560. /**
  100561. * Stores the refraction values in a texture.
  100562. */
  100563. protected _refractionTexture: BaseTexture;
  100564. /**
  100565. * Stores the emissive values in a texture.
  100566. */
  100567. protected _emissiveTexture: BaseTexture;
  100568. /**
  100569. * AKA Specular texture in other nomenclature.
  100570. */
  100571. protected _reflectivityTexture: BaseTexture;
  100572. /**
  100573. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100574. */
  100575. protected _metallicTexture: BaseTexture;
  100576. /**
  100577. * Specifies the metallic scalar of the metallic/roughness workflow.
  100578. * Can also be used to scale the metalness values of the metallic texture.
  100579. */
  100580. protected _metallic: Nullable<number>;
  100581. /**
  100582. * Specifies the roughness scalar of the metallic/roughness workflow.
  100583. * Can also be used to scale the roughness values of the metallic texture.
  100584. */
  100585. protected _roughness: Nullable<number>;
  100586. /**
  100587. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100588. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100589. */
  100590. protected _microSurfaceTexture: BaseTexture;
  100591. /**
  100592. * Stores surface normal data used to displace a mesh in a texture.
  100593. */
  100594. protected _bumpTexture: BaseTexture;
  100595. /**
  100596. * Stores the pre-calculated light information of a mesh in a texture.
  100597. */
  100598. protected _lightmapTexture: BaseTexture;
  100599. /**
  100600. * The color of a material in ambient lighting.
  100601. */
  100602. protected _ambientColor: Color3;
  100603. /**
  100604. * AKA Diffuse Color in other nomenclature.
  100605. */
  100606. protected _albedoColor: Color3;
  100607. /**
  100608. * AKA Specular Color in other nomenclature.
  100609. */
  100610. protected _reflectivityColor: Color3;
  100611. /**
  100612. * The color applied when light is reflected from a material.
  100613. */
  100614. protected _reflectionColor: Color3;
  100615. /**
  100616. * The color applied when light is emitted from a material.
  100617. */
  100618. protected _emissiveColor: Color3;
  100619. /**
  100620. * AKA Glossiness in other nomenclature.
  100621. */
  100622. protected _microSurface: number;
  100623. /**
  100624. * source material index of refraction (IOR)' / 'destination material IOR.
  100625. */
  100626. protected _indexOfRefraction: number;
  100627. /**
  100628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100629. */
  100630. protected _invertRefractionY: boolean;
  100631. /**
  100632. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100633. * Materials half opaque for instance using refraction could benefit from this control.
  100634. */
  100635. protected _linkRefractionWithTransparency: boolean;
  100636. /**
  100637. * Specifies that the material will use the light map as a show map.
  100638. */
  100639. protected _useLightmapAsShadowmap: boolean;
  100640. /**
  100641. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100642. * makes the reflect vector face the model (under horizon).
  100643. */
  100644. protected _useHorizonOcclusion: boolean;
  100645. /**
  100646. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100647. * too much the area relying on ambient texture to define their ambient occlusion.
  100648. */
  100649. protected _useRadianceOcclusion: boolean;
  100650. /**
  100651. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100652. */
  100653. protected _useAlphaFromAlbedoTexture: boolean;
  100654. /**
  100655. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  100656. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100657. */
  100658. protected _useSpecularOverAlpha: boolean;
  100659. /**
  100660. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100661. */
  100662. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100663. /**
  100664. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100665. */
  100666. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  100667. /**
  100668. * Specifies if the metallic texture contains the roughness information in its green channel.
  100669. */
  100670. protected _useRoughnessFromMetallicTextureGreen: boolean;
  100671. /**
  100672. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100673. */
  100674. protected _useMetallnessFromMetallicTextureBlue: boolean;
  100675. /**
  100676. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100677. */
  100678. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  100679. /**
  100680. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100681. */
  100682. protected _useAmbientInGrayScale: boolean;
  100683. /**
  100684. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100685. * The material will try to infer what glossiness each pixel should be.
  100686. */
  100687. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  100688. /**
  100689. * Defines the falloff type used in this material.
  100690. * It by default is Physical.
  100691. */
  100692. protected _lightFalloff: number;
  100693. /**
  100694. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100695. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100696. */
  100697. protected _useRadianceOverAlpha: boolean;
  100698. /**
  100699. * Allows using an object space normal map (instead of tangent space).
  100700. */
  100701. protected _useObjectSpaceNormalMap: boolean;
  100702. /**
  100703. * Allows using the bump map in parallax mode.
  100704. */
  100705. protected _useParallax: boolean;
  100706. /**
  100707. * Allows using the bump map in parallax occlusion mode.
  100708. */
  100709. protected _useParallaxOcclusion: boolean;
  100710. /**
  100711. * Controls the scale bias of the parallax mode.
  100712. */
  100713. protected _parallaxScaleBias: number;
  100714. /**
  100715. * If sets to true, disables all the lights affecting the material.
  100716. */
  100717. protected _disableLighting: boolean;
  100718. /**
  100719. * Number of Simultaneous lights allowed on the material.
  100720. */
  100721. protected _maxSimultaneousLights: number;
  100722. /**
  100723. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100724. */
  100725. protected _invertNormalMapX: boolean;
  100726. /**
  100727. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100728. */
  100729. protected _invertNormalMapY: boolean;
  100730. /**
  100731. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100732. */
  100733. protected _twoSidedLighting: boolean;
  100734. /**
  100735. * Defines the alpha limits in alpha test mode.
  100736. */
  100737. protected _alphaCutOff: number;
  100738. /**
  100739. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100740. */
  100741. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  100745. */
  100746. protected _useAlphaFresnel: boolean;
  100747. /**
  100748. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100749. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100750. */
  100751. protected _useLinearAlphaFresnel: boolean;
  100752. /**
  100753. * The transparency mode of the material.
  100754. */
  100755. protected _transparencyMode: Nullable<number>;
  100756. /**
  100757. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  100758. * from cos thetav and roughness:
  100759. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  100760. */
  100761. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  100762. /**
  100763. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100764. */
  100765. protected _forceIrradianceInFragment: boolean;
  100766. /**
  100767. * Force normal to face away from face.
  100768. */
  100769. protected _forceNormalForward: boolean;
  100770. /**
  100771. * Enables specular anti aliasing in the PBR shader.
  100772. * It will both interacts on the Geometry for analytical and IBL lighting.
  100773. * It also prefilter the roughness map based on the bump values.
  100774. */
  100775. protected _enableSpecularAntiAliasing: boolean;
  100776. /**
  100777. * Default configuration related to image processing available in the PBR Material.
  100778. */
  100779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100780. /**
  100781. * Keep track of the image processing observer to allow dispose and replace.
  100782. */
  100783. private _imageProcessingObserver;
  100784. /**
  100785. * Attaches a new image processing configuration to the PBR Material.
  100786. * @param configuration
  100787. */
  100788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100789. /**
  100790. * Stores the available render targets.
  100791. */
  100792. private _renderTargets;
  100793. /**
  100794. * Sets the global ambient color for the material used in lighting calculations.
  100795. */
  100796. private _globalAmbientColor;
  100797. /**
  100798. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  100799. */
  100800. private _useLogarithmicDepth;
  100801. /**
  100802. * If set to true, no lighting calculations will be applied.
  100803. */
  100804. private _unlit;
  100805. private _debugMode;
  100806. /**
  100807. * @hidden
  100808. * This is reserved for the inspector.
  100809. * Defines the material debug mode.
  100810. * It helps seeing only some components of the material while troubleshooting.
  100811. */
  100812. debugMode: number;
  100813. /**
  100814. * @hidden
  100815. * This is reserved for the inspector.
  100816. * Specify from where on screen the debug mode should start.
  100817. * The value goes from -1 (full screen) to 1 (not visible)
  100818. * It helps with side by side comparison against the final render
  100819. * This defaults to -1
  100820. */
  100821. private debugLimit;
  100822. /**
  100823. * @hidden
  100824. * This is reserved for the inspector.
  100825. * As the default viewing range might not be enough (if the ambient is really small for instance)
  100826. * You can use the factor to better multiply the final value.
  100827. */
  100828. private debugFactor;
  100829. /**
  100830. * Defines the clear coat layer parameters for the material.
  100831. */
  100832. readonly clearCoat: PBRClearCoatConfiguration;
  100833. /**
  100834. * Defines the anisotropic parameters for the material.
  100835. */
  100836. readonly anisotropy: PBRAnisotropicConfiguration;
  100837. /**
  100838. * Defines the BRDF parameters for the material.
  100839. */
  100840. readonly brdf: PBRBRDFConfiguration;
  100841. /**
  100842. * Instantiates a new PBRMaterial instance.
  100843. *
  100844. * @param name The material name
  100845. * @param scene The scene the material will be use in.
  100846. */
  100847. constructor(name: string, scene: Scene);
  100848. /**
  100849. * Gets a boolean indicating that current material needs to register RTT
  100850. */
  100851. readonly hasRenderTargetTextures: boolean;
  100852. /**
  100853. * Gets the name of the material class.
  100854. */
  100855. getClassName(): string;
  100856. /**
  100857. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100858. */
  100859. /**
  100860. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100861. */
  100862. useLogarithmicDepth: boolean;
  100863. /**
  100864. * Gets the current transparency mode.
  100865. */
  100866. /**
  100867. * Sets the transparency mode of the material.
  100868. *
  100869. * | Value | Type | Description |
  100870. * | ----- | ----------------------------------- | ----------- |
  100871. * | 0 | OPAQUE | |
  100872. * | 1 | ALPHATEST | |
  100873. * | 2 | ALPHABLEND | |
  100874. * | 3 | ALPHATESTANDBLEND | |
  100875. *
  100876. */
  100877. transparencyMode: Nullable<number>;
  100878. /**
  100879. * Returns true if alpha blending should be disabled.
  100880. */
  100881. private readonly _disableAlphaBlending;
  100882. /**
  100883. * Specifies whether or not this material should be rendered in alpha blend mode.
  100884. */
  100885. needAlphaBlending(): boolean;
  100886. /**
  100887. * Specifies if the mesh will require alpha blending.
  100888. * @param mesh - BJS mesh.
  100889. */
  100890. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100891. /**
  100892. * Specifies whether or not this material should be rendered in alpha test mode.
  100893. */
  100894. needAlphaTesting(): boolean;
  100895. /**
  100896. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100897. */
  100898. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100899. /**
  100900. * Gets the texture used for the alpha test.
  100901. */
  100902. getAlphaTestTexture(): BaseTexture;
  100903. /**
  100904. * Specifies that the submesh is ready to be used.
  100905. * @param mesh - BJS mesh.
  100906. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100907. * @param useInstances - Specifies that instances should be used.
  100908. * @returns - boolean indicating that the submesh is ready or not.
  100909. */
  100910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100911. /**
  100912. * Specifies if the material uses metallic roughness workflow.
  100913. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100914. */
  100915. isMetallicWorkflow(): boolean;
  100916. private _prepareEffect;
  100917. private _prepareDefines;
  100918. /**
  100919. * Force shader compilation
  100920. */
  100921. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100922. clipPlane: boolean;
  100923. }>): void;
  100924. /**
  100925. * Initializes the uniform buffer layout for the shader.
  100926. */
  100927. buildUniformLayout(): void;
  100928. /**
  100929. * Unbinds the textures.
  100930. */
  100931. unbind(): void;
  100932. /**
  100933. * Binds the submesh data.
  100934. * @param world - The world matrix.
  100935. * @param mesh - The BJS mesh.
  100936. * @param subMesh - A submesh of the BJS mesh.
  100937. */
  100938. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100939. /**
  100940. * Returns the animatable textures.
  100941. * @returns - Array of animatable textures.
  100942. */
  100943. getAnimatables(): IAnimatable[];
  100944. /**
  100945. * Returns the texture used for reflections.
  100946. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100947. */
  100948. private _getReflectionTexture;
  100949. /**
  100950. * Returns the texture used for refraction or null if none is used.
  100951. * @returns - Refection texture if present. If no refraction texture and refraction
  100952. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100953. */
  100954. private _getRefractionTexture;
  100955. /**
  100956. * Returns an array of the actively used textures.
  100957. * @returns - Array of BaseTextures
  100958. */
  100959. getActiveTextures(): BaseTexture[];
  100960. /**
  100961. * Checks to see if a texture is used in the material.
  100962. * @param texture - Base texture to use.
  100963. * @returns - Boolean specifying if a texture is used in the material.
  100964. */
  100965. hasTexture(texture: BaseTexture): boolean;
  100966. /**
  100967. * Disposes the resources of the material.
  100968. * @param forceDisposeEffect - Forces the disposal of effects.
  100969. * @param forceDisposeTextures - Forces the disposal of all textures.
  100970. */
  100971. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100972. }
  100973. }
  100974. declare module BABYLON {
  100975. /**
  100976. * The Physically based material of BJS.
  100977. *
  100978. * This offers the main features of a standard PBR material.
  100979. * For more information, please refer to the documentation :
  100980. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100981. */
  100982. export class PBRMaterial extends PBRBaseMaterial {
  100983. /**
  100984. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100985. */
  100986. static readonly PBRMATERIAL_OPAQUE: number;
  100987. /**
  100988. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100989. */
  100990. static readonly PBRMATERIAL_ALPHATEST: number;
  100991. /**
  100992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100993. */
  100994. static readonly PBRMATERIAL_ALPHABLEND: number;
  100995. /**
  100996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100997. * They are also discarded below the alpha cutoff threshold to improve performances.
  100998. */
  100999. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101000. /**
  101001. * Defines the default value of how much AO map is occluding the analytical lights
  101002. * (point spot...).
  101003. */
  101004. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101005. /**
  101006. * Intensity of the direct lights e.g. the four lights available in your scene.
  101007. * This impacts both the direct diffuse and specular highlights.
  101008. */
  101009. directIntensity: number;
  101010. /**
  101011. * Intensity of the emissive part of the material.
  101012. * This helps controlling the emissive effect without modifying the emissive color.
  101013. */
  101014. emissiveIntensity: number;
  101015. /**
  101016. * Intensity of the environment e.g. how much the environment will light the object
  101017. * either through harmonics for rough material or through the refelction for shiny ones.
  101018. */
  101019. environmentIntensity: number;
  101020. /**
  101021. * This is a special control allowing the reduction of the specular highlights coming from the
  101022. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101023. */
  101024. specularIntensity: number;
  101025. /**
  101026. * Debug Control allowing disabling the bump map on this material.
  101027. */
  101028. disableBumpMap: boolean;
  101029. /**
  101030. * AKA Diffuse Texture in standard nomenclature.
  101031. */
  101032. albedoTexture: BaseTexture;
  101033. /**
  101034. * AKA Occlusion Texture in other nomenclature.
  101035. */
  101036. ambientTexture: BaseTexture;
  101037. /**
  101038. * AKA Occlusion Texture Intensity in other nomenclature.
  101039. */
  101040. ambientTextureStrength: number;
  101041. /**
  101042. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101043. * 1 means it completely occludes it
  101044. * 0 mean it has no impact
  101045. */
  101046. ambientTextureImpactOnAnalyticalLights: number;
  101047. /**
  101048. * Stores the alpha values in a texture.
  101049. */
  101050. opacityTexture: BaseTexture;
  101051. /**
  101052. * Stores the reflection values in a texture.
  101053. */
  101054. reflectionTexture: Nullable<BaseTexture>;
  101055. /**
  101056. * Stores the emissive values in a texture.
  101057. */
  101058. emissiveTexture: BaseTexture;
  101059. /**
  101060. * AKA Specular texture in other nomenclature.
  101061. */
  101062. reflectivityTexture: BaseTexture;
  101063. /**
  101064. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101065. */
  101066. metallicTexture: BaseTexture;
  101067. /**
  101068. * Specifies the metallic scalar of the metallic/roughness workflow.
  101069. * Can also be used to scale the metalness values of the metallic texture.
  101070. */
  101071. metallic: Nullable<number>;
  101072. /**
  101073. * Specifies the roughness scalar of the metallic/roughness workflow.
  101074. * Can also be used to scale the roughness values of the metallic texture.
  101075. */
  101076. roughness: Nullable<number>;
  101077. /**
  101078. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101079. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101080. */
  101081. microSurfaceTexture: BaseTexture;
  101082. /**
  101083. * Stores surface normal data used to displace a mesh in a texture.
  101084. */
  101085. bumpTexture: BaseTexture;
  101086. /**
  101087. * Stores the pre-calculated light information of a mesh in a texture.
  101088. */
  101089. lightmapTexture: BaseTexture;
  101090. /**
  101091. * Stores the refracted light information in a texture.
  101092. */
  101093. refractionTexture: BaseTexture;
  101094. /**
  101095. * The color of a material in ambient lighting.
  101096. */
  101097. ambientColor: Color3;
  101098. /**
  101099. * AKA Diffuse Color in other nomenclature.
  101100. */
  101101. albedoColor: Color3;
  101102. /**
  101103. * AKA Specular Color in other nomenclature.
  101104. */
  101105. reflectivityColor: Color3;
  101106. /**
  101107. * The color reflected from the material.
  101108. */
  101109. reflectionColor: Color3;
  101110. /**
  101111. * The color emitted from the material.
  101112. */
  101113. emissiveColor: Color3;
  101114. /**
  101115. * AKA Glossiness in other nomenclature.
  101116. */
  101117. microSurface: number;
  101118. /**
  101119. * source material index of refraction (IOR)' / 'destination material IOR.
  101120. */
  101121. indexOfRefraction: number;
  101122. /**
  101123. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101124. */
  101125. invertRefractionY: boolean;
  101126. /**
  101127. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101128. * Materials half opaque for instance using refraction could benefit from this control.
  101129. */
  101130. linkRefractionWithTransparency: boolean;
  101131. /**
  101132. * If true, the light map contains occlusion information instead of lighting info.
  101133. */
  101134. useLightmapAsShadowmap: boolean;
  101135. /**
  101136. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101137. */
  101138. useAlphaFromAlbedoTexture: boolean;
  101139. /**
  101140. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101141. */
  101142. forceAlphaTest: boolean;
  101143. /**
  101144. * Defines the alpha limits in alpha test mode.
  101145. */
  101146. alphaCutOff: number;
  101147. /**
  101148. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101149. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101150. */
  101151. useSpecularOverAlpha: boolean;
  101152. /**
  101153. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101154. */
  101155. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101156. /**
  101157. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101158. */
  101159. useRoughnessFromMetallicTextureAlpha: boolean;
  101160. /**
  101161. * Specifies if the metallic texture contains the roughness information in its green channel.
  101162. */
  101163. useRoughnessFromMetallicTextureGreen: boolean;
  101164. /**
  101165. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101166. */
  101167. useMetallnessFromMetallicTextureBlue: boolean;
  101168. /**
  101169. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101170. */
  101171. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101172. /**
  101173. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101174. */
  101175. useAmbientInGrayScale: boolean;
  101176. /**
  101177. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101178. * The material will try to infer what glossiness each pixel should be.
  101179. */
  101180. useAutoMicroSurfaceFromReflectivityMap: boolean;
  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. /**
  101187. * BJS is using an harcoded light falloff based on a manually sets up range.
  101188. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101189. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101190. */
  101191. usePhysicalLightFalloff: boolean;
  101192. /**
  101193. * In order to support the falloff compatibility with gltf, a special mode has been added
  101194. * to reproduce the gltf light falloff.
  101195. */
  101196. /**
  101197. * In order to support the falloff compatibility with gltf, a special mode has been added
  101198. * to reproduce the gltf light falloff.
  101199. */
  101200. useGLTFLightFalloff: boolean;
  101201. /**
  101202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101204. */
  101205. useRadianceOverAlpha: boolean;
  101206. /**
  101207. * Allows using an object space normal map (instead of tangent space).
  101208. */
  101209. useObjectSpaceNormalMap: boolean;
  101210. /**
  101211. * Allows using the bump map in parallax mode.
  101212. */
  101213. useParallax: boolean;
  101214. /**
  101215. * Allows using the bump map in parallax occlusion mode.
  101216. */
  101217. useParallaxOcclusion: boolean;
  101218. /**
  101219. * Controls the scale bias of the parallax mode.
  101220. */
  101221. parallaxScaleBias: number;
  101222. /**
  101223. * If sets to true, disables all the lights affecting the material.
  101224. */
  101225. disableLighting: boolean;
  101226. /**
  101227. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101228. */
  101229. forceIrradianceInFragment: boolean;
  101230. /**
  101231. * Number of Simultaneous lights allowed on the material.
  101232. */
  101233. maxSimultaneousLights: number;
  101234. /**
  101235. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101236. */
  101237. invertNormalMapX: boolean;
  101238. /**
  101239. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101240. */
  101241. invertNormalMapY: boolean;
  101242. /**
  101243. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101244. */
  101245. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  101249. */
  101250. useAlphaFresnel: boolean;
  101251. /**
  101252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101253. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101254. */
  101255. useLinearAlphaFresnel: boolean;
  101256. /**
  101257. * Let user defines the brdf lookup texture used for IBL.
  101258. * A default 8bit version is embedded but you could point at :
  101259. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101260. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101261. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101262. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101263. */
  101264. environmentBRDFTexture: Nullable<BaseTexture>;
  101265. /**
  101266. * Force normal to face away from face.
  101267. */
  101268. forceNormalForward: boolean;
  101269. /**
  101270. * Enables specular anti aliasing in the PBR shader.
  101271. * It will both interacts on the Geometry for analytical and IBL lighting.
  101272. * It also prefilter the roughness map based on the bump values.
  101273. */
  101274. enableSpecularAntiAliasing: boolean;
  101275. /**
  101276. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101277. * makes the reflect vector face the model (under horizon).
  101278. */
  101279. useHorizonOcclusion: boolean;
  101280. /**
  101281. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101282. * too much the area relying on ambient texture to define their ambient occlusion.
  101283. */
  101284. useRadianceOcclusion: boolean;
  101285. /**
  101286. * If set to true, no lighting calculations will be applied.
  101287. */
  101288. unlit: boolean;
  101289. /**
  101290. * Gets the image processing configuration used either in this material.
  101291. */
  101292. /**
  101293. * Sets the Default image processing configuration used either in the this material.
  101294. *
  101295. * If sets to null, the scene one is in use.
  101296. */
  101297. imageProcessingConfiguration: ImageProcessingConfiguration;
  101298. /**
  101299. * Gets wether the color curves effect is enabled.
  101300. */
  101301. /**
  101302. * Sets wether the color curves effect is enabled.
  101303. */
  101304. cameraColorCurvesEnabled: boolean;
  101305. /**
  101306. * Gets wether the color grading effect is enabled.
  101307. */
  101308. /**
  101309. * Gets wether the color grading effect is enabled.
  101310. */
  101311. cameraColorGradingEnabled: boolean;
  101312. /**
  101313. * Gets wether tonemapping is enabled or not.
  101314. */
  101315. /**
  101316. * Sets wether tonemapping is enabled or not
  101317. */
  101318. cameraToneMappingEnabled: boolean;
  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. /**
  101325. * The camera exposure used on this material.
  101326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101327. * This corresponds to a photographic exposure.
  101328. */
  101329. cameraExposure: number;
  101330. /**
  101331. * Gets The camera contrast used on this material.
  101332. */
  101333. /**
  101334. * Sets The camera contrast used on this material.
  101335. */
  101336. cameraContrast: number;
  101337. /**
  101338. * Gets the Color Grading 2D Lookup Texture.
  101339. */
  101340. /**
  101341. * Sets the Color Grading 2D Lookup Texture.
  101342. */
  101343. cameraColorGradingTexture: Nullable<BaseTexture>;
  101344. /**
  101345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101347. * 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;
  101348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101349. */
  101350. /**
  101351. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101352. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101353. * 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;
  101354. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101355. */
  101356. cameraColorCurves: Nullable<ColorCurves>;
  101357. /**
  101358. * Instantiates a new PBRMaterial instance.
  101359. *
  101360. * @param name The material name
  101361. * @param scene The scene the material will be use in.
  101362. */
  101363. constructor(name: string, scene: Scene);
  101364. /**
  101365. * Returns the name of this material class.
  101366. */
  101367. getClassName(): string;
  101368. /**
  101369. * Makes a duplicate of the current material.
  101370. * @param name - name to use for the new material.
  101371. */
  101372. clone(name: string): PBRMaterial;
  101373. /**
  101374. * Serializes this PBR Material.
  101375. * @returns - An object with the serialized material.
  101376. */
  101377. serialize(): any;
  101378. /**
  101379. * Parses a PBR Material from a serialized object.
  101380. * @param source - Serialized object.
  101381. * @param scene - BJS scene instance.
  101382. * @param rootUrl - url for the scene object
  101383. * @returns - PBRMaterial
  101384. */
  101385. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101386. }
  101387. }
  101388. declare module BABYLON {
  101389. /**
  101390. * Direct draw surface info
  101391. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  101392. */
  101393. export interface DDSInfo {
  101394. /**
  101395. * Width of the texture
  101396. */
  101397. width: number;
  101398. /**
  101399. * Width of the texture
  101400. */
  101401. height: number;
  101402. /**
  101403. * Number of Mipmaps for the texture
  101404. * @see https://en.wikipedia.org/wiki/Mipmap
  101405. */
  101406. mipmapCount: number;
  101407. /**
  101408. * If the textures format is a known fourCC format
  101409. * @see https://www.fourcc.org/
  101410. */
  101411. isFourCC: boolean;
  101412. /**
  101413. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  101414. */
  101415. isRGB: boolean;
  101416. /**
  101417. * If the texture is a lumincance format
  101418. */
  101419. isLuminance: boolean;
  101420. /**
  101421. * If this is a cube texture
  101422. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  101423. */
  101424. isCube: boolean;
  101425. /**
  101426. * If the texture is a compressed format eg. FOURCC_DXT1
  101427. */
  101428. isCompressed: boolean;
  101429. /**
  101430. * The dxgiFormat of the texture
  101431. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  101432. */
  101433. dxgiFormat: number;
  101434. /**
  101435. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  101436. */
  101437. textureType: number;
  101438. /**
  101439. * Sphericle polynomial created for the dds texture
  101440. */
  101441. sphericalPolynomial?: SphericalPolynomial;
  101442. }
  101443. /**
  101444. * Class used to provide DDS decompression tools
  101445. */
  101446. export class DDSTools {
  101447. /**
  101448. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  101449. */
  101450. static StoreLODInAlphaChannel: boolean;
  101451. /**
  101452. * Gets DDS information from an array buffer
  101453. * @param arrayBuffer defines the array buffer to read data from
  101454. * @returns the DDS information
  101455. */
  101456. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  101457. private static _FloatView;
  101458. private static _Int32View;
  101459. private static _ToHalfFloat;
  101460. private static _FromHalfFloat;
  101461. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  101462. private static _GetHalfFloatRGBAArrayBuffer;
  101463. private static _GetFloatRGBAArrayBuffer;
  101464. private static _GetFloatAsUIntRGBAArrayBuffer;
  101465. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  101466. private static _GetRGBAArrayBuffer;
  101467. private static _ExtractLongWordOrder;
  101468. private static _GetRGBArrayBuffer;
  101469. private static _GetLuminanceArrayBuffer;
  101470. /**
  101471. * Uploads DDS Levels to a Babylon Texture
  101472. * @hidden
  101473. */
  101474. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  101475. }
  101476. interface Engine {
  101477. /**
  101478. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  101479. * @param rootUrl defines the url where the file to load is located
  101480. * @param scene defines the current scene
  101481. * @param lodScale defines scale to apply to the mip map selection
  101482. * @param lodOffset defines offset to apply to the mip map selection
  101483. * @param onLoad defines an optional callback raised when the texture is loaded
  101484. * @param onError defines an optional callback raised if there is an issue to load the texture
  101485. * @param format defines the format of the data
  101486. * @param forcedExtension defines the extension to use to pick the right loader
  101487. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  101488. * @returns the cube texture as an InternalTexture
  101489. */
  101490. 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;
  101491. }
  101492. }
  101493. declare module BABYLON {
  101494. /**
  101495. * Implementation of the DDS Texture Loader.
  101496. * @hidden
  101497. */
  101498. export class _DDSTextureLoader implements IInternalTextureLoader {
  101499. /**
  101500. * Defines wether the loader supports cascade loading the different faces.
  101501. */
  101502. readonly supportCascades: boolean;
  101503. /**
  101504. * This returns if the loader support the current file information.
  101505. * @param extension defines the file extension of the file being loaded
  101506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101507. * @param fallback defines the fallback internal texture if any
  101508. * @param isBase64 defines whether the texture is encoded as a base64
  101509. * @param isBuffer defines whether the texture data are stored as a buffer
  101510. * @returns true if the loader can load the specified file
  101511. */
  101512. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101513. /**
  101514. * Transform the url before loading if required.
  101515. * @param rootUrl the url of the texture
  101516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101517. * @returns the transformed texture
  101518. */
  101519. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101520. /**
  101521. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101522. * @param rootUrl the url of the texture
  101523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101524. * @returns the fallback texture
  101525. */
  101526. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101527. /**
  101528. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101529. * @param data contains the texture data
  101530. * @param texture defines the BabylonJS internal texture
  101531. * @param createPolynomials will be true if polynomials have been requested
  101532. * @param onLoad defines the callback to trigger once the texture is ready
  101533. * @param onError defines the callback to trigger in case of error
  101534. */
  101535. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101536. /**
  101537. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101538. * @param data contains the texture data
  101539. * @param texture defines the BabylonJS internal texture
  101540. * @param callback defines the method to call once ready to upload
  101541. */
  101542. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  101543. }
  101544. }
  101545. declare module BABYLON {
  101546. /** @hidden */
  101547. export var rgbdEncodePixelShader: {
  101548. name: string;
  101549. shader: string;
  101550. };
  101551. }
  101552. declare module BABYLON {
  101553. /** @hidden */
  101554. export var rgbdDecodePixelShader: {
  101555. name: string;
  101556. shader: string;
  101557. };
  101558. }
  101559. declare module BABYLON {
  101560. /**
  101561. * Raw texture data and descriptor sufficient for WebGL texture upload
  101562. */
  101563. export interface EnvironmentTextureInfo {
  101564. /**
  101565. * Version of the environment map
  101566. */
  101567. version: number;
  101568. /**
  101569. * Width of image
  101570. */
  101571. width: number;
  101572. /**
  101573. * Irradiance information stored in the file.
  101574. */
  101575. irradiance: any;
  101576. /**
  101577. * Specular information stored in the file.
  101578. */
  101579. specular: any;
  101580. }
  101581. /**
  101582. * Sets of helpers addressing the serialization and deserialization of environment texture
  101583. * stored in a BabylonJS env file.
  101584. * Those files are usually stored as .env files.
  101585. */
  101586. export class EnvironmentTextureTools {
  101587. /**
  101588. * Magic number identifying the env file.
  101589. */
  101590. private static _MagicBytes;
  101591. /**
  101592. * Gets the environment info from an env file.
  101593. * @param data The array buffer containing the .env bytes.
  101594. * @returns the environment file info (the json header) if successfully parsed.
  101595. */
  101596. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  101597. /**
  101598. * Creates an environment texture from a loaded cube texture.
  101599. * @param texture defines the cube texture to convert in env file
  101600. * @return a promise containing the environment data if succesfull.
  101601. */
  101602. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  101603. /**
  101604. * Creates a JSON representation of the spherical data.
  101605. * @param texture defines the texture containing the polynomials
  101606. * @return the JSON representation of the spherical info
  101607. */
  101608. private static _CreateEnvTextureIrradiance;
  101609. /**
  101610. * Uploads the texture info contained in the env file to the GPU.
  101611. * @param texture defines the internal texture to upload to
  101612. * @param arrayBuffer defines the buffer cotaining the data to load
  101613. * @param info defines the texture info retrieved through the GetEnvInfo method
  101614. * @returns a promise
  101615. */
  101616. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  101617. /**
  101618. * Uploads the levels of image data to the GPU.
  101619. * @param texture defines the internal texture to upload to
  101620. * @param imageData defines the array buffer views of image data [mipmap][face]
  101621. * @returns a promise
  101622. */
  101623. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  101624. /**
  101625. * Uploads spherical polynomials information to the texture.
  101626. * @param texture defines the texture we are trying to upload the information to
  101627. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  101628. */
  101629. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  101630. /** @hidden */
  101631. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  101632. }
  101633. }
  101634. declare module BABYLON {
  101635. /**
  101636. * Implementation of the ENV Texture Loader.
  101637. * @hidden
  101638. */
  101639. export class _ENVTextureLoader implements IInternalTextureLoader {
  101640. /**
  101641. * Defines wether the loader supports cascade loading the different faces.
  101642. */
  101643. readonly supportCascades: boolean;
  101644. /**
  101645. * This returns if the loader support the current file information.
  101646. * @param extension defines the file extension of the file being loaded
  101647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101648. * @param fallback defines the fallback internal texture if any
  101649. * @param isBase64 defines whether the texture is encoded as a base64
  101650. * @param isBuffer defines whether the texture data are stored as a buffer
  101651. * @returns true if the loader can load the specified file
  101652. */
  101653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101654. /**
  101655. * Transform the url before loading if required.
  101656. * @param rootUrl the url of the texture
  101657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101658. * @returns the transformed texture
  101659. */
  101660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101661. /**
  101662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101663. * @param rootUrl the url of the texture
  101664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101665. * @returns the fallback texture
  101666. */
  101667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101668. /**
  101669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101670. * @param data contains the texture data
  101671. * @param texture defines the BabylonJS internal texture
  101672. * @param createPolynomials will be true if polynomials have been requested
  101673. * @param onLoad defines the callback to trigger once the texture is ready
  101674. * @param onError defines the callback to trigger in case of error
  101675. */
  101676. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101677. /**
  101678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101679. * @param data contains the texture data
  101680. * @param texture defines the BabylonJS internal texture
  101681. * @param callback defines the method to call once ready to upload
  101682. */
  101683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  101684. }
  101685. }
  101686. declare module BABYLON {
  101687. /**
  101688. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  101689. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  101690. */
  101691. export class KhronosTextureContainer {
  101692. /** contents of the KTX container file */
  101693. arrayBuffer: any;
  101694. private static HEADER_LEN;
  101695. private static COMPRESSED_2D;
  101696. private static COMPRESSED_3D;
  101697. private static TEX_2D;
  101698. private static TEX_3D;
  101699. /**
  101700. * Gets the openGL type
  101701. */
  101702. glType: number;
  101703. /**
  101704. * Gets the openGL type size
  101705. */
  101706. glTypeSize: number;
  101707. /**
  101708. * Gets the openGL format
  101709. */
  101710. glFormat: number;
  101711. /**
  101712. * Gets the openGL internal format
  101713. */
  101714. glInternalFormat: number;
  101715. /**
  101716. * Gets the base internal format
  101717. */
  101718. glBaseInternalFormat: number;
  101719. /**
  101720. * Gets image width in pixel
  101721. */
  101722. pixelWidth: number;
  101723. /**
  101724. * Gets image height in pixel
  101725. */
  101726. pixelHeight: number;
  101727. /**
  101728. * Gets image depth in pixels
  101729. */
  101730. pixelDepth: number;
  101731. /**
  101732. * Gets the number of array elements
  101733. */
  101734. numberOfArrayElements: number;
  101735. /**
  101736. * Gets the number of faces
  101737. */
  101738. numberOfFaces: number;
  101739. /**
  101740. * Gets the number of mipmap levels
  101741. */
  101742. numberOfMipmapLevels: number;
  101743. /**
  101744. * Gets the bytes of key value data
  101745. */
  101746. bytesOfKeyValueData: number;
  101747. /**
  101748. * Gets the load type
  101749. */
  101750. loadType: number;
  101751. /**
  101752. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  101753. */
  101754. isInvalid: boolean;
  101755. /**
  101756. * Creates a new KhronosTextureContainer
  101757. * @param arrayBuffer contents of the KTX container file
  101758. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  101759. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  101760. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  101761. */
  101762. constructor(
  101763. /** contents of the KTX container file */
  101764. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  101765. /**
  101766. * Uploads KTX content to a Babylon Texture.
  101767. * It is assumed that the texture has already been created & is currently bound
  101768. * @hidden
  101769. */
  101770. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  101771. private _upload2DCompressedLevels;
  101772. }
  101773. }
  101774. declare module BABYLON {
  101775. /**
  101776. * Implementation of the KTX Texture Loader.
  101777. * @hidden
  101778. */
  101779. export class _KTXTextureLoader implements IInternalTextureLoader {
  101780. /**
  101781. * Defines wether the loader supports cascade loading the different faces.
  101782. */
  101783. readonly supportCascades: boolean;
  101784. /**
  101785. * This returns if the loader support the current file information.
  101786. * @param extension defines the file extension of the file being loaded
  101787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101788. * @param fallback defines the fallback internal texture if any
  101789. * @param isBase64 defines whether the texture is encoded as a base64
  101790. * @param isBuffer defines whether the texture data are stored as a buffer
  101791. * @returns true if the loader can load the specified file
  101792. */
  101793. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101794. /**
  101795. * Transform the url before loading if required.
  101796. * @param rootUrl the url of the texture
  101797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101798. * @returns the transformed texture
  101799. */
  101800. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101801. /**
  101802. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101803. * @param rootUrl the url of the texture
  101804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101805. * @returns the fallback texture
  101806. */
  101807. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101808. /**
  101809. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101810. * @param data contains the texture data
  101811. * @param texture defines the BabylonJS internal texture
  101812. * @param createPolynomials will be true if polynomials have been requested
  101813. * @param onLoad defines the callback to trigger once the texture is ready
  101814. * @param onError defines the callback to trigger in case of error
  101815. */
  101816. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101817. /**
  101818. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101819. * @param data contains the texture data
  101820. * @param texture defines the BabylonJS internal texture
  101821. * @param callback defines the method to call once ready to upload
  101822. */
  101823. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  101824. }
  101825. }
  101826. declare module BABYLON {
  101827. /** @hidden */
  101828. export var _forceSceneHelpersToBundle: boolean;
  101829. interface Scene {
  101830. /**
  101831. * Creates a default light for the scene.
  101832. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  101833. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  101834. */
  101835. createDefaultLight(replace?: boolean): void;
  101836. /**
  101837. * Creates a default camera for the scene.
  101838. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  101839. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101840. * @param replace has default false, when true replaces the active camera in the scene
  101841. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  101842. */
  101843. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101844. /**
  101845. * Creates a default camera and a default light.
  101846. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  101847. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101848. * @param replace has the default false, when true replaces the active camera/light in the scene
  101849. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  101850. */
  101851. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101852. /**
  101853. * Creates a new sky box
  101854. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  101855. * @param environmentTexture defines the texture to use as environment texture
  101856. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  101857. * @param scale defines the overall scale of the skybox
  101858. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  101859. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  101860. * @returns a new mesh holding the sky box
  101861. */
  101862. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  101863. /**
  101864. * Creates a new environment
  101865. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  101866. * @param options defines the options you can use to configure the environment
  101867. * @returns the new EnvironmentHelper
  101868. */
  101869. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  101870. /**
  101871. * Creates a new VREXperienceHelper
  101872. * @see http://doc.babylonjs.com/how_to/webvr_helper
  101873. * @param webVROptions defines the options used to create the new VREXperienceHelper
  101874. * @returns a new VREXperienceHelper
  101875. */
  101876. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  101877. /**
  101878. * Creates a new XREXperienceHelper
  101879. * @see http://doc.babylonjs.com/how_to/webxr
  101880. * @returns a promise for a new XREXperienceHelper
  101881. */
  101882. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  101883. }
  101884. }
  101885. declare module BABYLON {
  101886. /**
  101887. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  101888. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  101889. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  101890. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101891. */
  101892. export class VideoDome extends TransformNode {
  101893. /**
  101894. * Define the video source as a Monoscopic panoramic 360 video.
  101895. */
  101896. static readonly MODE_MONOSCOPIC: number;
  101897. /**
  101898. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101899. */
  101900. static readonly MODE_TOPBOTTOM: number;
  101901. /**
  101902. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101903. */
  101904. static readonly MODE_SIDEBYSIDE: number;
  101905. private _useDirectMapping;
  101906. /**
  101907. * The video texture being displayed on the sphere
  101908. */
  101909. protected _videoTexture: VideoTexture;
  101910. /**
  101911. * Gets the video texture being displayed on the sphere
  101912. */
  101913. readonly videoTexture: VideoTexture;
  101914. /**
  101915. * The skybox material
  101916. */
  101917. protected _material: BackgroundMaterial;
  101918. /**
  101919. * The surface used for the skybox
  101920. */
  101921. protected _mesh: Mesh;
  101922. /**
  101923. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101924. * Also see the options.resolution property.
  101925. */
  101926. fovMultiplier: number;
  101927. private _videoMode;
  101928. /**
  101929. * Gets or set the current video mode for the video. It can be:
  101930. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  101931. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101932. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101933. */
  101934. videoMode: number;
  101935. /**
  101936. * Oberserver used in Stereoscopic VR Mode.
  101937. */
  101938. private _onBeforeCameraRenderObserver;
  101939. /**
  101940. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  101941. * @param name Element's name, child elements will append suffixes for their own names.
  101942. * @param urlsOrVideo defines the url(s) or the video element to use
  101943. * @param options An object containing optional or exposed sub element properties
  101944. */
  101945. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  101946. resolution?: number;
  101947. clickToPlay?: boolean;
  101948. autoPlay?: boolean;
  101949. loop?: boolean;
  101950. size?: number;
  101951. poster?: string;
  101952. useDirectMapping?: boolean;
  101953. }, scene: Scene);
  101954. private _changeVideoMode;
  101955. /**
  101956. * Releases resources associated with this node.
  101957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101959. */
  101960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101961. }
  101962. }
  101963. declare module BABYLON {
  101964. /**
  101965. * This class can be used to get instrumentation data from a Babylon engine
  101966. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101967. */
  101968. export class EngineInstrumentation implements IDisposable {
  101969. /**
  101970. * Define the instrumented engine.
  101971. */
  101972. engine: Engine;
  101973. private _captureGPUFrameTime;
  101974. private _gpuFrameTimeToken;
  101975. private _gpuFrameTime;
  101976. private _captureShaderCompilationTime;
  101977. private _shaderCompilationTime;
  101978. private _onBeginFrameObserver;
  101979. private _onEndFrameObserver;
  101980. private _onBeforeShaderCompilationObserver;
  101981. private _onAfterShaderCompilationObserver;
  101982. /**
  101983. * Gets the perf counter used for GPU frame time
  101984. */
  101985. readonly gpuFrameTimeCounter: PerfCounter;
  101986. /**
  101987. * Gets the GPU frame time capture status
  101988. */
  101989. /**
  101990. * Enable or disable the GPU frame time capture
  101991. */
  101992. captureGPUFrameTime: boolean;
  101993. /**
  101994. * Gets the perf counter used for shader compilation time
  101995. */
  101996. readonly shaderCompilationTimeCounter: PerfCounter;
  101997. /**
  101998. * Gets the shader compilation time capture status
  101999. */
  102000. /**
  102001. * Enable or disable the shader compilation time capture
  102002. */
  102003. captureShaderCompilationTime: boolean;
  102004. /**
  102005. * Instantiates a new engine instrumentation.
  102006. * This class can be used to get instrumentation data from a Babylon engine
  102007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102008. * @param engine Defines the engine to instrument
  102009. */
  102010. constructor(
  102011. /**
  102012. * Define the instrumented engine.
  102013. */
  102014. engine: Engine);
  102015. /**
  102016. * Dispose and release associated resources.
  102017. */
  102018. dispose(): void;
  102019. }
  102020. }
  102021. declare module BABYLON {
  102022. /**
  102023. * This class can be used to get instrumentation data from a Babylon engine
  102024. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102025. */
  102026. export class SceneInstrumentation implements IDisposable {
  102027. /**
  102028. * Defines the scene to instrument
  102029. */
  102030. scene: Scene;
  102031. private _captureActiveMeshesEvaluationTime;
  102032. private _activeMeshesEvaluationTime;
  102033. private _captureRenderTargetsRenderTime;
  102034. private _renderTargetsRenderTime;
  102035. private _captureFrameTime;
  102036. private _frameTime;
  102037. private _captureRenderTime;
  102038. private _renderTime;
  102039. private _captureInterFrameTime;
  102040. private _interFrameTime;
  102041. private _captureParticlesRenderTime;
  102042. private _particlesRenderTime;
  102043. private _captureSpritesRenderTime;
  102044. private _spritesRenderTime;
  102045. private _capturePhysicsTime;
  102046. private _physicsTime;
  102047. private _captureAnimationsTime;
  102048. private _animationsTime;
  102049. private _captureCameraRenderTime;
  102050. private _cameraRenderTime;
  102051. private _onBeforeActiveMeshesEvaluationObserver;
  102052. private _onAfterActiveMeshesEvaluationObserver;
  102053. private _onBeforeRenderTargetsRenderObserver;
  102054. private _onAfterRenderTargetsRenderObserver;
  102055. private _onAfterRenderObserver;
  102056. private _onBeforeDrawPhaseObserver;
  102057. private _onAfterDrawPhaseObserver;
  102058. private _onBeforeAnimationsObserver;
  102059. private _onBeforeParticlesRenderingObserver;
  102060. private _onAfterParticlesRenderingObserver;
  102061. private _onBeforeSpritesRenderingObserver;
  102062. private _onAfterSpritesRenderingObserver;
  102063. private _onBeforePhysicsObserver;
  102064. private _onAfterPhysicsObserver;
  102065. private _onAfterAnimationsObserver;
  102066. private _onBeforeCameraRenderObserver;
  102067. private _onAfterCameraRenderObserver;
  102068. /**
  102069. * Gets the perf counter used for active meshes evaluation time
  102070. */
  102071. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102072. /**
  102073. * Gets the active meshes evaluation time capture status
  102074. */
  102075. /**
  102076. * Enable or disable the active meshes evaluation time capture
  102077. */
  102078. captureActiveMeshesEvaluationTime: boolean;
  102079. /**
  102080. * Gets the perf counter used for render targets render time
  102081. */
  102082. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102083. /**
  102084. * Gets the render targets render time capture status
  102085. */
  102086. /**
  102087. * Enable or disable the render targets render time capture
  102088. */
  102089. captureRenderTargetsRenderTime: boolean;
  102090. /**
  102091. * Gets the perf counter used for particles render time
  102092. */
  102093. readonly particlesRenderTimeCounter: PerfCounter;
  102094. /**
  102095. * Gets the particles render time capture status
  102096. */
  102097. /**
  102098. * Enable or disable the particles render time capture
  102099. */
  102100. captureParticlesRenderTime: boolean;
  102101. /**
  102102. * Gets the perf counter used for sprites render time
  102103. */
  102104. readonly spritesRenderTimeCounter: PerfCounter;
  102105. /**
  102106. * Gets the sprites render time capture status
  102107. */
  102108. /**
  102109. * Enable or disable the sprites render time capture
  102110. */
  102111. captureSpritesRenderTime: boolean;
  102112. /**
  102113. * Gets the perf counter used for physics time
  102114. */
  102115. readonly physicsTimeCounter: PerfCounter;
  102116. /**
  102117. * Gets the physics time capture status
  102118. */
  102119. /**
  102120. * Enable or disable the physics time capture
  102121. */
  102122. capturePhysicsTime: boolean;
  102123. /**
  102124. * Gets the perf counter used for animations time
  102125. */
  102126. readonly animationsTimeCounter: PerfCounter;
  102127. /**
  102128. * Gets the animations time capture status
  102129. */
  102130. /**
  102131. * Enable or disable the animations time capture
  102132. */
  102133. captureAnimationsTime: boolean;
  102134. /**
  102135. * Gets the perf counter used for frame time capture
  102136. */
  102137. readonly frameTimeCounter: PerfCounter;
  102138. /**
  102139. * Gets the frame time capture status
  102140. */
  102141. /**
  102142. * Enable or disable the frame time capture
  102143. */
  102144. captureFrameTime: boolean;
  102145. /**
  102146. * Gets the perf counter used for inter-frames time capture
  102147. */
  102148. readonly interFrameTimeCounter: PerfCounter;
  102149. /**
  102150. * Gets the inter-frames time capture status
  102151. */
  102152. /**
  102153. * Enable or disable the inter-frames time capture
  102154. */
  102155. captureInterFrameTime: boolean;
  102156. /**
  102157. * Gets the perf counter used for render time capture
  102158. */
  102159. readonly renderTimeCounter: PerfCounter;
  102160. /**
  102161. * Gets the render time capture status
  102162. */
  102163. /**
  102164. * Enable or disable the render time capture
  102165. */
  102166. captureRenderTime: boolean;
  102167. /**
  102168. * Gets the perf counter used for camera render time capture
  102169. */
  102170. readonly cameraRenderTimeCounter: PerfCounter;
  102171. /**
  102172. * Gets the camera render time capture status
  102173. */
  102174. /**
  102175. * Enable or disable the camera render time capture
  102176. */
  102177. captureCameraRenderTime: boolean;
  102178. /**
  102179. * Gets the perf counter used for draw calls
  102180. */
  102181. readonly drawCallsCounter: PerfCounter;
  102182. /**
  102183. * Gets the perf counter used for texture collisions
  102184. */
  102185. readonly textureCollisionsCounter: PerfCounter;
  102186. /**
  102187. * Instantiates a new scene instrumentation.
  102188. * This class can be used to get instrumentation data from a Babylon engine
  102189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102190. * @param scene Defines the scene to instrument
  102191. */
  102192. constructor(
  102193. /**
  102194. * Defines the scene to instrument
  102195. */
  102196. scene: Scene);
  102197. /**
  102198. * Dispose and release associated resources.
  102199. */
  102200. dispose(): void;
  102201. }
  102202. }
  102203. declare module BABYLON {
  102204. /** @hidden */
  102205. export var glowMapGenerationPixelShader: {
  102206. name: string;
  102207. shader: string;
  102208. };
  102209. }
  102210. declare module BABYLON {
  102211. /** @hidden */
  102212. export var glowMapGenerationVertexShader: {
  102213. name: string;
  102214. shader: string;
  102215. };
  102216. }
  102217. declare module BABYLON {
  102218. /**
  102219. * Effect layer options. This helps customizing the behaviour
  102220. * of the effect layer.
  102221. */
  102222. export interface IEffectLayerOptions {
  102223. /**
  102224. * Multiplication factor apply to the canvas size to compute the render target size
  102225. * used to generated the objects (the smaller the faster).
  102226. */
  102227. mainTextureRatio: number;
  102228. /**
  102229. * Enforces a fixed size texture to ensure effect stability across devices.
  102230. */
  102231. mainTextureFixedSize?: number;
  102232. /**
  102233. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102234. */
  102235. alphaBlendingMode: number;
  102236. /**
  102237. * The camera attached to the layer.
  102238. */
  102239. camera: Nullable<Camera>;
  102240. /**
  102241. * The rendering group to draw the layer in.
  102242. */
  102243. renderingGroupId: number;
  102244. }
  102245. /**
  102246. * The effect layer Helps adding post process effect blended with the main pass.
  102247. *
  102248. * This can be for instance use to generate glow or higlight effects on the scene.
  102249. *
  102250. * The effect layer class can not be used directly and is intented to inherited from to be
  102251. * customized per effects.
  102252. */
  102253. export abstract class EffectLayer {
  102254. private _vertexBuffers;
  102255. private _indexBuffer;
  102256. private _cachedDefines;
  102257. private _effectLayerMapGenerationEffect;
  102258. private _effectLayerOptions;
  102259. private _mergeEffect;
  102260. protected _scene: Scene;
  102261. protected _engine: Engine;
  102262. protected _maxSize: number;
  102263. protected _mainTextureDesiredSize: ISize;
  102264. protected _mainTexture: RenderTargetTexture;
  102265. protected _shouldRender: boolean;
  102266. protected _postProcesses: PostProcess[];
  102267. protected _textures: BaseTexture[];
  102268. protected _emissiveTextureAndColor: {
  102269. texture: Nullable<BaseTexture>;
  102270. color: Color4;
  102271. };
  102272. /**
  102273. * The name of the layer
  102274. */
  102275. name: string;
  102276. /**
  102277. * The clear color of the texture used to generate the glow map.
  102278. */
  102279. neutralColor: Color4;
  102280. /**
  102281. * Specifies wether the highlight layer is enabled or not.
  102282. */
  102283. isEnabled: boolean;
  102284. /**
  102285. * Gets the camera attached to the layer.
  102286. */
  102287. readonly camera: Nullable<Camera>;
  102288. /**
  102289. * Gets the rendering group id the layer should render in.
  102290. */
  102291. readonly renderingGroupId: number;
  102292. /**
  102293. * An event triggered when the effect layer has been disposed.
  102294. */
  102295. onDisposeObservable: Observable<EffectLayer>;
  102296. /**
  102297. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102298. */
  102299. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102300. /**
  102301. * An event triggered when the generated texture is being merged in the scene.
  102302. */
  102303. onBeforeComposeObservable: Observable<EffectLayer>;
  102304. /**
  102305. * An event triggered when the generated texture has been merged in the scene.
  102306. */
  102307. onAfterComposeObservable: Observable<EffectLayer>;
  102308. /**
  102309. * An event triggered when the efffect layer changes its size.
  102310. */
  102311. onSizeChangedObservable: Observable<EffectLayer>;
  102312. /** @hidden */
  102313. static _SceneComponentInitialization: (scene: Scene) => void;
  102314. /**
  102315. * Instantiates a new effect Layer and references it in the scene.
  102316. * @param name The name of the layer
  102317. * @param scene The scene to use the layer in
  102318. */
  102319. constructor(
  102320. /** The Friendly of the effect in the scene */
  102321. name: string, scene: Scene);
  102322. /**
  102323. * Get the effect name of the layer.
  102324. * @return The effect name
  102325. */
  102326. abstract getEffectName(): string;
  102327. /**
  102328. * Checks for the readiness of the element composing the layer.
  102329. * @param subMesh the mesh to check for
  102330. * @param useInstances specify wether or not to use instances to render the mesh
  102331. * @return true if ready otherwise, false
  102332. */
  102333. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102334. /**
  102335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102336. * @returns true if the effect requires stencil during the main canvas render pass.
  102337. */
  102338. abstract needStencil(): boolean;
  102339. /**
  102340. * Create the merge effect. This is the shader use to blit the information back
  102341. * to the main canvas at the end of the scene rendering.
  102342. * @returns The effect containing the shader used to merge the effect on the main canvas
  102343. */
  102344. protected abstract _createMergeEffect(): Effect;
  102345. /**
  102346. * Creates the render target textures and post processes used in the effect layer.
  102347. */
  102348. protected abstract _createTextureAndPostProcesses(): void;
  102349. /**
  102350. * Implementation specific of rendering the generating effect on the main canvas.
  102351. * @param effect The effect used to render through
  102352. */
  102353. protected abstract _internalRender(effect: Effect): void;
  102354. /**
  102355. * Sets the required values for both the emissive texture and and the main color.
  102356. */
  102357. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102358. /**
  102359. * Free any resources and references associated to a mesh.
  102360. * Internal use
  102361. * @param mesh The mesh to free.
  102362. */
  102363. abstract _disposeMesh(mesh: Mesh): void;
  102364. /**
  102365. * Serializes this layer (Glow or Highlight for example)
  102366. * @returns a serialized layer object
  102367. */
  102368. abstract serialize?(): any;
  102369. /**
  102370. * Initializes the effect layer with the required options.
  102371. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102372. */
  102373. protected _init(options: Partial<IEffectLayerOptions>): void;
  102374. /**
  102375. * Generates the index buffer of the full screen quad blending to the main canvas.
  102376. */
  102377. private _generateIndexBuffer;
  102378. /**
  102379. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  102380. */
  102381. private _genrateVertexBuffer;
  102382. /**
  102383. * Sets the main texture desired size which is the closest power of two
  102384. * of the engine canvas size.
  102385. */
  102386. private _setMainTextureSize;
  102387. /**
  102388. * Creates the main texture for the effect layer.
  102389. */
  102390. protected _createMainTexture(): void;
  102391. /**
  102392. * Adds specific effects defines.
  102393. * @param defines The defines to add specifics to.
  102394. */
  102395. protected _addCustomEffectDefines(defines: string[]): void;
  102396. /**
  102397. * Checks for the readiness of the element composing the layer.
  102398. * @param subMesh the mesh to check for
  102399. * @param useInstances specify wether or not to use instances to render the mesh
  102400. * @param emissiveTexture the associated emissive texture used to generate the glow
  102401. * @return true if ready otherwise, false
  102402. */
  102403. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  102404. /**
  102405. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  102406. */
  102407. render(): void;
  102408. /**
  102409. * Determine if a given mesh will be used in the current effect.
  102410. * @param mesh mesh to test
  102411. * @returns true if the mesh will be used
  102412. */
  102413. hasMesh(mesh: AbstractMesh): boolean;
  102414. /**
  102415. * Returns true if the layer contains information to display, otherwise false.
  102416. * @returns true if the glow layer should be rendered
  102417. */
  102418. shouldRender(): boolean;
  102419. /**
  102420. * Returns true if the mesh should render, otherwise false.
  102421. * @param mesh The mesh to render
  102422. * @returns true if it should render otherwise false
  102423. */
  102424. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  102425. /**
  102426. * Returns true if the mesh can be rendered, otherwise false.
  102427. * @param mesh The mesh to render
  102428. * @param material The material used on the mesh
  102429. * @returns true if it can be rendered otherwise false
  102430. */
  102431. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102432. /**
  102433. * Returns true if the mesh should render, otherwise false.
  102434. * @param mesh The mesh to render
  102435. * @returns true if it should render otherwise false
  102436. */
  102437. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  102438. /**
  102439. * Renders the submesh passed in parameter to the generation map.
  102440. */
  102441. protected _renderSubMesh(subMesh: SubMesh): void;
  102442. /**
  102443. * Rebuild the required buffers.
  102444. * @hidden Internal use only.
  102445. */
  102446. _rebuild(): void;
  102447. /**
  102448. * Dispose only the render target textures and post process.
  102449. */
  102450. private _disposeTextureAndPostProcesses;
  102451. /**
  102452. * Dispose the highlight layer and free resources.
  102453. */
  102454. dispose(): void;
  102455. /**
  102456. * Gets the class name of the effect layer
  102457. * @returns the string with the class name of the effect layer
  102458. */
  102459. getClassName(): string;
  102460. /**
  102461. * Creates an effect layer from parsed effect layer data
  102462. * @param parsedEffectLayer defines effect layer data
  102463. * @param scene defines the current scene
  102464. * @param rootUrl defines the root URL containing the effect layer information
  102465. * @returns a parsed effect Layer
  102466. */
  102467. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102468. }
  102469. }
  102470. declare module BABYLON {
  102471. interface AbstractScene {
  102472. /**
  102473. * The list of effect layers (highlights/glow) added to the scene
  102474. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102475. * @see http://doc.babylonjs.com/how_to/glow_layer
  102476. */
  102477. effectLayers: Array<EffectLayer>;
  102478. /**
  102479. * Removes the given effect layer from this scene.
  102480. * @param toRemove defines the effect layer to remove
  102481. * @returns the index of the removed effect layer
  102482. */
  102483. removeEffectLayer(toRemove: EffectLayer): number;
  102484. /**
  102485. * Adds the given effect layer to this scene
  102486. * @param newEffectLayer defines the effect layer to add
  102487. */
  102488. addEffectLayer(newEffectLayer: EffectLayer): void;
  102489. }
  102490. /**
  102491. * Defines the layer scene component responsible to manage any effect layers
  102492. * in a given scene.
  102493. */
  102494. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102495. /**
  102496. * The component name helpfull to identify the component in the list of scene components.
  102497. */
  102498. readonly name: string;
  102499. /**
  102500. * The scene the component belongs to.
  102501. */
  102502. scene: Scene;
  102503. private _engine;
  102504. private _renderEffects;
  102505. private _needStencil;
  102506. private _previousStencilState;
  102507. /**
  102508. * Creates a new instance of the component for the given scene
  102509. * @param scene Defines the scene to register the component in
  102510. */
  102511. constructor(scene: Scene);
  102512. /**
  102513. * Registers the component in a given scene
  102514. */
  102515. register(): void;
  102516. /**
  102517. * Rebuilds the elements related to this component in case of
  102518. * context lost for instance.
  102519. */
  102520. rebuild(): void;
  102521. /**
  102522. * Serializes the component data to the specified json object
  102523. * @param serializationObject The object to serialize to
  102524. */
  102525. serialize(serializationObject: any): void;
  102526. /**
  102527. * Adds all the element from the container to the scene
  102528. * @param container the container holding the elements
  102529. */
  102530. addFromContainer(container: AbstractScene): void;
  102531. /**
  102532. * Removes all the elements in the container from the scene
  102533. * @param container contains the elements to remove
  102534. */
  102535. removeFromContainer(container: AbstractScene): void;
  102536. /**
  102537. * Disposes the component and the associated ressources.
  102538. */
  102539. dispose(): void;
  102540. private _isReadyForMesh;
  102541. private _renderMainTexture;
  102542. private _setStencil;
  102543. private _setStencilBack;
  102544. private _draw;
  102545. private _drawCamera;
  102546. private _drawRenderingGroup;
  102547. }
  102548. }
  102549. declare module BABYLON {
  102550. /** @hidden */
  102551. export var glowMapMergePixelShader: {
  102552. name: string;
  102553. shader: string;
  102554. };
  102555. }
  102556. declare module BABYLON {
  102557. /** @hidden */
  102558. export var glowMapMergeVertexShader: {
  102559. name: string;
  102560. shader: string;
  102561. };
  102562. }
  102563. declare module BABYLON {
  102564. interface AbstractScene {
  102565. /**
  102566. * Return a the first highlight layer of the scene with a given name.
  102567. * @param name The name of the highlight layer to look for.
  102568. * @return The highlight layer if found otherwise null.
  102569. */
  102570. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102571. }
  102572. /**
  102573. * Glow layer options. This helps customizing the behaviour
  102574. * of the glow layer.
  102575. */
  102576. export interface IGlowLayerOptions {
  102577. /**
  102578. * Multiplication factor apply to the canvas size to compute the render target size
  102579. * used to generated the glowing objects (the smaller the faster).
  102580. */
  102581. mainTextureRatio: number;
  102582. /**
  102583. * Enforces a fixed size texture to ensure resize independant blur.
  102584. */
  102585. mainTextureFixedSize?: number;
  102586. /**
  102587. * How big is the kernel of the blur texture.
  102588. */
  102589. blurKernelSize: number;
  102590. /**
  102591. * The camera attached to the layer.
  102592. */
  102593. camera: Nullable<Camera>;
  102594. /**
  102595. * Enable MSAA by chosing the number of samples.
  102596. */
  102597. mainTextureSamples?: number;
  102598. /**
  102599. * The rendering group to draw the layer in.
  102600. */
  102601. renderingGroupId: number;
  102602. }
  102603. /**
  102604. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  102605. *
  102606. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102607. * glowy meshes to your scene.
  102608. *
  102609. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  102610. */
  102611. export class GlowLayer extends EffectLayer {
  102612. /**
  102613. * Effect Name of the layer.
  102614. */
  102615. static readonly EffectName: string;
  102616. /**
  102617. * The default blur kernel size used for the glow.
  102618. */
  102619. static DefaultBlurKernelSize: number;
  102620. /**
  102621. * The default texture size ratio used for the glow.
  102622. */
  102623. static DefaultTextureRatio: number;
  102624. /**
  102625. * Sets the kernel size of the blur.
  102626. */
  102627. /**
  102628. * Gets the kernel size of the blur.
  102629. */
  102630. blurKernelSize: number;
  102631. /**
  102632. * Sets the glow intensity.
  102633. */
  102634. /**
  102635. * Gets the glow intensity.
  102636. */
  102637. intensity: number;
  102638. private _options;
  102639. private _intensity;
  102640. private _horizontalBlurPostprocess1;
  102641. private _verticalBlurPostprocess1;
  102642. private _horizontalBlurPostprocess2;
  102643. private _verticalBlurPostprocess2;
  102644. private _blurTexture1;
  102645. private _blurTexture2;
  102646. private _postProcesses1;
  102647. private _postProcesses2;
  102648. private _includedOnlyMeshes;
  102649. private _excludedMeshes;
  102650. /**
  102651. * Callback used to let the user override the color selection on a per mesh basis
  102652. */
  102653. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  102654. /**
  102655. * Callback used to let the user override the texture selection on a per mesh basis
  102656. */
  102657. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  102658. /**
  102659. * Instantiates a new glow Layer and references it to the scene.
  102660. * @param name The name of the layer
  102661. * @param scene The scene to use the layer in
  102662. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  102663. */
  102664. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  102665. /**
  102666. * Get the effect name of the layer.
  102667. * @return The effect name
  102668. */
  102669. getEffectName(): string;
  102670. /**
  102671. * Create the merge effect. This is the shader use to blit the information back
  102672. * to the main canvas at the end of the scene rendering.
  102673. */
  102674. protected _createMergeEffect(): Effect;
  102675. /**
  102676. * Creates the render target textures and post processes used in the glow layer.
  102677. */
  102678. protected _createTextureAndPostProcesses(): void;
  102679. /**
  102680. * Checks for the readiness of the element composing the layer.
  102681. * @param subMesh the mesh to check for
  102682. * @param useInstances specify wether or not to use instances to render the mesh
  102683. * @param emissiveTexture the associated emissive texture used to generate the glow
  102684. * @return true if ready otherwise, false
  102685. */
  102686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102687. /**
  102688. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102689. */
  102690. needStencil(): boolean;
  102691. /**
  102692. * Returns true if the mesh can be rendered, otherwise false.
  102693. * @param mesh The mesh to render
  102694. * @param material The material used on the mesh
  102695. * @returns true if it can be rendered otherwise false
  102696. */
  102697. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102698. /**
  102699. * Implementation specific of rendering the generating effect on the main canvas.
  102700. * @param effect The effect used to render through
  102701. */
  102702. protected _internalRender(effect: Effect): void;
  102703. /**
  102704. * Sets the required values for both the emissive texture and and the main color.
  102705. */
  102706. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102707. /**
  102708. * Returns true if the mesh should render, otherwise false.
  102709. * @param mesh The mesh to render
  102710. * @returns true if it should render otherwise false
  102711. */
  102712. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102713. /**
  102714. * Adds specific effects defines.
  102715. * @param defines The defines to add specifics to.
  102716. */
  102717. protected _addCustomEffectDefines(defines: string[]): void;
  102718. /**
  102719. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  102720. * @param mesh The mesh to exclude from the glow layer
  102721. */
  102722. addExcludedMesh(mesh: Mesh): void;
  102723. /**
  102724. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  102725. * @param mesh The mesh to remove
  102726. */
  102727. removeExcludedMesh(mesh: Mesh): void;
  102728. /**
  102729. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  102730. * @param mesh The mesh to include in the glow layer
  102731. */
  102732. addIncludedOnlyMesh(mesh: Mesh): void;
  102733. /**
  102734. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  102735. * @param mesh The mesh to remove
  102736. */
  102737. removeIncludedOnlyMesh(mesh: Mesh): void;
  102738. /**
  102739. * Determine if a given mesh will be used in the glow layer
  102740. * @param mesh The mesh to test
  102741. * @returns true if the mesh will be highlighted by the current glow layer
  102742. */
  102743. hasMesh(mesh: AbstractMesh): boolean;
  102744. /**
  102745. * Free any resources and references associated to a mesh.
  102746. * Internal use
  102747. * @param mesh The mesh to free.
  102748. * @hidden
  102749. */
  102750. _disposeMesh(mesh: Mesh): void;
  102751. /**
  102752. * Gets the class name of the effect layer
  102753. * @returns the string with the class name of the effect layer
  102754. */
  102755. getClassName(): string;
  102756. /**
  102757. * Serializes this glow layer
  102758. * @returns a serialized glow layer object
  102759. */
  102760. serialize(): any;
  102761. /**
  102762. * Creates a Glow Layer from parsed glow layer data
  102763. * @param parsedGlowLayer defines glow layer data
  102764. * @param scene defines the current scene
  102765. * @param rootUrl defines the root URL containing the glow layer information
  102766. * @returns a parsed Glow Layer
  102767. */
  102768. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  102769. }
  102770. }
  102771. declare module BABYLON {
  102772. /** @hidden */
  102773. export var glowBlurPostProcessPixelShader: {
  102774. name: string;
  102775. shader: string;
  102776. };
  102777. }
  102778. declare module BABYLON {
  102779. interface AbstractScene {
  102780. /**
  102781. * Return a the first highlight layer of the scene with a given name.
  102782. * @param name The name of the highlight layer to look for.
  102783. * @return The highlight layer if found otherwise null.
  102784. */
  102785. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  102786. }
  102787. /**
  102788. * Highlight layer options. This helps customizing the behaviour
  102789. * of the highlight layer.
  102790. */
  102791. export interface IHighlightLayerOptions {
  102792. /**
  102793. * Multiplication factor apply to the canvas size to compute the render target size
  102794. * used to generated the glowing objects (the smaller the faster).
  102795. */
  102796. mainTextureRatio: number;
  102797. /**
  102798. * Enforces a fixed size texture to ensure resize independant blur.
  102799. */
  102800. mainTextureFixedSize?: number;
  102801. /**
  102802. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  102803. * of the picture to blur (the smaller the faster).
  102804. */
  102805. blurTextureSizeRatio: number;
  102806. /**
  102807. * How big in texel of the blur texture is the vertical blur.
  102808. */
  102809. blurVerticalSize: number;
  102810. /**
  102811. * How big in texel of the blur texture is the horizontal blur.
  102812. */
  102813. blurHorizontalSize: number;
  102814. /**
  102815. * Alpha blending mode used to apply the blur. Default is combine.
  102816. */
  102817. alphaBlendingMode: number;
  102818. /**
  102819. * The camera attached to the layer.
  102820. */
  102821. camera: Nullable<Camera>;
  102822. /**
  102823. * Should we display highlight as a solid stroke?
  102824. */
  102825. isStroke?: boolean;
  102826. /**
  102827. * The rendering group to draw the layer in.
  102828. */
  102829. renderingGroupId: number;
  102830. }
  102831. /**
  102832. * The highlight layer Helps adding a glow effect around a mesh.
  102833. *
  102834. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102835. * glowy meshes to your scene.
  102836. *
  102837. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  102838. */
  102839. export class HighlightLayer extends EffectLayer {
  102840. name: string;
  102841. /**
  102842. * Effect Name of the highlight layer.
  102843. */
  102844. static readonly EffectName: string;
  102845. /**
  102846. * The neutral color used during the preparation of the glow effect.
  102847. * This is black by default as the blend operation is a blend operation.
  102848. */
  102849. static NeutralColor: Color4;
  102850. /**
  102851. * Stencil value used for glowing meshes.
  102852. */
  102853. static GlowingMeshStencilReference: number;
  102854. /**
  102855. * Stencil value used for the other meshes in the scene.
  102856. */
  102857. static NormalMeshStencilReference: number;
  102858. /**
  102859. * Specifies whether or not the inner glow is ACTIVE in the layer.
  102860. */
  102861. innerGlow: boolean;
  102862. /**
  102863. * Specifies whether or not the outer glow is ACTIVE in the layer.
  102864. */
  102865. outerGlow: boolean;
  102866. /**
  102867. * Specifies the horizontal size of the blur.
  102868. */
  102869. /**
  102870. * Gets the horizontal size of the blur.
  102871. */
  102872. blurHorizontalSize: number;
  102873. /**
  102874. * Specifies the vertical size of the blur.
  102875. */
  102876. /**
  102877. * Gets the vertical size of the blur.
  102878. */
  102879. blurVerticalSize: number;
  102880. /**
  102881. * An event triggered when the highlight layer is being blurred.
  102882. */
  102883. onBeforeBlurObservable: Observable<HighlightLayer>;
  102884. /**
  102885. * An event triggered when the highlight layer has been blurred.
  102886. */
  102887. onAfterBlurObservable: Observable<HighlightLayer>;
  102888. private _instanceGlowingMeshStencilReference;
  102889. private _options;
  102890. private _downSamplePostprocess;
  102891. private _horizontalBlurPostprocess;
  102892. private _verticalBlurPostprocess;
  102893. private _blurTexture;
  102894. private _meshes;
  102895. private _excludedMeshes;
  102896. /**
  102897. * Instantiates a new highlight Layer and references it to the scene..
  102898. * @param name The name of the layer
  102899. * @param scene The scene to use the layer in
  102900. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  102901. */
  102902. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  102903. /**
  102904. * Get the effect name of the layer.
  102905. * @return The effect name
  102906. */
  102907. getEffectName(): string;
  102908. /**
  102909. * Create the merge effect. This is the shader use to blit the information back
  102910. * to the main canvas at the end of the scene rendering.
  102911. */
  102912. protected _createMergeEffect(): Effect;
  102913. /**
  102914. * Creates the render target textures and post processes used in the highlight layer.
  102915. */
  102916. protected _createTextureAndPostProcesses(): void;
  102917. /**
  102918. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102919. */
  102920. needStencil(): boolean;
  102921. /**
  102922. * Checks for the readiness of the element composing the layer.
  102923. * @param subMesh the mesh to check for
  102924. * @param useInstances specify wether or not to use instances to render the mesh
  102925. * @param emissiveTexture the associated emissive texture used to generate the glow
  102926. * @return true if ready otherwise, false
  102927. */
  102928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102929. /**
  102930. * Implementation specific of rendering the generating effect on the main canvas.
  102931. * @param effect The effect used to render through
  102932. */
  102933. protected _internalRender(effect: Effect): void;
  102934. /**
  102935. * Returns true if the layer contains information to display, otherwise false.
  102936. */
  102937. shouldRender(): boolean;
  102938. /**
  102939. * Returns true if the mesh should render, otherwise false.
  102940. * @param mesh The mesh to render
  102941. * @returns true if it should render otherwise false
  102942. */
  102943. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102944. /**
  102945. * Sets the required values for both the emissive texture and and the main color.
  102946. */
  102947. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102948. /**
  102949. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  102950. * @param mesh The mesh to exclude from the highlight layer
  102951. */
  102952. addExcludedMesh(mesh: Mesh): void;
  102953. /**
  102954. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  102955. * @param mesh The mesh to highlight
  102956. */
  102957. removeExcludedMesh(mesh: Mesh): void;
  102958. /**
  102959. * Determine if a given mesh will be highlighted by the current HighlightLayer
  102960. * @param mesh mesh to test
  102961. * @returns true if the mesh will be highlighted by the current HighlightLayer
  102962. */
  102963. hasMesh(mesh: AbstractMesh): boolean;
  102964. /**
  102965. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  102966. * @param mesh The mesh to highlight
  102967. * @param color The color of the highlight
  102968. * @param glowEmissiveOnly Extract the glow from the emissive texture
  102969. */
  102970. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  102971. /**
  102972. * Remove a mesh from the highlight layer in order to make it stop glowing.
  102973. * @param mesh The mesh to highlight
  102974. */
  102975. removeMesh(mesh: Mesh): void;
  102976. /**
  102977. * Force the stencil to the normal expected value for none glowing parts
  102978. */
  102979. private _defaultStencilReference;
  102980. /**
  102981. * Free any resources and references associated to a mesh.
  102982. * Internal use
  102983. * @param mesh The mesh to free.
  102984. * @hidden
  102985. */
  102986. _disposeMesh(mesh: Mesh): void;
  102987. /**
  102988. * Dispose the highlight layer and free resources.
  102989. */
  102990. dispose(): void;
  102991. /**
  102992. * Gets the class name of the effect layer
  102993. * @returns the string with the class name of the effect layer
  102994. */
  102995. getClassName(): string;
  102996. /**
  102997. * Serializes this Highlight layer
  102998. * @returns a serialized Highlight layer object
  102999. */
  103000. serialize(): any;
  103001. /**
  103002. * Creates a Highlight layer from parsed Highlight layer data
  103003. * @param parsedHightlightLayer defines the Highlight layer data
  103004. * @param scene defines the current scene
  103005. * @param rootUrl defines the root URL containing the Highlight layer information
  103006. * @returns a parsed Highlight layer
  103007. */
  103008. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103009. }
  103010. }
  103011. declare module BABYLON {
  103012. /** @hidden */
  103013. export var lensFlarePixelShader: {
  103014. name: string;
  103015. shader: string;
  103016. };
  103017. }
  103018. declare module BABYLON {
  103019. /** @hidden */
  103020. export var lensFlareVertexShader: {
  103021. name: string;
  103022. shader: string;
  103023. };
  103024. }
  103025. declare module BABYLON {
  103026. /**
  103027. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103028. * It is usually composed of several `lensFlare`.
  103029. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103030. */
  103031. export class LensFlareSystem {
  103032. /**
  103033. * Define the name of the lens flare system
  103034. */
  103035. name: string;
  103036. /**
  103037. * List of lens flares used in this system.
  103038. */
  103039. lensFlares: LensFlare[];
  103040. /**
  103041. * Define a limit from the border the lens flare can be visible.
  103042. */
  103043. borderLimit: number;
  103044. /**
  103045. * Define a viewport border we do not want to see the lens flare in.
  103046. */
  103047. viewportBorder: number;
  103048. /**
  103049. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103050. */
  103051. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103052. /**
  103053. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103054. */
  103055. layerMask: number;
  103056. /**
  103057. * Define the id of the lens flare system in the scene.
  103058. * (equal to name by default)
  103059. */
  103060. id: string;
  103061. private _scene;
  103062. private _emitter;
  103063. private _vertexBuffers;
  103064. private _indexBuffer;
  103065. private _effect;
  103066. private _positionX;
  103067. private _positionY;
  103068. private _isEnabled;
  103069. /** @hidden */
  103070. static _SceneComponentInitialization: (scene: Scene) => void;
  103071. /**
  103072. * Instantiates a lens flare system.
  103073. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103074. * It is usually composed of several `lensFlare`.
  103075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103076. * @param name Define the name of the lens flare system in the scene
  103077. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103078. * @param scene Define the scene the lens flare system belongs to
  103079. */
  103080. constructor(
  103081. /**
  103082. * Define the name of the lens flare system
  103083. */
  103084. name: string, emitter: any, scene: Scene);
  103085. /**
  103086. * Define if the lens flare system is enabled.
  103087. */
  103088. isEnabled: boolean;
  103089. /**
  103090. * Get the scene the effects belongs to.
  103091. * @returns the scene holding the lens flare system
  103092. */
  103093. getScene(): Scene;
  103094. /**
  103095. * Get the emitter of the lens flare system.
  103096. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103097. * @returns the emitter of the lens flare system
  103098. */
  103099. getEmitter(): any;
  103100. /**
  103101. * Set the emitter of the lens flare system.
  103102. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103103. * @param newEmitter Define the new emitter of the system
  103104. */
  103105. setEmitter(newEmitter: any): void;
  103106. /**
  103107. * Get the lens flare system emitter position.
  103108. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103109. * @returns the position
  103110. */
  103111. getEmitterPosition(): Vector3;
  103112. /**
  103113. * @hidden
  103114. */
  103115. computeEffectivePosition(globalViewport: Viewport): boolean;
  103116. /** @hidden */
  103117. _isVisible(): boolean;
  103118. /**
  103119. * @hidden
  103120. */
  103121. render(): boolean;
  103122. /**
  103123. * Dispose and release the lens flare with its associated resources.
  103124. */
  103125. dispose(): void;
  103126. /**
  103127. * Parse a lens flare system from a JSON repressentation
  103128. * @param parsedLensFlareSystem Define the JSON to parse
  103129. * @param scene Define the scene the parsed system should be instantiated in
  103130. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103131. * @returns the parsed system
  103132. */
  103133. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103134. /**
  103135. * Serialize the current Lens Flare System into a JSON representation.
  103136. * @returns the serialized JSON
  103137. */
  103138. serialize(): any;
  103139. }
  103140. }
  103141. declare module BABYLON {
  103142. /**
  103143. * This represents one of the lens effect in a `lensFlareSystem`.
  103144. * It controls one of the indiviual texture used in the effect.
  103145. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103146. */
  103147. export class LensFlare {
  103148. /**
  103149. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103150. */
  103151. size: number;
  103152. /**
  103153. * 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.
  103154. */
  103155. position: number;
  103156. /**
  103157. * Define the lens color.
  103158. */
  103159. color: Color3;
  103160. /**
  103161. * Define the lens texture.
  103162. */
  103163. texture: Nullable<Texture>;
  103164. /**
  103165. * Define the alpha mode to render this particular lens.
  103166. */
  103167. alphaMode: number;
  103168. private _system;
  103169. /**
  103170. * Creates a new Lens Flare.
  103171. * This represents one of the lens effect in a `lensFlareSystem`.
  103172. * It controls one of the indiviual texture used in the effect.
  103173. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103174. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103175. * @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.
  103176. * @param color Define the lens color
  103177. * @param imgUrl Define the lens texture url
  103178. * @param system Define the `lensFlareSystem` this flare is part of
  103179. * @returns The newly created Lens Flare
  103180. */
  103181. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103182. /**
  103183. * Instantiates a new Lens Flare.
  103184. * This represents one of the lens effect in a `lensFlareSystem`.
  103185. * It controls one of the indiviual texture used in the effect.
  103186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103187. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103188. * @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.
  103189. * @param color Define the lens color
  103190. * @param imgUrl Define the lens texture url
  103191. * @param system Define the `lensFlareSystem` this flare is part of
  103192. */
  103193. constructor(
  103194. /**
  103195. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103196. */
  103197. size: number,
  103198. /**
  103199. * 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.
  103200. */
  103201. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103202. /**
  103203. * Dispose and release the lens flare with its associated resources.
  103204. */
  103205. dispose(): void;
  103206. }
  103207. }
  103208. declare module BABYLON {
  103209. interface AbstractScene {
  103210. /**
  103211. * The list of lens flare system added to the scene
  103212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103213. */
  103214. lensFlareSystems: Array<LensFlareSystem>;
  103215. /**
  103216. * Removes the given lens flare system from this scene.
  103217. * @param toRemove The lens flare system to remove
  103218. * @returns The index of the removed lens flare system
  103219. */
  103220. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103221. /**
  103222. * Adds the given lens flare system to this scene
  103223. * @param newLensFlareSystem The lens flare system to add
  103224. */
  103225. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103226. /**
  103227. * Gets a lens flare system using its name
  103228. * @param name defines the name to look for
  103229. * @returns the lens flare system or null if not found
  103230. */
  103231. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103232. /**
  103233. * Gets a lens flare system using its id
  103234. * @param id defines the id to look for
  103235. * @returns the lens flare system or null if not found
  103236. */
  103237. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103238. }
  103239. /**
  103240. * Defines the lens flare scene component responsible to manage any lens flares
  103241. * in a given scene.
  103242. */
  103243. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103244. /**
  103245. * The component name helpfull to identify the component in the list of scene components.
  103246. */
  103247. readonly name: string;
  103248. /**
  103249. * The scene the component belongs to.
  103250. */
  103251. scene: Scene;
  103252. /**
  103253. * Creates a new instance of the component for the given scene
  103254. * @param scene Defines the scene to register the component in
  103255. */
  103256. constructor(scene: Scene);
  103257. /**
  103258. * Registers the component in a given scene
  103259. */
  103260. register(): void;
  103261. /**
  103262. * Rebuilds the elements related to this component in case of
  103263. * context lost for instance.
  103264. */
  103265. rebuild(): void;
  103266. /**
  103267. * Adds all the element from the container to the scene
  103268. * @param container the container holding the elements
  103269. */
  103270. addFromContainer(container: AbstractScene): void;
  103271. /**
  103272. * Removes all the elements in the container from the scene
  103273. * @param container contains the elements to remove
  103274. */
  103275. removeFromContainer(container: AbstractScene): void;
  103276. /**
  103277. * Serializes the component data to the specified json object
  103278. * @param serializationObject The object to serialize to
  103279. */
  103280. serialize(serializationObject: any): void;
  103281. /**
  103282. * Disposes the component and the associated ressources.
  103283. */
  103284. dispose(): void;
  103285. private _draw;
  103286. }
  103287. }
  103288. declare module BABYLON {
  103289. /**
  103290. * Defines the shadow generator component responsible to manage any shadow generators
  103291. * in a given scene.
  103292. */
  103293. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103294. /**
  103295. * The component name helpfull to identify the component in the list of scene components.
  103296. */
  103297. readonly name: string;
  103298. /**
  103299. * The scene the component belongs to.
  103300. */
  103301. scene: Scene;
  103302. /**
  103303. * Creates a new instance of the component for the given scene
  103304. * @param scene Defines the scene to register the component in
  103305. */
  103306. constructor(scene: Scene);
  103307. /**
  103308. * Registers the component in a given scene
  103309. */
  103310. register(): void;
  103311. /**
  103312. * Rebuilds the elements related to this component in case of
  103313. * context lost for instance.
  103314. */
  103315. rebuild(): void;
  103316. /**
  103317. * Serializes the component data to the specified json object
  103318. * @param serializationObject The object to serialize to
  103319. */
  103320. serialize(serializationObject: any): void;
  103321. /**
  103322. * Adds all the element from the container to the scene
  103323. * @param container the container holding the elements
  103324. */
  103325. addFromContainer(container: AbstractScene): void;
  103326. /**
  103327. * Removes all the elements in the container from the scene
  103328. * @param container contains the elements to remove
  103329. */
  103330. removeFromContainer(container: AbstractScene): void;
  103331. /**
  103332. * Rebuilds the elements related to this component in case of
  103333. * context lost for instance.
  103334. */
  103335. dispose(): void;
  103336. private _gatherRenderTargets;
  103337. }
  103338. }
  103339. declare module BABYLON {
  103340. /**
  103341. * A directional light is defined by a direction (what a surprise!).
  103342. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103343. * 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.
  103344. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103345. */
  103346. export class DirectionalLight extends ShadowLight {
  103347. private _shadowFrustumSize;
  103348. /**
  103349. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103350. */
  103351. /**
  103352. * Specifies a fix frustum size for the shadow generation.
  103353. */
  103354. shadowFrustumSize: number;
  103355. private _shadowOrthoScale;
  103356. /**
  103357. * Gets the shadow projection scale against the optimal computed one.
  103358. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103359. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103360. */
  103361. /**
  103362. * Sets the shadow projection scale against the optimal computed one.
  103363. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103364. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103365. */
  103366. shadowOrthoScale: number;
  103367. /**
  103368. * Automatically compute the projection matrix to best fit (including all the casters)
  103369. * on each frame.
  103370. */
  103371. autoUpdateExtends: boolean;
  103372. private _orthoLeft;
  103373. private _orthoRight;
  103374. private _orthoTop;
  103375. private _orthoBottom;
  103376. /**
  103377. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103378. * The directional light is emitted from everywhere in the given direction.
  103379. * It can cast shadows.
  103380. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103381. * @param name The friendly name of the light
  103382. * @param direction The direction of the light
  103383. * @param scene The scene the light belongs to
  103384. */
  103385. constructor(name: string, direction: Vector3, scene: Scene);
  103386. /**
  103387. * Returns the string "DirectionalLight".
  103388. * @return The class name
  103389. */
  103390. getClassName(): string;
  103391. /**
  103392. * Returns the integer 1.
  103393. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103394. */
  103395. getTypeID(): number;
  103396. /**
  103397. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103398. * Returns the DirectionalLight Shadow projection matrix.
  103399. */
  103400. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103401. /**
  103402. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103403. * Returns the DirectionalLight Shadow projection matrix.
  103404. */
  103405. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103406. /**
  103407. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103408. * Returns the DirectionalLight Shadow projection matrix.
  103409. */
  103410. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103411. protected _buildUniformLayout(): void;
  103412. /**
  103413. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103414. * @param effect The effect to update
  103415. * @param lightIndex The index of the light in the effect to update
  103416. * @returns The directional light
  103417. */
  103418. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103419. /**
  103420. * Gets the minZ used for shadow according to both the scene and the light.
  103421. *
  103422. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103423. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103424. * @param activeCamera The camera we are returning the min for
  103425. * @returns the depth min z
  103426. */
  103427. getDepthMinZ(activeCamera: Camera): number;
  103428. /**
  103429. * Gets the maxZ used for shadow according to both the scene and the light.
  103430. *
  103431. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103432. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103433. * @param activeCamera The camera we are returning the max for
  103434. * @returns the depth max z
  103435. */
  103436. getDepthMaxZ(activeCamera: Camera): number;
  103437. /**
  103438. * Prepares the list of defines specific to the light type.
  103439. * @param defines the list of defines
  103440. * @param lightIndex defines the index of the light for the effect
  103441. */
  103442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103443. }
  103444. }
  103445. declare module BABYLON {
  103446. /**
  103447. * A point light is a light defined by an unique point in world space.
  103448. * The light is emitted in every direction from this point.
  103449. * A good example of a point light is a standard light bulb.
  103450. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103451. */
  103452. export class PointLight extends ShadowLight {
  103453. private _shadowAngle;
  103454. /**
  103455. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103456. * This specifies what angle the shadow will use to be created.
  103457. *
  103458. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103459. */
  103460. /**
  103461. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103462. * This specifies what angle the shadow will use to be created.
  103463. *
  103464. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103465. */
  103466. shadowAngle: number;
  103467. /**
  103468. * Gets the direction if it has been set.
  103469. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103470. */
  103471. /**
  103472. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103473. */
  103474. direction: Vector3;
  103475. /**
  103476. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103477. * A PointLight emits the light in every direction.
  103478. * It can cast shadows.
  103479. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103480. * ```javascript
  103481. * var pointLight = new PointLight("pl", camera.position, scene);
  103482. * ```
  103483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103484. * @param name The light friendly name
  103485. * @param position The position of the point light in the scene
  103486. * @param scene The scene the lights belongs to
  103487. */
  103488. constructor(name: string, position: Vector3, scene: Scene);
  103489. /**
  103490. * Returns the string "PointLight"
  103491. * @returns the class name
  103492. */
  103493. getClassName(): string;
  103494. /**
  103495. * Returns the integer 0.
  103496. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103497. */
  103498. getTypeID(): number;
  103499. /**
  103500. * Specifies wether or not the shadowmap should be a cube texture.
  103501. * @returns true if the shadowmap needs to be a cube texture.
  103502. */
  103503. needCube(): boolean;
  103504. /**
  103505. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103506. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103507. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103508. */
  103509. getShadowDirection(faceIndex?: number): Vector3;
  103510. /**
  103511. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103512. * - fov = PI / 2
  103513. * - aspect ratio : 1.0
  103514. * - z-near and far equal to the active camera minZ and maxZ.
  103515. * Returns the PointLight.
  103516. */
  103517. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103518. protected _buildUniformLayout(): void;
  103519. /**
  103520. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103521. * @param effect The effect to update
  103522. * @param lightIndex The index of the light in the effect to update
  103523. * @returns The point light
  103524. */
  103525. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103526. /**
  103527. * Prepares the list of defines specific to the light type.
  103528. * @param defines the list of defines
  103529. * @param lightIndex defines the index of the light for the effect
  103530. */
  103531. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103532. }
  103533. }
  103534. declare module BABYLON {
  103535. /**
  103536. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103537. * These values define a cone of light starting from the position, emitting toward the direction.
  103538. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103539. * and the exponent defines the speed of the decay of the light with distance (reach).
  103540. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103541. */
  103542. export class SpotLight extends ShadowLight {
  103543. private _angle;
  103544. private _innerAngle;
  103545. private _cosHalfAngle;
  103546. private _lightAngleScale;
  103547. private _lightAngleOffset;
  103548. /**
  103549. * Gets the cone angle of the spot light in Radians.
  103550. */
  103551. /**
  103552. * Sets the cone angle of the spot light in Radians.
  103553. */
  103554. angle: number;
  103555. /**
  103556. * Only used in gltf falloff mode, this defines the angle where
  103557. * the directional falloff will start before cutting at angle which could be seen
  103558. * as outer angle.
  103559. */
  103560. /**
  103561. * Only used in gltf falloff mode, this defines the angle where
  103562. * the directional falloff will start before cutting at angle which could be seen
  103563. * as outer angle.
  103564. */
  103565. innerAngle: number;
  103566. private _shadowAngleScale;
  103567. /**
  103568. * Allows scaling the angle of the light for shadow generation only.
  103569. */
  103570. /**
  103571. * Allows scaling the angle of the light for shadow generation only.
  103572. */
  103573. shadowAngleScale: number;
  103574. /**
  103575. * The light decay speed with the distance from the emission spot.
  103576. */
  103577. exponent: number;
  103578. private _projectionTextureMatrix;
  103579. /**
  103580. * Allows reading the projecton texture
  103581. */
  103582. readonly projectionTextureMatrix: Matrix;
  103583. protected _projectionTextureLightNear: number;
  103584. /**
  103585. * Gets the near clip of the Spotlight for texture projection.
  103586. */
  103587. /**
  103588. * Sets the near clip of the Spotlight for texture projection.
  103589. */
  103590. projectionTextureLightNear: number;
  103591. protected _projectionTextureLightFar: number;
  103592. /**
  103593. * Gets the far clip of the Spotlight for texture projection.
  103594. */
  103595. /**
  103596. * Sets the far clip of the Spotlight for texture projection.
  103597. */
  103598. projectionTextureLightFar: number;
  103599. protected _projectionTextureUpDirection: Vector3;
  103600. /**
  103601. * Gets the Up vector of the Spotlight for texture projection.
  103602. */
  103603. /**
  103604. * Sets the Up vector of the Spotlight for texture projection.
  103605. */
  103606. projectionTextureUpDirection: Vector3;
  103607. private _projectionTexture;
  103608. /**
  103609. * Gets the projection texture of the light.
  103610. */
  103611. /**
  103612. * Sets the projection texture of the light.
  103613. */
  103614. projectionTexture: Nullable<BaseTexture>;
  103615. private _projectionTextureViewLightDirty;
  103616. private _projectionTextureProjectionLightDirty;
  103617. private _projectionTextureDirty;
  103618. private _projectionTextureViewTargetVector;
  103619. private _projectionTextureViewLightMatrix;
  103620. private _projectionTextureProjectionLightMatrix;
  103621. private _projectionTextureScalingMatrix;
  103622. /**
  103623. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103624. * It can cast shadows.
  103625. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103626. * @param name The light friendly name
  103627. * @param position The position of the spot light in the scene
  103628. * @param direction The direction of the light in the scene
  103629. * @param angle The cone angle of the light in Radians
  103630. * @param exponent The light decay speed with the distance from the emission spot
  103631. * @param scene The scene the lights belongs to
  103632. */
  103633. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103634. /**
  103635. * Returns the string "SpotLight".
  103636. * @returns the class name
  103637. */
  103638. getClassName(): string;
  103639. /**
  103640. * Returns the integer 2.
  103641. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103642. */
  103643. getTypeID(): number;
  103644. /**
  103645. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103646. */
  103647. protected _setDirection(value: Vector3): void;
  103648. /**
  103649. * Overrides the position setter to recompute the projection texture view light Matrix.
  103650. */
  103651. protected _setPosition(value: Vector3): void;
  103652. /**
  103653. * 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.
  103654. * Returns the SpotLight.
  103655. */
  103656. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103657. protected _computeProjectionTextureViewLightMatrix(): void;
  103658. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103659. /**
  103660. * Main function for light texture projection matrix computing.
  103661. */
  103662. protected _computeProjectionTextureMatrix(): void;
  103663. protected _buildUniformLayout(): void;
  103664. private _computeAngleValues;
  103665. /**
  103666. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103667. * @param effect The effect to update
  103668. * @param lightIndex The index of the light in the effect to update
  103669. * @returns The spot light
  103670. */
  103671. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103672. /**
  103673. * Disposes the light and the associated resources.
  103674. */
  103675. dispose(): void;
  103676. /**
  103677. * Prepares the list of defines specific to the light type.
  103678. * @param defines the list of defines
  103679. * @param lightIndex defines the index of the light for the effect
  103680. */
  103681. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103682. }
  103683. }
  103684. declare module BABYLON {
  103685. /**
  103686. * Header information of HDR texture files.
  103687. */
  103688. export interface HDRInfo {
  103689. /**
  103690. * The height of the texture in pixels.
  103691. */
  103692. height: number;
  103693. /**
  103694. * The width of the texture in pixels.
  103695. */
  103696. width: number;
  103697. /**
  103698. * The index of the beginning of the data in the binary file.
  103699. */
  103700. dataPosition: number;
  103701. }
  103702. /**
  103703. * This groups tools to convert HDR texture to native colors array.
  103704. */
  103705. export class HDRTools {
  103706. private static Ldexp;
  103707. private static Rgbe2float;
  103708. private static readStringLine;
  103709. /**
  103710. * Reads header information from an RGBE texture stored in a native array.
  103711. * More information on this format are available here:
  103712. * https://en.wikipedia.org/wiki/RGBE_image_format
  103713. *
  103714. * @param uint8array The binary file stored in native array.
  103715. * @return The header information.
  103716. */
  103717. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  103718. /**
  103719. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  103720. * This RGBE texture needs to store the information as a panorama.
  103721. *
  103722. * More information on this format are available here:
  103723. * https://en.wikipedia.org/wiki/RGBE_image_format
  103724. *
  103725. * @param buffer The binary file stored in an array buffer.
  103726. * @param size The expected size of the extracted cubemap.
  103727. * @return The Cube Map information.
  103728. */
  103729. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  103730. /**
  103731. * Returns the pixels data extracted from an RGBE texture.
  103732. * This pixels will be stored left to right up to down in the R G B order in one array.
  103733. *
  103734. * More information on this format are available here:
  103735. * https://en.wikipedia.org/wiki/RGBE_image_format
  103736. *
  103737. * @param uint8array The binary file stored in an array buffer.
  103738. * @param hdrInfo The header information of the file.
  103739. * @return The pixels data in RGB right to left up to down order.
  103740. */
  103741. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  103742. private static RGBE_ReadPixels_RLE;
  103743. }
  103744. }
  103745. declare module BABYLON {
  103746. /**
  103747. * This represents a texture coming from an HDR input.
  103748. *
  103749. * The only supported format is currently panorama picture stored in RGBE format.
  103750. * Example of such files can be found on HDRLib: http://hdrlib.com/
  103751. */
  103752. export class HDRCubeTexture extends BaseTexture {
  103753. private static _facesMapping;
  103754. private _generateHarmonics;
  103755. private _noMipmap;
  103756. private _textureMatrix;
  103757. private _size;
  103758. private _onLoad;
  103759. private _onError;
  103760. /**
  103761. * The texture URL.
  103762. */
  103763. url: string;
  103764. /**
  103765. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  103766. */
  103767. coordinatesMode: number;
  103768. protected _isBlocking: boolean;
  103769. /**
  103770. * Sets wether or not the texture is blocking during loading.
  103771. */
  103772. /**
  103773. * Gets wether or not the texture is blocking during loading.
  103774. */
  103775. isBlocking: boolean;
  103776. protected _rotationY: number;
  103777. /**
  103778. * Sets texture matrix rotation angle around Y axis in radians.
  103779. */
  103780. /**
  103781. * Gets texture matrix rotation angle around Y axis radians.
  103782. */
  103783. rotationY: number;
  103784. /**
  103785. * Gets or sets the center of the bounding box associated with the cube texture
  103786. * It must define where the camera used to render the texture was set
  103787. */
  103788. boundingBoxPosition: Vector3;
  103789. private _boundingBoxSize;
  103790. /**
  103791. * Gets or sets the size of the bounding box associated with the cube texture
  103792. * When defined, the cubemap will switch to local mode
  103793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103794. * @example https://www.babylonjs-playground.com/#RNASML
  103795. */
  103796. boundingBoxSize: Vector3;
  103797. /**
  103798. * Instantiates an HDRTexture from the following parameters.
  103799. *
  103800. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  103801. * @param scene The scene the texture will be used in
  103802. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  103803. * @param noMipmap Forces to not generate the mipmap if true
  103804. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  103805. * @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)
  103806. * @param reserved Reserved flag for internal use.
  103807. */
  103808. 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>);
  103809. /**
  103810. * Get the current class name of the texture useful for serialization or dynamic coding.
  103811. * @returns "HDRCubeTexture"
  103812. */
  103813. getClassName(): string;
  103814. /**
  103815. * Occurs when the file is raw .hdr file.
  103816. */
  103817. private loadTexture;
  103818. clone(): HDRCubeTexture;
  103819. delayLoad(): void;
  103820. /**
  103821. * Get the texture reflection matrix used to rotate/transform the reflection.
  103822. * @returns the reflection matrix
  103823. */
  103824. getReflectionTextureMatrix(): Matrix;
  103825. /**
  103826. * Set the texture reflection matrix used to rotate/transform the reflection.
  103827. * @param value Define the reflection matrix to set
  103828. */
  103829. setReflectionTextureMatrix(value: Matrix): void;
  103830. /**
  103831. * Parses a JSON representation of an HDR Texture in order to create the texture
  103832. * @param parsedTexture Define the JSON representation
  103833. * @param scene Define the scene the texture should be created in
  103834. * @param rootUrl Define the root url in case we need to load relative dependencies
  103835. * @returns the newly created texture after parsing
  103836. */
  103837. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  103838. serialize(): any;
  103839. }
  103840. }
  103841. declare module BABYLON {
  103842. /**
  103843. * Class used to control physics engine
  103844. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103845. */
  103846. export class PhysicsEngine implements IPhysicsEngine {
  103847. private _physicsPlugin;
  103848. /**
  103849. * Global value used to control the smallest number supported by the simulation
  103850. */
  103851. static Epsilon: number;
  103852. private _impostors;
  103853. private _joints;
  103854. /**
  103855. * Gets the gravity vector used by the simulation
  103856. */
  103857. gravity: Vector3;
  103858. /**
  103859. * Factory used to create the default physics plugin.
  103860. * @returns The default physics plugin
  103861. */
  103862. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  103863. /**
  103864. * Creates a new Physics Engine
  103865. * @param gravity defines the gravity vector used by the simulation
  103866. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  103867. */
  103868. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  103869. /**
  103870. * Sets the gravity vector used by the simulation
  103871. * @param gravity defines the gravity vector to use
  103872. */
  103873. setGravity(gravity: Vector3): void;
  103874. /**
  103875. * Set the time step of the physics engine.
  103876. * Default is 1/60.
  103877. * To slow it down, enter 1/600 for example.
  103878. * To speed it up, 1/30
  103879. * @param newTimeStep defines the new timestep to apply to this world.
  103880. */
  103881. setTimeStep(newTimeStep?: number): void;
  103882. /**
  103883. * Get the time step of the physics engine.
  103884. * @returns the current time step
  103885. */
  103886. getTimeStep(): number;
  103887. /**
  103888. * Release all resources
  103889. */
  103890. dispose(): void;
  103891. /**
  103892. * Gets the name of the current physics plugin
  103893. * @returns the name of the plugin
  103894. */
  103895. getPhysicsPluginName(): string;
  103896. /**
  103897. * Adding a new impostor for the impostor tracking.
  103898. * This will be done by the impostor itself.
  103899. * @param impostor the impostor to add
  103900. */
  103901. addImpostor(impostor: PhysicsImpostor): void;
  103902. /**
  103903. * Remove an impostor from the engine.
  103904. * This impostor and its mesh will not longer be updated by the physics engine.
  103905. * @param impostor the impostor to remove
  103906. */
  103907. removeImpostor(impostor: PhysicsImpostor): void;
  103908. /**
  103909. * Add a joint to the physics engine
  103910. * @param mainImpostor defines the main impostor to which the joint is added.
  103911. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103912. * @param joint defines the joint that will connect both impostors.
  103913. */
  103914. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103915. /**
  103916. * Removes a joint from the simulation
  103917. * @param mainImpostor defines the impostor used with the joint
  103918. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103919. * @param joint defines the joint to remove
  103920. */
  103921. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103922. /**
  103923. * Called by the scene. No need to call it.
  103924. * @param delta defines the timespam between frames
  103925. */
  103926. _step(delta: number): void;
  103927. /**
  103928. * Gets the current plugin used to run the simulation
  103929. * @returns current plugin
  103930. */
  103931. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103932. /**
  103933. * Gets the list of physic impostors
  103934. * @returns an array of PhysicsImpostor
  103935. */
  103936. getImpostors(): Array<PhysicsImpostor>;
  103937. /**
  103938. * Gets the impostor for a physics enabled object
  103939. * @param object defines the object impersonated by the impostor
  103940. * @returns the PhysicsImpostor or null if not found
  103941. */
  103942. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103943. /**
  103944. * Gets the impostor for a physics body object
  103945. * @param body defines physics body used by the impostor
  103946. * @returns the PhysicsImpostor or null if not found
  103947. */
  103948. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103949. }
  103950. }
  103951. declare module BABYLON {
  103952. /** @hidden */
  103953. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  103954. private _useDeltaForWorldStep;
  103955. world: any;
  103956. name: string;
  103957. private _physicsMaterials;
  103958. private _fixedTimeStep;
  103959. BJSCANNON: any;
  103960. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  103961. setGravity(gravity: Vector3): void;
  103962. setTimeStep(timeStep: number): void;
  103963. getTimeStep(): number;
  103964. executeStep(delta: number): void;
  103965. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103966. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103967. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103968. private _processChildMeshes;
  103969. removePhysicsBody(impostor: PhysicsImpostor): void;
  103970. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103971. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103972. private _addMaterial;
  103973. private _checkWithEpsilon;
  103974. private _createShape;
  103975. private _createHeightmap;
  103976. private _minus90X;
  103977. private _plus90X;
  103978. private _tmpPosition;
  103979. private _tmpDeltaPosition;
  103980. private _tmpUnityRotation;
  103981. private _updatePhysicsBodyTransformation;
  103982. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103983. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103984. isSupported(): boolean;
  103985. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103986. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103987. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103988. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103989. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103990. getBodyMass(impostor: PhysicsImpostor): number;
  103991. getBodyFriction(impostor: PhysicsImpostor): number;
  103992. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103993. getBodyRestitution(impostor: PhysicsImpostor): number;
  103994. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103995. sleepBody(impostor: PhysicsImpostor): void;
  103996. wakeUpBody(impostor: PhysicsImpostor): void;
  103997. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  103998. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  103999. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104000. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104001. getRadius(impostor: PhysicsImpostor): number;
  104002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104003. dispose(): void;
  104004. private _extendNamespace;
  104005. }
  104006. }
  104007. declare module BABYLON {
  104008. /** @hidden */
  104009. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104010. world: any;
  104011. name: string;
  104012. BJSOIMO: any;
  104013. constructor(iterations?: number, oimoInjection?: any);
  104014. setGravity(gravity: Vector3): void;
  104015. setTimeStep(timeStep: number): void;
  104016. getTimeStep(): number;
  104017. private _tmpImpostorsArray;
  104018. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104019. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104020. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104021. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104022. private _tmpPositionVector;
  104023. removePhysicsBody(impostor: PhysicsImpostor): void;
  104024. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104025. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104026. isSupported(): boolean;
  104027. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104028. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104029. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104030. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104031. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104032. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104033. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104034. getBodyMass(impostor: PhysicsImpostor): number;
  104035. getBodyFriction(impostor: PhysicsImpostor): number;
  104036. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104037. getBodyRestitution(impostor: PhysicsImpostor): number;
  104038. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104039. sleepBody(impostor: PhysicsImpostor): void;
  104040. wakeUpBody(impostor: PhysicsImpostor): void;
  104041. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104042. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104043. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104044. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104045. getRadius(impostor: PhysicsImpostor): number;
  104046. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104047. dispose(): void;
  104048. }
  104049. }
  104050. declare module BABYLON {
  104051. interface AbstractScene {
  104052. /**
  104053. * The list of reflection probes added to the scene
  104054. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104055. */
  104056. reflectionProbes: Array<ReflectionProbe>;
  104057. /**
  104058. * Removes the given reflection probe from this scene.
  104059. * @param toRemove The reflection probe to remove
  104060. * @returns The index of the removed reflection probe
  104061. */
  104062. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104063. /**
  104064. * Adds the given reflection probe to this scene.
  104065. * @param newReflectionProbe The reflection probe to add
  104066. */
  104067. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104068. }
  104069. /**
  104070. * Class used to generate realtime reflection / refraction cube textures
  104071. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104072. */
  104073. export class ReflectionProbe {
  104074. /** defines the name of the probe */
  104075. name: string;
  104076. private _scene;
  104077. private _renderTargetTexture;
  104078. private _projectionMatrix;
  104079. private _viewMatrix;
  104080. private _target;
  104081. private _add;
  104082. private _attachedMesh;
  104083. private _invertYAxis;
  104084. /** Gets or sets probe position (center of the cube map) */
  104085. position: Vector3;
  104086. /**
  104087. * Creates a new reflection probe
  104088. * @param name defines the name of the probe
  104089. * @param size defines the texture resolution (for each face)
  104090. * @param scene defines the hosting scene
  104091. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104092. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104093. */
  104094. constructor(
  104095. /** defines the name of the probe */
  104096. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104097. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104098. samples: number;
  104099. /** Gets or sets the refresh rate to use (on every frame by default) */
  104100. refreshRate: number;
  104101. /**
  104102. * Gets the hosting scene
  104103. * @returns a Scene
  104104. */
  104105. getScene(): Scene;
  104106. /** Gets the internal CubeTexture used to render to */
  104107. readonly cubeTexture: RenderTargetTexture;
  104108. /** Gets the list of meshes to render */
  104109. readonly renderList: Nullable<AbstractMesh[]>;
  104110. /**
  104111. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104112. * @param mesh defines the mesh to attach to
  104113. */
  104114. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104115. /**
  104116. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104117. * @param renderingGroupId The rendering group id corresponding to its index
  104118. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104119. */
  104120. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104121. /**
  104122. * Clean all associated resources
  104123. */
  104124. dispose(): void;
  104125. /**
  104126. * Converts the reflection probe information to a readable string for debug purpose.
  104127. * @param fullDetails Supports for multiple levels of logging within scene loading
  104128. * @returns the human readable reflection probe info
  104129. */
  104130. toString(fullDetails?: boolean): string;
  104131. /**
  104132. * Get the class name of the relfection probe.
  104133. * @returns "ReflectionProbe"
  104134. */
  104135. getClassName(): string;
  104136. /**
  104137. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104138. * @returns The JSON representation of the texture
  104139. */
  104140. serialize(): any;
  104141. /**
  104142. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104143. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104144. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104145. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104146. * @returns The parsed reflection probe if successful
  104147. */
  104148. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104149. }
  104150. }
  104151. declare module BABYLON {
  104152. /** @hidden */
  104153. export var _BabylonLoaderRegistered: boolean;
  104154. }
  104155. declare module BABYLON {
  104156. /**
  104157. * The Physically based simple base material of BJS.
  104158. *
  104159. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104160. * It is used as the base class for both the specGloss and metalRough conventions.
  104161. */
  104162. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104163. /**
  104164. * Number of Simultaneous lights allowed on the material.
  104165. */
  104166. maxSimultaneousLights: number;
  104167. /**
  104168. * If sets to true, disables all the lights affecting the material.
  104169. */
  104170. disableLighting: boolean;
  104171. /**
  104172. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104173. */
  104174. environmentTexture: BaseTexture;
  104175. /**
  104176. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104177. */
  104178. invertNormalMapX: boolean;
  104179. /**
  104180. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104181. */
  104182. invertNormalMapY: boolean;
  104183. /**
  104184. * Normal map used in the model.
  104185. */
  104186. normalTexture: BaseTexture;
  104187. /**
  104188. * Emissivie color used to self-illuminate the model.
  104189. */
  104190. emissiveColor: Color3;
  104191. /**
  104192. * Emissivie texture used to self-illuminate the model.
  104193. */
  104194. emissiveTexture: BaseTexture;
  104195. /**
  104196. * Occlusion Channel Strenght.
  104197. */
  104198. occlusionStrength: number;
  104199. /**
  104200. * Occlusion Texture of the material (adding extra occlusion effects).
  104201. */
  104202. occlusionTexture: BaseTexture;
  104203. /**
  104204. * Defines the alpha limits in alpha test mode.
  104205. */
  104206. alphaCutOff: number;
  104207. /**
  104208. * Gets the current double sided mode.
  104209. */
  104210. /**
  104211. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104212. */
  104213. doubleSided: boolean;
  104214. /**
  104215. * Stores the pre-calculated light information of a mesh in a texture.
  104216. */
  104217. lightmapTexture: BaseTexture;
  104218. /**
  104219. * If true, the light map contains occlusion information instead of lighting info.
  104220. */
  104221. useLightmapAsShadowmap: boolean;
  104222. /**
  104223. * Instantiates a new PBRMaterial instance.
  104224. *
  104225. * @param name The material name
  104226. * @param scene The scene the material will be use in.
  104227. */
  104228. constructor(name: string, scene: Scene);
  104229. getClassName(): string;
  104230. }
  104231. }
  104232. declare module BABYLON {
  104233. /**
  104234. * The PBR material of BJS following the metal roughness convention.
  104235. *
  104236. * This fits to the PBR convention in the GLTF definition:
  104237. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104238. */
  104239. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104240. /**
  104241. * The base color has two different interpretations depending on the value of metalness.
  104242. * When the material is a metal, the base color is the specific measured reflectance value
  104243. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104244. * of the material.
  104245. */
  104246. baseColor: Color3;
  104247. /**
  104248. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104249. * well as opacity information in the alpha channel.
  104250. */
  104251. baseTexture: BaseTexture;
  104252. /**
  104253. * Specifies the metallic scalar value of the material.
  104254. * Can also be used to scale the metalness values of the metallic texture.
  104255. */
  104256. metallic: number;
  104257. /**
  104258. * Specifies the roughness scalar value of the material.
  104259. * Can also be used to scale the roughness values of the metallic texture.
  104260. */
  104261. roughness: number;
  104262. /**
  104263. * Texture containing both the metallic value in the B channel and the
  104264. * roughness value in the G channel to keep better precision.
  104265. */
  104266. metallicRoughnessTexture: BaseTexture;
  104267. /**
  104268. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104269. *
  104270. * @param name The material name
  104271. * @param scene The scene the material will be use in.
  104272. */
  104273. constructor(name: string, scene: Scene);
  104274. /**
  104275. * Return the currrent class name of the material.
  104276. */
  104277. getClassName(): string;
  104278. /**
  104279. * Makes a duplicate of the current material.
  104280. * @param name - name to use for the new material.
  104281. */
  104282. clone(name: string): PBRMetallicRoughnessMaterial;
  104283. /**
  104284. * Serialize the material to a parsable JSON object.
  104285. */
  104286. serialize(): any;
  104287. /**
  104288. * Parses a JSON object correponding to the serialize function.
  104289. */
  104290. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104291. }
  104292. }
  104293. declare module BABYLON {
  104294. /**
  104295. * The PBR material of BJS following the specular glossiness convention.
  104296. *
  104297. * This fits to the PBR convention in the GLTF definition:
  104298. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104299. */
  104300. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104301. /**
  104302. * Specifies the diffuse color of the material.
  104303. */
  104304. diffuseColor: Color3;
  104305. /**
  104306. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104307. * channel.
  104308. */
  104309. diffuseTexture: BaseTexture;
  104310. /**
  104311. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104312. */
  104313. specularColor: Color3;
  104314. /**
  104315. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104316. */
  104317. glossiness: number;
  104318. /**
  104319. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104320. */
  104321. specularGlossinessTexture: BaseTexture;
  104322. /**
  104323. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104324. *
  104325. * @param name The material name
  104326. * @param scene The scene the material will be use in.
  104327. */
  104328. constructor(name: string, scene: Scene);
  104329. /**
  104330. * Return the currrent class name of the material.
  104331. */
  104332. getClassName(): string;
  104333. /**
  104334. * Makes a duplicate of the current material.
  104335. * @param name - name to use for the new material.
  104336. */
  104337. clone(name: string): PBRSpecularGlossinessMaterial;
  104338. /**
  104339. * Serialize the material to a parsable JSON object.
  104340. */
  104341. serialize(): any;
  104342. /**
  104343. * Parses a JSON object correponding to the serialize function.
  104344. */
  104345. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104346. }
  104347. }
  104348. declare module BABYLON {
  104349. /**
  104350. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104351. * It can help converting any input color in a desired output one. This can then be used to create effects
  104352. * from sepia, black and white to sixties or futuristic rendering...
  104353. *
  104354. * The only supported format is currently 3dl.
  104355. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104356. */
  104357. export class ColorGradingTexture extends BaseTexture {
  104358. /**
  104359. * The current texture matrix. (will always be identity in color grading texture)
  104360. */
  104361. private _textureMatrix;
  104362. /**
  104363. * The texture URL.
  104364. */
  104365. url: string;
  104366. /**
  104367. * Empty line regex stored for GC.
  104368. */
  104369. private static _noneEmptyLineRegex;
  104370. private _engine;
  104371. /**
  104372. * Instantiates a ColorGradingTexture from the following parameters.
  104373. *
  104374. * @param url The location of the color gradind data (currently only supporting 3dl)
  104375. * @param scene The scene the texture will be used in
  104376. */
  104377. constructor(url: string, scene: Scene);
  104378. /**
  104379. * Returns the texture matrix used in most of the material.
  104380. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  104381. */
  104382. getTextureMatrix(): Matrix;
  104383. /**
  104384. * Occurs when the file being loaded is a .3dl LUT file.
  104385. */
  104386. private load3dlTexture;
  104387. /**
  104388. * Starts the loading process of the texture.
  104389. */
  104390. private loadTexture;
  104391. /**
  104392. * Clones the color gradind texture.
  104393. */
  104394. clone(): ColorGradingTexture;
  104395. /**
  104396. * Called during delayed load for textures.
  104397. */
  104398. delayLoad(): void;
  104399. /**
  104400. * Parses a color grading texture serialized by Babylon.
  104401. * @param parsedTexture The texture information being parsedTexture
  104402. * @param scene The scene to load the texture in
  104403. * @param rootUrl The root url of the data assets to load
  104404. * @return A color gradind texture
  104405. */
  104406. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  104407. /**
  104408. * Serializes the LUT texture to json format.
  104409. */
  104410. serialize(): any;
  104411. }
  104412. }
  104413. declare module BABYLON {
  104414. /**
  104415. * Based on jsTGALoader - Javascript loader for TGA file
  104416. * By Vincent Thibault
  104417. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104418. */
  104419. export class TGATools {
  104420. private static _TYPE_INDEXED;
  104421. private static _TYPE_RGB;
  104422. private static _TYPE_GREY;
  104423. private static _TYPE_RLE_INDEXED;
  104424. private static _TYPE_RLE_RGB;
  104425. private static _TYPE_RLE_GREY;
  104426. private static _ORIGIN_MASK;
  104427. private static _ORIGIN_SHIFT;
  104428. private static _ORIGIN_BL;
  104429. private static _ORIGIN_BR;
  104430. private static _ORIGIN_UL;
  104431. private static _ORIGIN_UR;
  104432. /**
  104433. * Gets the header of a TGA file
  104434. * @param data defines the TGA data
  104435. * @returns the header
  104436. */
  104437. static GetTGAHeader(data: Uint8Array): any;
  104438. /**
  104439. * Uploads TGA content to a Babylon Texture
  104440. * @hidden
  104441. */
  104442. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104443. /** @hidden */
  104444. 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;
  104445. /** @hidden */
  104446. 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;
  104447. /** @hidden */
  104448. 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;
  104449. /** @hidden */
  104450. 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;
  104451. /** @hidden */
  104452. 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;
  104453. /** @hidden */
  104454. 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;
  104455. }
  104456. }
  104457. declare module BABYLON {
  104458. /**
  104459. * Implementation of the TGA Texture Loader.
  104460. * @hidden
  104461. */
  104462. export class _TGATextureLoader implements IInternalTextureLoader {
  104463. /**
  104464. * Defines wether the loader supports cascade loading the different faces.
  104465. */
  104466. readonly supportCascades: boolean;
  104467. /**
  104468. * This returns if the loader support the current file information.
  104469. * @param extension defines the file extension of the file being loaded
  104470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104471. * @param fallback defines the fallback internal texture if any
  104472. * @param isBase64 defines whether the texture is encoded as a base64
  104473. * @param isBuffer defines whether the texture data are stored as a buffer
  104474. * @returns true if the loader can load the specified file
  104475. */
  104476. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104477. /**
  104478. * Transform the url before loading if required.
  104479. * @param rootUrl the url of the texture
  104480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104481. * @returns the transformed texture
  104482. */
  104483. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104484. /**
  104485. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104486. * @param rootUrl the url of the texture
  104487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104488. * @returns the fallback texture
  104489. */
  104490. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104491. /**
  104492. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104493. * @param data contains the texture data
  104494. * @param texture defines the BabylonJS internal texture
  104495. * @param createPolynomials will be true if polynomials have been requested
  104496. * @param onLoad defines the callback to trigger once the texture is ready
  104497. * @param onError defines the callback to trigger in case of error
  104498. */
  104499. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104500. /**
  104501. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104502. * @param data contains the texture data
  104503. * @param texture defines the BabylonJS internal texture
  104504. * @param callback defines the method to call once ready to upload
  104505. */
  104506. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104507. }
  104508. }
  104509. declare module BABYLON {
  104510. /**
  104511. * 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.
  104512. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104513. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104514. */
  104515. export class CustomProceduralTexture extends ProceduralTexture {
  104516. private _animate;
  104517. private _time;
  104518. private _config;
  104519. private _texturePath;
  104520. /**
  104521. * Instantiates a new Custom Procedural Texture.
  104522. * 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.
  104523. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104524. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104525. * @param name Define the name of the texture
  104526. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104527. * @param size Define the size of the texture to create
  104528. * @param scene Define the scene the texture belongs to
  104529. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104530. * @param generateMipMaps Define if the texture should creates mip maps or not
  104531. */
  104532. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104533. private _loadJson;
  104534. /**
  104535. * Is the texture ready to be used ? (rendered at least once)
  104536. * @returns true if ready, otherwise, false.
  104537. */
  104538. isReady(): boolean;
  104539. /**
  104540. * Render the texture to its associated render target.
  104541. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104542. */
  104543. render(useCameraPostProcess?: boolean): void;
  104544. /**
  104545. * Update the list of dependant textures samplers in the shader.
  104546. */
  104547. updateTextures(): void;
  104548. /**
  104549. * Update the uniform values of the procedural texture in the shader.
  104550. */
  104551. updateShaderUniforms(): void;
  104552. /**
  104553. * Define if the texture animates or not.
  104554. */
  104555. animate: boolean;
  104556. }
  104557. }
  104558. declare module BABYLON {
  104559. /** @hidden */
  104560. export var noisePixelShader: {
  104561. name: string;
  104562. shader: string;
  104563. };
  104564. }
  104565. declare module BABYLON {
  104566. /**
  104567. * Class used to generate noise procedural textures
  104568. */
  104569. export class NoiseProceduralTexture extends ProceduralTexture {
  104570. private _time;
  104571. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104572. brightness: number;
  104573. /** Defines the number of octaves to process */
  104574. octaves: number;
  104575. /** Defines the level of persistence (0.8 by default) */
  104576. persistence: number;
  104577. /** Gets or sets animation speed factor (default is 1) */
  104578. animationSpeedFactor: number;
  104579. /**
  104580. * Creates a new NoiseProceduralTexture
  104581. * @param name defines the name fo the texture
  104582. * @param size defines the size of the texture (default is 256)
  104583. * @param scene defines the hosting scene
  104584. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104585. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104586. */
  104587. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104588. private _updateShaderUniforms;
  104589. protected _getDefines(): string;
  104590. /** Generate the current state of the procedural texture */
  104591. render(useCameraPostProcess?: boolean): void;
  104592. /**
  104593. * Serializes this noise procedural texture
  104594. * @returns a serialized noise procedural texture object
  104595. */
  104596. serialize(): any;
  104597. /**
  104598. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  104599. * @param parsedTexture defines parsed texture data
  104600. * @param scene defines the current scene
  104601. * @param rootUrl defines the root URL containing noise procedural texture information
  104602. * @returns a parsed NoiseProceduralTexture
  104603. */
  104604. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  104605. }
  104606. }
  104607. declare module BABYLON {
  104608. /**
  104609. * Raw cube texture where the raw buffers are passed in
  104610. */
  104611. export class RawCubeTexture extends CubeTexture {
  104612. /**
  104613. * Creates a cube texture where the raw buffers are passed in.
  104614. * @param scene defines the scene the texture is attached to
  104615. * @param data defines the array of data to use to create each face
  104616. * @param size defines the size of the textures
  104617. * @param format defines the format of the data
  104618. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104619. * @param generateMipMaps defines if the engine should generate the mip levels
  104620. * @param invertY defines if data must be stored with Y axis inverted
  104621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104622. * @param compression defines the compression used (null by default)
  104623. */
  104624. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  104625. /**
  104626. * Updates the raw cube texture.
  104627. * @param data defines the data to store
  104628. * @param format defines the data format
  104629. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104630. * @param invertY defines if data must be stored with Y axis inverted
  104631. * @param compression defines the compression used (null by default)
  104632. * @param level defines which level of the texture to update
  104633. */
  104634. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  104635. /**
  104636. * Updates a raw cube texture with RGBD encoded data.
  104637. * @param data defines the array of data [mipmap][face] to use to create each face
  104638. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  104639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  104641. * @returns a promsie that resolves when the operation is complete
  104642. */
  104643. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  104644. /**
  104645. * Clones the raw cube texture.
  104646. * @return a new cube texture
  104647. */
  104648. clone(): CubeTexture;
  104649. /** @hidden */
  104650. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104651. }
  104652. }
  104653. declare module BABYLON {
  104654. /**
  104655. * Class used to store 3D textures containing user data
  104656. */
  104657. export class RawTexture3D extends Texture {
  104658. /** Gets or sets the texture format to use */
  104659. format: number;
  104660. private _engine;
  104661. /**
  104662. * Create a new RawTexture3D
  104663. * @param data defines the data of the texture
  104664. * @param width defines the width of the texture
  104665. * @param height defines the height of the texture
  104666. * @param depth defines the depth of the texture
  104667. * @param format defines the texture format to use
  104668. * @param scene defines the hosting scene
  104669. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  104670. * @param invertY defines if texture must be stored with Y axis inverted
  104671. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  104672. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  104673. */
  104674. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  104675. /** Gets or sets the texture format to use */
  104676. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  104677. /**
  104678. * Update the texture with new data
  104679. * @param data defines the data to store in the texture
  104680. */
  104681. update(data: ArrayBufferView): void;
  104682. }
  104683. }
  104684. declare module BABYLON {
  104685. /**
  104686. * Creates a refraction texture used by refraction channel of the standard material.
  104687. * It is like a mirror but to see through a material.
  104688. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104689. */
  104690. export class RefractionTexture extends RenderTargetTexture {
  104691. /**
  104692. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  104693. * 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.
  104694. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104695. */
  104696. refractionPlane: Plane;
  104697. /**
  104698. * Define how deep under the surface we should see.
  104699. */
  104700. depth: number;
  104701. /**
  104702. * Creates a refraction texture used by refraction channel of the standard material.
  104703. * It is like a mirror but to see through a material.
  104704. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104705. * @param name Define the texture name
  104706. * @param size Define the size of the underlying texture
  104707. * @param scene Define the scene the refraction belongs to
  104708. * @param generateMipMaps Define if we need to generate mips level for the refraction
  104709. */
  104710. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  104711. /**
  104712. * Clone the refraction texture.
  104713. * @returns the cloned texture
  104714. */
  104715. clone(): RefractionTexture;
  104716. /**
  104717. * Serialize the texture to a JSON representation you could use in Parse later on
  104718. * @returns the serialized JSON representation
  104719. */
  104720. serialize(): any;
  104721. }
  104722. }
  104723. declare module BABYLON {
  104724. /**
  104725. * Configuration for Draco compression
  104726. */
  104727. export interface IDracoCompressionConfiguration {
  104728. /**
  104729. * Configuration for the decoder.
  104730. */
  104731. decoder?: {
  104732. /**
  104733. * The url to the WebAssembly module.
  104734. */
  104735. wasmUrl?: string;
  104736. /**
  104737. * The url to the WebAssembly binary.
  104738. */
  104739. wasmBinaryUrl?: string;
  104740. /**
  104741. * The url to the fallback JavaScript module.
  104742. */
  104743. fallbackUrl?: string;
  104744. };
  104745. }
  104746. /**
  104747. * Draco compression (https://google.github.io/draco/)
  104748. *
  104749. * This class wraps the Draco module.
  104750. *
  104751. * **Encoder**
  104752. *
  104753. * The encoder is not currently implemented.
  104754. *
  104755. * **Decoder**
  104756. *
  104757. * 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.
  104758. *
  104759. * To update the configuration, use the following code:
  104760. * ```javascript
  104761. * DracoCompression.Configuration = {
  104762. * decoder: {
  104763. * wasmUrl: "<url to the WebAssembly library>",
  104764. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  104765. * fallbackUrl: "<url to the fallback JavaScript library>",
  104766. * }
  104767. * };
  104768. * ```
  104769. *
  104770. * 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.
  104771. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  104772. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  104773. *
  104774. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  104775. * ```javascript
  104776. * var dracoCompression = new DracoCompression();
  104777. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  104778. * [VertexBuffer.PositionKind]: 0
  104779. * });
  104780. * ```
  104781. *
  104782. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  104783. */
  104784. export class DracoCompression implements IDisposable {
  104785. private static _DecoderModulePromise;
  104786. /**
  104787. * The configuration. Defaults to the following urls:
  104788. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  104789. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  104790. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  104791. */
  104792. static Configuration: IDracoCompressionConfiguration;
  104793. /**
  104794. * Returns true if the decoder is available.
  104795. */
  104796. static readonly DecoderAvailable: boolean;
  104797. /**
  104798. * Constructor
  104799. */
  104800. constructor();
  104801. /**
  104802. * Stop all async operations and release resources.
  104803. */
  104804. dispose(): void;
  104805. /**
  104806. * Decode Draco compressed mesh data to vertex data.
  104807. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  104808. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  104809. * @returns A promise that resolves with the decoded vertex data
  104810. */
  104811. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  104812. [kind: string]: number;
  104813. }): Promise<VertexData>;
  104814. private static _GetDecoderModule;
  104815. private static _LoadScriptAsync;
  104816. private static _LoadFileAsync;
  104817. }
  104818. }
  104819. declare module BABYLON {
  104820. /**
  104821. * Class for building Constructive Solid Geometry
  104822. */
  104823. export class CSG {
  104824. private polygons;
  104825. /**
  104826. * The world matrix
  104827. */
  104828. matrix: Matrix;
  104829. /**
  104830. * Stores the position
  104831. */
  104832. position: Vector3;
  104833. /**
  104834. * Stores the rotation
  104835. */
  104836. rotation: Vector3;
  104837. /**
  104838. * Stores the rotation quaternion
  104839. */
  104840. rotationQuaternion: Nullable<Quaternion>;
  104841. /**
  104842. * Stores the scaling vector
  104843. */
  104844. scaling: Vector3;
  104845. /**
  104846. * Convert the Mesh to CSG
  104847. * @param mesh The Mesh to convert to CSG
  104848. * @returns A new CSG from the Mesh
  104849. */
  104850. static FromMesh(mesh: Mesh): CSG;
  104851. /**
  104852. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  104853. * @param polygons Polygons used to construct a CSG solid
  104854. */
  104855. private static FromPolygons;
  104856. /**
  104857. * Clones, or makes a deep copy, of the CSG
  104858. * @returns A new CSG
  104859. */
  104860. clone(): CSG;
  104861. /**
  104862. * Unions this CSG with another CSG
  104863. * @param csg The CSG to union against this CSG
  104864. * @returns The unioned CSG
  104865. */
  104866. union(csg: CSG): CSG;
  104867. /**
  104868. * Unions this CSG with another CSG in place
  104869. * @param csg The CSG to union against this CSG
  104870. */
  104871. unionInPlace(csg: CSG): void;
  104872. /**
  104873. * Subtracts this CSG with another CSG
  104874. * @param csg The CSG to subtract against this CSG
  104875. * @returns A new CSG
  104876. */
  104877. subtract(csg: CSG): CSG;
  104878. /**
  104879. * Subtracts this CSG with another CSG in place
  104880. * @param csg The CSG to subtact against this CSG
  104881. */
  104882. subtractInPlace(csg: CSG): void;
  104883. /**
  104884. * Intersect this CSG with another CSG
  104885. * @param csg The CSG to intersect against this CSG
  104886. * @returns A new CSG
  104887. */
  104888. intersect(csg: CSG): CSG;
  104889. /**
  104890. * Intersects this CSG with another CSG in place
  104891. * @param csg The CSG to intersect against this CSG
  104892. */
  104893. intersectInPlace(csg: CSG): void;
  104894. /**
  104895. * Return a new CSG solid with solid and empty space switched. This solid is
  104896. * not modified.
  104897. * @returns A new CSG solid with solid and empty space switched
  104898. */
  104899. inverse(): CSG;
  104900. /**
  104901. * Inverses the CSG in place
  104902. */
  104903. inverseInPlace(): void;
  104904. /**
  104905. * This is used to keep meshes transformations so they can be restored
  104906. * when we build back a Babylon Mesh
  104907. * NB : All CSG operations are performed in world coordinates
  104908. * @param csg The CSG to copy the transform attributes from
  104909. * @returns This CSG
  104910. */
  104911. copyTransformAttributes(csg: CSG): CSG;
  104912. /**
  104913. * Build Raw mesh from CSG
  104914. * Coordinates here are in world space
  104915. * @param name The name of the mesh geometry
  104916. * @param scene The Scene
  104917. * @param keepSubMeshes Specifies if the submeshes should be kept
  104918. * @returns A new Mesh
  104919. */
  104920. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104921. /**
  104922. * Build Mesh from CSG taking material and transforms into account
  104923. * @param name The name of the Mesh
  104924. * @param material The material of the Mesh
  104925. * @param scene The Scene
  104926. * @param keepSubMeshes Specifies if submeshes should be kept
  104927. * @returns The new Mesh
  104928. */
  104929. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104930. }
  104931. }
  104932. declare module BABYLON {
  104933. /**
  104934. * Class used to create a trail following a mesh
  104935. */
  104936. export class TrailMesh extends Mesh {
  104937. private _generator;
  104938. private _autoStart;
  104939. private _running;
  104940. private _diameter;
  104941. private _length;
  104942. private _sectionPolygonPointsCount;
  104943. private _sectionVectors;
  104944. private _sectionNormalVectors;
  104945. private _beforeRenderObserver;
  104946. /**
  104947. * @constructor
  104948. * @param name The value used by scene.getMeshByName() to do a lookup.
  104949. * @param generator The mesh to generate a trail.
  104950. * @param scene The scene to add this mesh to.
  104951. * @param diameter Diameter of trailing mesh. Default is 1.
  104952. * @param length Length of trailing mesh. Default is 60.
  104953. * @param autoStart Automatically start trailing mesh. Default true.
  104954. */
  104955. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104956. /**
  104957. * "TrailMesh"
  104958. * @returns "TrailMesh"
  104959. */
  104960. getClassName(): string;
  104961. private _createMesh;
  104962. /**
  104963. * Start trailing mesh.
  104964. */
  104965. start(): void;
  104966. /**
  104967. * Stop trailing mesh.
  104968. */
  104969. stop(): void;
  104970. /**
  104971. * Update trailing mesh geometry.
  104972. */
  104973. update(): void;
  104974. /**
  104975. * Returns a new TrailMesh object.
  104976. * @param name is a string, the name given to the new mesh
  104977. * @param newGenerator use new generator object for cloned trail mesh
  104978. * @returns a new mesh
  104979. */
  104980. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104981. /**
  104982. * Serializes this trail mesh
  104983. * @param serializationObject object to write serialization to
  104984. */
  104985. serialize(serializationObject: any): void;
  104986. /**
  104987. * Parses a serialized trail mesh
  104988. * @param parsedMesh the serialized mesh
  104989. * @param scene the scene to create the trail mesh in
  104990. * @returns the created trail mesh
  104991. */
  104992. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104993. }
  104994. }
  104995. declare module BABYLON {
  104996. /**
  104997. * Class containing static functions to help procedurally build meshes
  104998. */
  104999. export class RibbonBuilder {
  105000. /**
  105001. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105002. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105003. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105004. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105005. * * 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
  105006. * * 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
  105007. * * 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
  105008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105009. * * If you create a double-sided mesh, you can choose what parts of 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
  105010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105011. * * 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
  105012. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105013. * * 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
  105014. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105016. * @param name defines the name of the mesh
  105017. * @param options defines the options used to create the mesh
  105018. * @param scene defines the hosting scene
  105019. * @returns the ribbon mesh
  105020. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105022. */
  105023. static CreateRibbon(name: string, options: {
  105024. pathArray: Vector3[][];
  105025. closeArray?: boolean;
  105026. closePath?: boolean;
  105027. offset?: number;
  105028. updatable?: boolean;
  105029. sideOrientation?: number;
  105030. frontUVs?: Vector4;
  105031. backUVs?: Vector4;
  105032. instance?: Mesh;
  105033. invertUV?: boolean;
  105034. uvs?: Vector2[];
  105035. colors?: Color4[];
  105036. }, scene?: Nullable<Scene>): Mesh;
  105037. }
  105038. }
  105039. declare module BABYLON {
  105040. /**
  105041. * Class containing static functions to help procedurally build meshes
  105042. */
  105043. export class TorusKnotBuilder {
  105044. /**
  105045. * Creates a torus knot mesh
  105046. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105047. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105048. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105049. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105051. * * If you create a double-sided mesh, you can choose what parts of 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
  105052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105053. * @param name defines the name of the mesh
  105054. * @param options defines the options used to create the mesh
  105055. * @param scene defines the hosting scene
  105056. * @returns the torus knot mesh
  105057. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105058. */
  105059. static CreateTorusKnot(name: string, options: {
  105060. radius?: number;
  105061. tube?: number;
  105062. radialSegments?: number;
  105063. tubularSegments?: number;
  105064. p?: number;
  105065. q?: number;
  105066. updatable?: boolean;
  105067. sideOrientation?: number;
  105068. frontUVs?: Vector4;
  105069. backUVs?: Vector4;
  105070. }, scene: any): Mesh;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /**
  105075. * Polygon
  105076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105077. */
  105078. export class Polygon {
  105079. /**
  105080. * Creates a rectangle
  105081. * @param xmin bottom X coord
  105082. * @param ymin bottom Y coord
  105083. * @param xmax top X coord
  105084. * @param ymax top Y coord
  105085. * @returns points that make the resulting rectation
  105086. */
  105087. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105088. /**
  105089. * Creates a circle
  105090. * @param radius radius of circle
  105091. * @param cx scale in x
  105092. * @param cy scale in y
  105093. * @param numberOfSides number of sides that make up the circle
  105094. * @returns points that make the resulting circle
  105095. */
  105096. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105097. /**
  105098. * Creates a polygon from input string
  105099. * @param input Input polygon data
  105100. * @returns the parsed points
  105101. */
  105102. static Parse(input: string): Vector2[];
  105103. /**
  105104. * Starts building a polygon from x and y coordinates
  105105. * @param x x coordinate
  105106. * @param y y coordinate
  105107. * @returns the started path2
  105108. */
  105109. static StartingAt(x: number, y: number): Path2;
  105110. }
  105111. /**
  105112. * Builds a polygon
  105113. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105114. */
  105115. export class PolygonMeshBuilder {
  105116. private _points;
  105117. private _outlinepoints;
  105118. private _holes;
  105119. private _name;
  105120. private _scene;
  105121. private _epoints;
  105122. private _eholes;
  105123. private _addToepoint;
  105124. /**
  105125. * Babylon reference to the earcut plugin.
  105126. */
  105127. bjsEarcut: any;
  105128. /**
  105129. * Creates a PolygonMeshBuilder
  105130. * @param name name of the builder
  105131. * @param contours Path of the polygon
  105132. * @param scene scene to add to
  105133. * @param earcutInjection can be used to inject your own earcut reference
  105134. */
  105135. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105136. /**
  105137. * Adds a whole within the polygon
  105138. * @param hole Array of points defining the hole
  105139. * @returns this
  105140. */
  105141. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105142. /**
  105143. * Creates the polygon
  105144. * @param updatable If the mesh should be updatable
  105145. * @param depth The depth of the mesh created
  105146. * @returns the created mesh
  105147. */
  105148. build(updatable?: boolean, depth?: number): Mesh;
  105149. /**
  105150. * Adds a side to the polygon
  105151. * @param positions points that make the polygon
  105152. * @param normals normals of the polygon
  105153. * @param uvs uvs of the polygon
  105154. * @param indices indices of the polygon
  105155. * @param bounds bounds of the polygon
  105156. * @param points points of the polygon
  105157. * @param depth depth of the polygon
  105158. * @param flip flip of the polygon
  105159. */
  105160. private addSide;
  105161. }
  105162. }
  105163. declare module BABYLON {
  105164. /**
  105165. * Class containing static functions to help procedurally build meshes
  105166. */
  105167. export class PolygonBuilder {
  105168. /**
  105169. * Creates a polygon mesh
  105170. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105171. * * 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
  105172. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105175. * * Remember you can only change the shape positions, not their number when updating a polygon
  105176. * @param name defines the name of the mesh
  105177. * @param options defines the options used to create the mesh
  105178. * @param scene defines the hosting scene
  105179. * @param earcutInjection can be used to inject your own earcut reference
  105180. * @returns the polygon mesh
  105181. */
  105182. static CreatePolygon(name: string, options: {
  105183. shape: Vector3[];
  105184. holes?: Vector3[][];
  105185. depth?: number;
  105186. faceUV?: Vector4[];
  105187. faceColors?: Color4[];
  105188. updatable?: boolean;
  105189. sideOrientation?: number;
  105190. frontUVs?: Vector4;
  105191. backUVs?: Vector4;
  105192. }, scene: Scene, earcutInjection?: any): Mesh;
  105193. /**
  105194. * Creates an extruded polygon mesh, with depth in the Y direction.
  105195. * * 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)
  105196. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105197. * @param name defines the name of the mesh
  105198. * @param options defines the options used to create the mesh
  105199. * @param scene defines the hosting scene
  105200. * @param earcutInjection can be used to inject your own earcut reference
  105201. * @returns the polygon mesh
  105202. */
  105203. static ExtrudePolygon(name: string, options: {
  105204. shape: Vector3[];
  105205. holes?: Vector3[][];
  105206. depth?: number;
  105207. faceUV?: Vector4[];
  105208. faceColors?: Color4[];
  105209. updatable?: boolean;
  105210. sideOrientation?: number;
  105211. frontUVs?: Vector4;
  105212. backUVs?: Vector4;
  105213. }, scene: Scene, earcutInjection?: any): Mesh;
  105214. }
  105215. }
  105216. declare module BABYLON {
  105217. /**
  105218. * Class containing static functions to help procedurally build meshes
  105219. */
  105220. export class ShapeBuilder {
  105221. /**
  105222. * 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.
  105223. * * 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.
  105224. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105225. * * 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.
  105226. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105227. * * 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
  105228. * * 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
  105229. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105231. * * If you create a double-sided mesh, you can choose what parts of 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
  105232. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105234. * @param name defines the name of the mesh
  105235. * @param options defines the options used to create the mesh
  105236. * @param scene defines the hosting scene
  105237. * @returns the extruded shape mesh
  105238. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105240. */
  105241. static ExtrudeShape(name: string, options: {
  105242. shape: Vector3[];
  105243. path: Vector3[];
  105244. scale?: number;
  105245. rotation?: number;
  105246. cap?: number;
  105247. updatable?: boolean;
  105248. sideOrientation?: number;
  105249. frontUVs?: Vector4;
  105250. backUVs?: Vector4;
  105251. instance?: Mesh;
  105252. invertUV?: boolean;
  105253. }, scene?: Nullable<Scene>): Mesh;
  105254. /**
  105255. * Creates an custom extruded shape mesh.
  105256. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105257. * * 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.
  105258. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105259. * * 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
  105260. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105261. * * 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
  105262. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105263. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105264. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105265. * * 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
  105266. * * 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
  105267. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105269. * * If you create a double-sided mesh, you can choose what parts of 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
  105270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105272. * @param name defines the name of the mesh
  105273. * @param options defines the options used to create the mesh
  105274. * @param scene defines the hosting scene
  105275. * @returns the custom extruded shape mesh
  105276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105279. */
  105280. static ExtrudeShapeCustom(name: string, options: {
  105281. shape: Vector3[];
  105282. path: Vector3[];
  105283. scaleFunction?: any;
  105284. rotationFunction?: any;
  105285. ribbonCloseArray?: boolean;
  105286. ribbonClosePath?: boolean;
  105287. cap?: number;
  105288. updatable?: boolean;
  105289. sideOrientation?: number;
  105290. frontUVs?: Vector4;
  105291. backUVs?: Vector4;
  105292. instance?: Mesh;
  105293. invertUV?: boolean;
  105294. }, scene: Scene): Mesh;
  105295. private static _ExtrudeShapeGeneric;
  105296. }
  105297. }
  105298. declare module BABYLON {
  105299. /**
  105300. * Class containing static functions to help procedurally build meshes
  105301. */
  105302. export class LatheBuilder {
  105303. /**
  105304. * Creates lathe mesh.
  105305. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105306. * * 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
  105307. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105308. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105309. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105310. * * 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
  105311. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105312. * * 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
  105313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105314. * * If you create a double-sided mesh, you can choose what parts of 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
  105315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105317. * @param name defines the name of the mesh
  105318. * @param options defines the options used to create the mesh
  105319. * @param scene defines the hosting scene
  105320. * @returns the lathe mesh
  105321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105322. */
  105323. static CreateLathe(name: string, options: {
  105324. shape: Vector3[];
  105325. radius?: number;
  105326. tessellation?: number;
  105327. clip?: number;
  105328. arc?: number;
  105329. closed?: boolean;
  105330. updatable?: boolean;
  105331. sideOrientation?: number;
  105332. frontUVs?: Vector4;
  105333. backUVs?: Vector4;
  105334. cap?: number;
  105335. invertUV?: boolean;
  105336. }, scene: Scene): Mesh;
  105337. }
  105338. }
  105339. declare module BABYLON {
  105340. /**
  105341. * Class containing static functions to help procedurally build meshes
  105342. */
  105343. export class TubeBuilder {
  105344. /**
  105345. * Creates a tube mesh.
  105346. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105347. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105348. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105349. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105350. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105351. * * 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)
  105352. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105353. * * 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
  105354. * * 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
  105355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105356. * * If you create a double-sided mesh, you can choose what parts of 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
  105357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105359. * @param name defines the name of the mesh
  105360. * @param options defines the options used to create the mesh
  105361. * @param scene defines the hosting scene
  105362. * @returns the tube mesh
  105363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105364. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105365. */
  105366. static CreateTube(name: string, options: {
  105367. path: Vector3[];
  105368. radius?: number;
  105369. tessellation?: number;
  105370. radiusFunction?: {
  105371. (i: number, distance: number): number;
  105372. };
  105373. cap?: number;
  105374. arc?: number;
  105375. updatable?: boolean;
  105376. sideOrientation?: number;
  105377. frontUVs?: Vector4;
  105378. backUVs?: Vector4;
  105379. instance?: Mesh;
  105380. invertUV?: boolean;
  105381. }, scene: Scene): Mesh;
  105382. }
  105383. }
  105384. declare module BABYLON {
  105385. /**
  105386. * Class containing static functions to help procedurally build meshes
  105387. */
  105388. export class IcoSphereBuilder {
  105389. /**
  105390. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105391. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105392. * * 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`)
  105393. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105394. * * 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
  105395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105396. * * If you create a double-sided mesh, you can choose what parts of 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
  105397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105398. * @param name defines the name of the mesh
  105399. * @param options defines the options used to create the mesh
  105400. * @param scene defines the hosting scene
  105401. * @returns the icosahedron mesh
  105402. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105403. */
  105404. static CreateIcoSphere(name: string, options: {
  105405. radius?: number;
  105406. radiusX?: number;
  105407. radiusY?: number;
  105408. radiusZ?: number;
  105409. flat?: boolean;
  105410. subdivisions?: number;
  105411. sideOrientation?: number;
  105412. frontUVs?: Vector4;
  105413. backUVs?: Vector4;
  105414. updatable?: boolean;
  105415. }, scene: Scene): Mesh;
  105416. }
  105417. }
  105418. declare module BABYLON {
  105419. /**
  105420. * Class containing static functions to help procedurally build meshes
  105421. */
  105422. export class DecalBuilder {
  105423. /**
  105424. * Creates a decal mesh.
  105425. * 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
  105426. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105427. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105428. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105429. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105430. * @param name defines the name of the mesh
  105431. * @param sourceMesh defines the mesh where the decal must be applied
  105432. * @param options defines the options used to create the mesh
  105433. * @param scene defines the hosting scene
  105434. * @returns the decal mesh
  105435. * @see https://doc.babylonjs.com/how_to/decals
  105436. */
  105437. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105438. position?: Vector3;
  105439. normal?: Vector3;
  105440. size?: Vector3;
  105441. angle?: number;
  105442. }): Mesh;
  105443. }
  105444. }
  105445. declare module BABYLON {
  105446. /**
  105447. * Class containing static functions to help procedurally build meshes
  105448. */
  105449. export class MeshBuilder {
  105450. /**
  105451. * Creates a box mesh
  105452. * * The parameter `size` sets the size (float) of each box side (default 1)
  105453. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105454. * * 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)
  105455. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105457. * * If you create a double-sided mesh, you can choose what parts of 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
  105458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105459. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105460. * @param name defines the name of the mesh
  105461. * @param options defines the options used to create the mesh
  105462. * @param scene defines the hosting scene
  105463. * @returns the box mesh
  105464. */
  105465. static CreateBox(name: string, options: {
  105466. size?: number;
  105467. width?: number;
  105468. height?: number;
  105469. depth?: number;
  105470. faceUV?: Vector4[];
  105471. faceColors?: Color4[];
  105472. sideOrientation?: number;
  105473. frontUVs?: Vector4;
  105474. backUVs?: Vector4;
  105475. updatable?: boolean;
  105476. }, scene?: Nullable<Scene>): Mesh;
  105477. /**
  105478. * Creates a sphere mesh
  105479. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105480. * * 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`)
  105481. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105482. * * 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
  105483. * * 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)
  105484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105485. * * If you create a double-sided mesh, you can choose what parts of 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
  105486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105487. * @param name defines the name of the mesh
  105488. * @param options defines the options used to create the mesh
  105489. * @param scene defines the hosting scene
  105490. * @returns the sphere mesh
  105491. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105492. */
  105493. static CreateSphere(name: string, options: {
  105494. segments?: number;
  105495. diameter?: number;
  105496. diameterX?: number;
  105497. diameterY?: number;
  105498. diameterZ?: number;
  105499. arc?: number;
  105500. slice?: number;
  105501. sideOrientation?: number;
  105502. frontUVs?: Vector4;
  105503. backUVs?: Vector4;
  105504. updatable?: boolean;
  105505. }, scene: any): Mesh;
  105506. /**
  105507. * Creates a plane polygonal mesh. By default, this is a disc
  105508. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105509. * * 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
  105510. * * 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
  105511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105512. * * If you create a double-sided mesh, you can choose what parts of 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
  105513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105514. * @param name defines the name of the mesh
  105515. * @param options defines the options used to create the mesh
  105516. * @param scene defines the hosting scene
  105517. * @returns the plane polygonal mesh
  105518. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105519. */
  105520. static CreateDisc(name: string, options: {
  105521. radius?: number;
  105522. tessellation?: number;
  105523. arc?: number;
  105524. updatable?: boolean;
  105525. sideOrientation?: number;
  105526. frontUVs?: Vector4;
  105527. backUVs?: Vector4;
  105528. }, scene?: Nullable<Scene>): Mesh;
  105529. /**
  105530. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105531. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105532. * * 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`)
  105533. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105534. * * 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
  105535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105536. * * If you create a double-sided mesh, you can choose what parts of 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
  105537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105538. * @param name defines the name of the mesh
  105539. * @param options defines the options used to create the mesh
  105540. * @param scene defines the hosting scene
  105541. * @returns the icosahedron mesh
  105542. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105543. */
  105544. static CreateIcoSphere(name: string, options: {
  105545. radius?: number;
  105546. radiusX?: number;
  105547. radiusY?: number;
  105548. radiusZ?: number;
  105549. flat?: boolean;
  105550. subdivisions?: number;
  105551. sideOrientation?: number;
  105552. frontUVs?: Vector4;
  105553. backUVs?: Vector4;
  105554. updatable?: boolean;
  105555. }, scene: Scene): Mesh;
  105556. /**
  105557. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105558. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105559. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105560. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105561. * * 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
  105562. * * 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
  105563. * * 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
  105564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105565. * * If you create a double-sided mesh, you can choose what parts of 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
  105566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105567. * * 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
  105568. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105569. * * 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
  105570. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105572. * @param name defines the name of the mesh
  105573. * @param options defines the options used to create the mesh
  105574. * @param scene defines the hosting scene
  105575. * @returns the ribbon mesh
  105576. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105577. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105578. */
  105579. static CreateRibbon(name: string, options: {
  105580. pathArray: Vector3[][];
  105581. closeArray?: boolean;
  105582. closePath?: boolean;
  105583. offset?: number;
  105584. updatable?: boolean;
  105585. sideOrientation?: number;
  105586. frontUVs?: Vector4;
  105587. backUVs?: Vector4;
  105588. instance?: Mesh;
  105589. invertUV?: boolean;
  105590. uvs?: Vector2[];
  105591. colors?: Color4[];
  105592. }, scene?: Nullable<Scene>): Mesh;
  105593. /**
  105594. * Creates a cylinder or a cone mesh
  105595. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105596. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105597. * * 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.
  105598. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105599. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105600. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105601. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105602. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105603. * * 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).
  105604. * * 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
  105605. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105606. * * 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
  105607. * * 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.
  105608. * * If `enclose` is false, a ring surface is one element.
  105609. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105610. * * 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
  105611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105612. * * If you create a double-sided mesh, you can choose what parts of 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
  105613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105614. * @param name defines the name of the mesh
  105615. * @param options defines the options used to create the mesh
  105616. * @param scene defines the hosting scene
  105617. * @returns the cylinder mesh
  105618. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105619. */
  105620. static CreateCylinder(name: string, options: {
  105621. height?: number;
  105622. diameterTop?: number;
  105623. diameterBottom?: number;
  105624. diameter?: number;
  105625. tessellation?: number;
  105626. subdivisions?: number;
  105627. arc?: number;
  105628. faceColors?: Color4[];
  105629. faceUV?: Vector4[];
  105630. updatable?: boolean;
  105631. hasRings?: boolean;
  105632. enclose?: boolean;
  105633. sideOrientation?: number;
  105634. frontUVs?: Vector4;
  105635. backUVs?: Vector4;
  105636. }, scene: any): Mesh;
  105637. /**
  105638. * Creates a torus mesh
  105639. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105640. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105641. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105643. * * If you create a double-sided mesh, you can choose what parts of 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
  105644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105645. * @param name defines the name of the mesh
  105646. * @param options defines the options used to create the mesh
  105647. * @param scene defines the hosting scene
  105648. * @returns the torus mesh
  105649. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105650. */
  105651. static CreateTorus(name: string, options: {
  105652. diameter?: number;
  105653. thickness?: number;
  105654. tessellation?: number;
  105655. updatable?: boolean;
  105656. sideOrientation?: number;
  105657. frontUVs?: Vector4;
  105658. backUVs?: Vector4;
  105659. }, scene: any): Mesh;
  105660. /**
  105661. * Creates a torus knot mesh
  105662. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105663. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105664. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105665. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105667. * * If you create a double-sided mesh, you can choose what parts of 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
  105668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105669. * @param name defines the name of the mesh
  105670. * @param options defines the options used to create the mesh
  105671. * @param scene defines the hosting scene
  105672. * @returns the torus knot mesh
  105673. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105674. */
  105675. static CreateTorusKnot(name: string, options: {
  105676. radius?: number;
  105677. tube?: number;
  105678. radialSegments?: number;
  105679. tubularSegments?: number;
  105680. p?: number;
  105681. q?: number;
  105682. updatable?: boolean;
  105683. sideOrientation?: number;
  105684. frontUVs?: Vector4;
  105685. backUVs?: Vector4;
  105686. }, scene: any): Mesh;
  105687. /**
  105688. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105689. * * 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
  105690. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105691. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105692. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105693. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105694. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105695. * * 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
  105696. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105699. * @param name defines the name of the new line system
  105700. * @param options defines the options used to create the line system
  105701. * @param scene defines the hosting scene
  105702. * @returns a new line system mesh
  105703. */
  105704. static CreateLineSystem(name: string, options: {
  105705. lines: Vector3[][];
  105706. updatable?: boolean;
  105707. instance?: Nullable<LinesMesh>;
  105708. colors?: Nullable<Color4[][]>;
  105709. useVertexAlpha?: boolean;
  105710. }, scene: Nullable<Scene>): LinesMesh;
  105711. /**
  105712. * Creates a line mesh
  105713. * 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
  105714. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105715. * * The parameter `points` is an array successive Vector3
  105716. * * 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
  105717. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105718. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105719. * * When updating an instance, remember that only point positions can change, not the number of points
  105720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105722. * @param name defines the name of the new line system
  105723. * @param options defines the options used to create the line system
  105724. * @param scene defines the hosting scene
  105725. * @returns a new line mesh
  105726. */
  105727. static CreateLines(name: string, options: {
  105728. points: Vector3[];
  105729. updatable?: boolean;
  105730. instance?: Nullable<LinesMesh>;
  105731. colors?: Color4[];
  105732. useVertexAlpha?: boolean;
  105733. }, scene?: Nullable<Scene>): LinesMesh;
  105734. /**
  105735. * Creates a dashed line mesh
  105736. * * 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
  105737. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105738. * * The parameter `points` is an array successive Vector3
  105739. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105740. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105741. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105742. * * 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
  105743. * * When updating an instance, remember that only point positions can change, not the number of points
  105744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105745. * @param name defines the name of the mesh
  105746. * @param options defines the options used to create the mesh
  105747. * @param scene defines the hosting scene
  105748. * @returns the dashed line mesh
  105749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105750. */
  105751. static CreateDashedLines(name: string, options: {
  105752. points: Vector3[];
  105753. dashSize?: number;
  105754. gapSize?: number;
  105755. dashNb?: number;
  105756. updatable?: boolean;
  105757. instance?: LinesMesh;
  105758. }, scene?: Nullable<Scene>): LinesMesh;
  105759. /**
  105760. * 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.
  105761. * * 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.
  105762. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105763. * * 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.
  105764. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105765. * * 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
  105766. * * 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
  105767. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105769. * * If you create a double-sided mesh, you can choose what parts of 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
  105770. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105772. * @param name defines the name of the mesh
  105773. * @param options defines the options used to create the mesh
  105774. * @param scene defines the hosting scene
  105775. * @returns the extruded shape mesh
  105776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105778. */
  105779. static ExtrudeShape(name: string, options: {
  105780. shape: Vector3[];
  105781. path: Vector3[];
  105782. scale?: number;
  105783. rotation?: number;
  105784. cap?: number;
  105785. updatable?: boolean;
  105786. sideOrientation?: number;
  105787. frontUVs?: Vector4;
  105788. backUVs?: Vector4;
  105789. instance?: Mesh;
  105790. invertUV?: boolean;
  105791. }, scene?: Nullable<Scene>): Mesh;
  105792. /**
  105793. * Creates an custom extruded shape mesh.
  105794. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105795. * * 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.
  105796. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105797. * * 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
  105798. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105799. * * 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
  105800. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105801. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105802. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105803. * * 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
  105804. * * 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
  105805. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105807. * * If you create a double-sided mesh, you can choose what parts of 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
  105808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105810. * @param name defines the name of the mesh
  105811. * @param options defines the options used to create the mesh
  105812. * @param scene defines the hosting scene
  105813. * @returns the custom extruded shape mesh
  105814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105815. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105817. */
  105818. static ExtrudeShapeCustom(name: string, options: {
  105819. shape: Vector3[];
  105820. path: Vector3[];
  105821. scaleFunction?: any;
  105822. rotationFunction?: any;
  105823. ribbonCloseArray?: boolean;
  105824. ribbonClosePath?: boolean;
  105825. cap?: number;
  105826. updatable?: boolean;
  105827. sideOrientation?: number;
  105828. frontUVs?: Vector4;
  105829. backUVs?: Vector4;
  105830. instance?: Mesh;
  105831. invertUV?: boolean;
  105832. }, scene: Scene): Mesh;
  105833. /**
  105834. * Creates lathe mesh.
  105835. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105836. * * 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
  105837. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105838. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105839. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105840. * * 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
  105841. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105842. * * 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
  105843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105844. * * If you create a double-sided mesh, you can choose what parts of 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
  105845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105847. * @param name defines the name of the mesh
  105848. * @param options defines the options used to create the mesh
  105849. * @param scene defines the hosting scene
  105850. * @returns the lathe mesh
  105851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105852. */
  105853. static CreateLathe(name: string, options: {
  105854. shape: Vector3[];
  105855. radius?: number;
  105856. tessellation?: number;
  105857. clip?: number;
  105858. arc?: number;
  105859. closed?: boolean;
  105860. updatable?: boolean;
  105861. sideOrientation?: number;
  105862. frontUVs?: Vector4;
  105863. backUVs?: Vector4;
  105864. cap?: number;
  105865. invertUV?: boolean;
  105866. }, scene: Scene): Mesh;
  105867. /**
  105868. * Creates a plane mesh
  105869. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105870. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105871. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105873. * * If you create a double-sided mesh, you can choose what parts of 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
  105874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105875. * @param name defines the name of the mesh
  105876. * @param options defines the options used to create the mesh
  105877. * @param scene defines the hosting scene
  105878. * @returns the plane mesh
  105879. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105880. */
  105881. static CreatePlane(name: string, options: {
  105882. size?: number;
  105883. width?: number;
  105884. height?: number;
  105885. sideOrientation?: number;
  105886. frontUVs?: Vector4;
  105887. backUVs?: Vector4;
  105888. updatable?: boolean;
  105889. sourcePlane?: Plane;
  105890. }, scene: Scene): Mesh;
  105891. /**
  105892. * Creates a ground mesh
  105893. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105894. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105896. * @param name defines the name of the mesh
  105897. * @param options defines the options used to create the mesh
  105898. * @param scene defines the hosting scene
  105899. * @returns the ground mesh
  105900. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105901. */
  105902. static CreateGround(name: string, options: {
  105903. width?: number;
  105904. height?: number;
  105905. subdivisions?: number;
  105906. subdivisionsX?: number;
  105907. subdivisionsY?: number;
  105908. updatable?: boolean;
  105909. }, scene: any): Mesh;
  105910. /**
  105911. * Creates a tiled ground mesh
  105912. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105913. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105914. * * 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
  105915. * * 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
  105916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105917. * @param name defines the name of the mesh
  105918. * @param options defines the options used to create the mesh
  105919. * @param scene defines the hosting scene
  105920. * @returns the tiled ground mesh
  105921. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105922. */
  105923. static CreateTiledGround(name: string, options: {
  105924. xmin: number;
  105925. zmin: number;
  105926. xmax: number;
  105927. zmax: number;
  105928. subdivisions?: {
  105929. w: number;
  105930. h: number;
  105931. };
  105932. precision?: {
  105933. w: number;
  105934. h: number;
  105935. };
  105936. updatable?: boolean;
  105937. }, scene: Scene): Mesh;
  105938. /**
  105939. * Creates a ground mesh from a height map
  105940. * * The parameter `url` sets the URL of the height map image resource.
  105941. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105942. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105943. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105944. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105945. * * 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.
  105946. * * 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).
  105947. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105949. * @param name defines the name of the mesh
  105950. * @param url defines the url to the height map
  105951. * @param options defines the options used to create the mesh
  105952. * @param scene defines the hosting scene
  105953. * @returns the ground mesh
  105954. * @see https://doc.babylonjs.com/babylon101/height_map
  105955. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105956. */
  105957. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105958. width?: number;
  105959. height?: number;
  105960. subdivisions?: number;
  105961. minHeight?: number;
  105962. maxHeight?: number;
  105963. colorFilter?: Color3;
  105964. alphaFilter?: number;
  105965. updatable?: boolean;
  105966. onReady?: (mesh: GroundMesh) => void;
  105967. }, scene: Scene): GroundMesh;
  105968. /**
  105969. * Creates a polygon mesh
  105970. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105971. * * 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
  105972. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105975. * * Remember you can only change the shape positions, not their number when updating a polygon
  105976. * @param name defines the name of the mesh
  105977. * @param options defines the options used to create the mesh
  105978. * @param scene defines the hosting scene
  105979. * @param earcutInjection can be used to inject your own earcut reference
  105980. * @returns the polygon mesh
  105981. */
  105982. static CreatePolygon(name: string, options: {
  105983. shape: Vector3[];
  105984. holes?: Vector3[][];
  105985. depth?: number;
  105986. faceUV?: Vector4[];
  105987. faceColors?: Color4[];
  105988. updatable?: boolean;
  105989. sideOrientation?: number;
  105990. frontUVs?: Vector4;
  105991. backUVs?: Vector4;
  105992. }, scene: Scene, earcutInjection?: any): Mesh;
  105993. /**
  105994. * Creates an extruded polygon mesh, with depth in the Y direction.
  105995. * * 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)
  105996. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105997. * @param name defines the name of the mesh
  105998. * @param options defines the options used to create the mesh
  105999. * @param scene defines the hosting scene
  106000. * @param earcutInjection can be used to inject your own earcut reference
  106001. * @returns the polygon mesh
  106002. */
  106003. static ExtrudePolygon(name: string, options: {
  106004. shape: Vector3[];
  106005. holes?: Vector3[][];
  106006. depth?: number;
  106007. faceUV?: Vector4[];
  106008. faceColors?: Color4[];
  106009. updatable?: boolean;
  106010. sideOrientation?: number;
  106011. frontUVs?: Vector4;
  106012. backUVs?: Vector4;
  106013. }, scene: Scene, earcutInjection?: any): Mesh;
  106014. /**
  106015. * Creates a tube mesh.
  106016. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106017. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106018. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106019. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106020. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106021. * * 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)
  106022. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106023. * * 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
  106024. * * 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
  106025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106026. * * If you create a double-sided mesh, you can choose what parts of 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
  106027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106029. * @param name defines the name of the mesh
  106030. * @param options defines the options used to create the mesh
  106031. * @param scene defines the hosting scene
  106032. * @returns the tube mesh
  106033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106034. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106035. */
  106036. static CreateTube(name: string, options: {
  106037. path: Vector3[];
  106038. radius?: number;
  106039. tessellation?: number;
  106040. radiusFunction?: {
  106041. (i: number, distance: number): number;
  106042. };
  106043. cap?: number;
  106044. arc?: number;
  106045. updatable?: boolean;
  106046. sideOrientation?: number;
  106047. frontUVs?: Vector4;
  106048. backUVs?: Vector4;
  106049. instance?: Mesh;
  106050. invertUV?: boolean;
  106051. }, scene: Scene): Mesh;
  106052. /**
  106053. * Creates a polyhedron mesh
  106054. * * 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
  106055. * * The parameter `size` (positive float, default 1) sets the polygon size
  106056. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106057. * * 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`
  106058. * * 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
  106059. * * 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)`)
  106060. * * 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
  106061. * * 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
  106062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106063. * * If you create a double-sided mesh, you can choose what parts of 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
  106064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106065. * @param name defines the name of the mesh
  106066. * @param options defines the options used to create the mesh
  106067. * @param scene defines the hosting scene
  106068. * @returns the polyhedron mesh
  106069. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106070. */
  106071. static CreatePolyhedron(name: string, options: {
  106072. type?: number;
  106073. size?: number;
  106074. sizeX?: number;
  106075. sizeY?: number;
  106076. sizeZ?: number;
  106077. custom?: any;
  106078. faceUV?: Vector4[];
  106079. faceColors?: Color4[];
  106080. flat?: boolean;
  106081. updatable?: boolean;
  106082. sideOrientation?: number;
  106083. frontUVs?: Vector4;
  106084. backUVs?: Vector4;
  106085. }, scene: Scene): Mesh;
  106086. /**
  106087. * Creates a decal mesh.
  106088. * 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
  106089. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106090. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106091. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106092. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106093. * @param name defines the name of the mesh
  106094. * @param sourceMesh defines the mesh where the decal must be applied
  106095. * @param options defines the options used to create the mesh
  106096. * @param scene defines the hosting scene
  106097. * @returns the decal mesh
  106098. * @see https://doc.babylonjs.com/how_to/decals
  106099. */
  106100. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106101. position?: Vector3;
  106102. normal?: Vector3;
  106103. size?: Vector3;
  106104. angle?: number;
  106105. }): Mesh;
  106106. }
  106107. }
  106108. declare module BABYLON {
  106109. /**
  106110. * A simplifier interface for future simplification implementations
  106111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106112. */
  106113. export interface ISimplifier {
  106114. /**
  106115. * Simplification of a given mesh according to the given settings.
  106116. * Since this requires computation, it is assumed that the function runs async.
  106117. * @param settings The settings of the simplification, including quality and distance
  106118. * @param successCallback A callback that will be called after the mesh was simplified.
  106119. * @param errorCallback in case of an error, this callback will be called. optional.
  106120. */
  106121. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106122. }
  106123. /**
  106124. * Expected simplification settings.
  106125. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106126. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106127. */
  106128. export interface ISimplificationSettings {
  106129. /**
  106130. * Gets or sets the expected quality
  106131. */
  106132. quality: number;
  106133. /**
  106134. * Gets or sets the distance when this optimized version should be used
  106135. */
  106136. distance: number;
  106137. /**
  106138. * Gets an already optimized mesh
  106139. */
  106140. optimizeMesh?: boolean;
  106141. }
  106142. /**
  106143. * Class used to specify simplification options
  106144. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106145. */
  106146. export class SimplificationSettings implements ISimplificationSettings {
  106147. /** expected quality */
  106148. quality: number;
  106149. /** distance when this optimized version should be used */
  106150. distance: number;
  106151. /** already optimized mesh */
  106152. optimizeMesh?: boolean | undefined;
  106153. /**
  106154. * Creates a SimplificationSettings
  106155. * @param quality expected quality
  106156. * @param distance distance when this optimized version should be used
  106157. * @param optimizeMesh already optimized mesh
  106158. */
  106159. constructor(
  106160. /** expected quality */
  106161. quality: number,
  106162. /** distance when this optimized version should be used */
  106163. distance: number,
  106164. /** already optimized mesh */
  106165. optimizeMesh?: boolean | undefined);
  106166. }
  106167. /**
  106168. * Interface used to define a simplification task
  106169. */
  106170. export interface ISimplificationTask {
  106171. /**
  106172. * Array of settings
  106173. */
  106174. settings: Array<ISimplificationSettings>;
  106175. /**
  106176. * Simplification type
  106177. */
  106178. simplificationType: SimplificationType;
  106179. /**
  106180. * Mesh to simplify
  106181. */
  106182. mesh: Mesh;
  106183. /**
  106184. * Callback called on success
  106185. */
  106186. successCallback?: () => void;
  106187. /**
  106188. * Defines if parallel processing can be used
  106189. */
  106190. parallelProcessing: boolean;
  106191. }
  106192. /**
  106193. * Queue used to order the simplification tasks
  106194. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106195. */
  106196. export class SimplificationQueue {
  106197. private _simplificationArray;
  106198. /**
  106199. * Gets a boolean indicating that the process is still running
  106200. */
  106201. running: boolean;
  106202. /**
  106203. * Creates a new queue
  106204. */
  106205. constructor();
  106206. /**
  106207. * Adds a new simplification task
  106208. * @param task defines a task to add
  106209. */
  106210. addTask(task: ISimplificationTask): void;
  106211. /**
  106212. * Execute next task
  106213. */
  106214. executeNext(): void;
  106215. /**
  106216. * Execute a simplification task
  106217. * @param task defines the task to run
  106218. */
  106219. runSimplification(task: ISimplificationTask): void;
  106220. private getSimplifier;
  106221. }
  106222. /**
  106223. * The implemented types of simplification
  106224. * At the moment only Quadratic Error Decimation is implemented
  106225. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106226. */
  106227. export enum SimplificationType {
  106228. /** Quadratic error decimation */
  106229. QUADRATIC = 0
  106230. }
  106231. }
  106232. declare module BABYLON {
  106233. interface Scene {
  106234. /** @hidden (Backing field) */
  106235. _simplificationQueue: SimplificationQueue;
  106236. /**
  106237. * Gets or sets the simplification queue attached to the scene
  106238. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106239. */
  106240. simplificationQueue: SimplificationQueue;
  106241. }
  106242. interface Mesh {
  106243. /**
  106244. * Simplify the mesh according to the given array of settings.
  106245. * Function will return immediately and will simplify async
  106246. * @param settings a collection of simplification settings
  106247. * @param parallelProcessing should all levels calculate parallel or one after the other
  106248. * @param simplificationType the type of simplification to run
  106249. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106250. * @returns the current mesh
  106251. */
  106252. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106253. }
  106254. /**
  106255. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106256. * created in a scene
  106257. */
  106258. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106259. /**
  106260. * The component name helpfull to identify the component in the list of scene components.
  106261. */
  106262. readonly name: string;
  106263. /**
  106264. * The scene the component belongs to.
  106265. */
  106266. scene: Scene;
  106267. /**
  106268. * Creates a new instance of the component for the given scene
  106269. * @param scene Defines the scene to register the component in
  106270. */
  106271. constructor(scene: Scene);
  106272. /**
  106273. * Registers the component in a given scene
  106274. */
  106275. register(): void;
  106276. /**
  106277. * Rebuilds the elements related to this component in case of
  106278. * context lost for instance.
  106279. */
  106280. rebuild(): void;
  106281. /**
  106282. * Disposes the component and the associated ressources
  106283. */
  106284. dispose(): void;
  106285. private _beforeCameraUpdate;
  106286. }
  106287. }
  106288. declare module BABYLON {
  106289. /**
  106290. * Class used to enable access to IndexedDB
  106291. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106292. */
  106293. export class Database implements IOfflineProvider {
  106294. private _callbackManifestChecked;
  106295. private _currentSceneUrl;
  106296. private _db;
  106297. private _enableSceneOffline;
  106298. private _enableTexturesOffline;
  106299. private _manifestVersionFound;
  106300. private _mustUpdateRessources;
  106301. private _hasReachedQuota;
  106302. private _isSupported;
  106303. private _idbFactory;
  106304. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106305. private static IsUASupportingBlobStorage;
  106306. /**
  106307. * Gets a boolean indicating if Database storate is enabled (off by default)
  106308. */
  106309. static IDBStorageEnabled: boolean;
  106310. /**
  106311. * Gets a boolean indicating if scene must be saved in the database
  106312. */
  106313. readonly enableSceneOffline: boolean;
  106314. /**
  106315. * Gets a boolean indicating if textures must be saved in the database
  106316. */
  106317. readonly enableTexturesOffline: boolean;
  106318. /**
  106319. * Creates a new Database
  106320. * @param urlToScene defines the url to load the scene
  106321. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106322. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106323. */
  106324. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106325. private static _ParseURL;
  106326. private static _ReturnFullUrlLocation;
  106327. private _checkManifestFile;
  106328. /**
  106329. * Open the database and make it available
  106330. * @param successCallback defines the callback to call on success
  106331. * @param errorCallback defines the callback to call on error
  106332. */
  106333. open(successCallback: () => void, errorCallback: () => void): void;
  106334. /**
  106335. * Loads an image from the database
  106336. * @param url defines the url to load from
  106337. * @param image defines the target DOM image
  106338. */
  106339. loadImage(url: string, image: HTMLImageElement): void;
  106340. private _loadImageFromDBAsync;
  106341. private _saveImageIntoDBAsync;
  106342. private _checkVersionFromDB;
  106343. private _loadVersionFromDBAsync;
  106344. private _saveVersionIntoDBAsync;
  106345. /**
  106346. * Loads a file from database
  106347. * @param url defines the URL to load from
  106348. * @param sceneLoaded defines a callback to call on success
  106349. * @param progressCallBack defines a callback to call when progress changed
  106350. * @param errorCallback defines a callback to call on error
  106351. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106352. */
  106353. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106354. private _loadFileAsync;
  106355. private _saveFileAsync;
  106356. /**
  106357. * Validates if xhr data is correct
  106358. * @param xhr defines the request to validate
  106359. * @param dataType defines the expected data type
  106360. * @returns true if data is correct
  106361. */
  106362. private static _ValidateXHRData;
  106363. }
  106364. }
  106365. declare module BABYLON {
  106366. /** @hidden */
  106367. export var gpuUpdateParticlesPixelShader: {
  106368. name: string;
  106369. shader: string;
  106370. };
  106371. }
  106372. declare module BABYLON {
  106373. /** @hidden */
  106374. export var gpuUpdateParticlesVertexShader: {
  106375. name: string;
  106376. shader: string;
  106377. };
  106378. }
  106379. declare module BABYLON {
  106380. /** @hidden */
  106381. export var clipPlaneFragmentDeclaration2: {
  106382. name: string;
  106383. shader: string;
  106384. };
  106385. }
  106386. declare module BABYLON {
  106387. /** @hidden */
  106388. export var gpuRenderParticlesPixelShader: {
  106389. name: string;
  106390. shader: string;
  106391. };
  106392. }
  106393. declare module BABYLON {
  106394. /** @hidden */
  106395. export var clipPlaneVertexDeclaration2: {
  106396. name: string;
  106397. shader: string;
  106398. };
  106399. }
  106400. declare module BABYLON {
  106401. /** @hidden */
  106402. export var gpuRenderParticlesVertexShader: {
  106403. name: string;
  106404. shader: string;
  106405. };
  106406. }
  106407. declare module BABYLON {
  106408. /**
  106409. * This represents a GPU particle system in Babylon
  106410. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106411. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106412. */
  106413. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106414. /**
  106415. * The layer mask we are rendering the particles through.
  106416. */
  106417. layerMask: number;
  106418. private _capacity;
  106419. private _activeCount;
  106420. private _currentActiveCount;
  106421. private _accumulatedCount;
  106422. private _renderEffect;
  106423. private _updateEffect;
  106424. private _buffer0;
  106425. private _buffer1;
  106426. private _spriteBuffer;
  106427. private _updateVAO;
  106428. private _renderVAO;
  106429. private _targetIndex;
  106430. private _sourceBuffer;
  106431. private _targetBuffer;
  106432. private _engine;
  106433. private _currentRenderId;
  106434. private _started;
  106435. private _stopped;
  106436. private _timeDelta;
  106437. private _randomTexture;
  106438. private _randomTexture2;
  106439. private _attributesStrideSize;
  106440. private _updateEffectOptions;
  106441. private _randomTextureSize;
  106442. private _actualFrame;
  106443. private readonly _rawTextureWidth;
  106444. /**
  106445. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106446. */
  106447. static readonly IsSupported: boolean;
  106448. /**
  106449. * An event triggered when the system is disposed.
  106450. */
  106451. onDisposeObservable: Observable<GPUParticleSystem>;
  106452. /**
  106453. * Gets the maximum number of particles active at the same time.
  106454. * @returns The max number of active particles.
  106455. */
  106456. getCapacity(): number;
  106457. /**
  106458. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106459. * to override the particles.
  106460. */
  106461. forceDepthWrite: boolean;
  106462. /**
  106463. * Gets or set the number of active particles
  106464. */
  106465. activeParticleCount: number;
  106466. private _preWarmDone;
  106467. /**
  106468. * Is this system ready to be used/rendered
  106469. * @return true if the system is ready
  106470. */
  106471. isReady(): boolean;
  106472. /**
  106473. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106474. * @returns True if it has been started, otherwise false.
  106475. */
  106476. isStarted(): boolean;
  106477. /**
  106478. * Starts the particle system and begins to emit
  106479. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106480. */
  106481. start(delay?: number): void;
  106482. /**
  106483. * Stops the particle system.
  106484. */
  106485. stop(): void;
  106486. /**
  106487. * Remove all active particles
  106488. */
  106489. reset(): void;
  106490. /**
  106491. * Returns the string "GPUParticleSystem"
  106492. * @returns a string containing the class name
  106493. */
  106494. getClassName(): string;
  106495. private _colorGradientsTexture;
  106496. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106497. /**
  106498. * Adds a new color gradient
  106499. * @param gradient defines the gradient to use (between 0 and 1)
  106500. * @param color1 defines the color to affect to the specified gradient
  106501. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106502. * @returns the current particle system
  106503. */
  106504. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106505. /**
  106506. * Remove a specific color gradient
  106507. * @param gradient defines the gradient to remove
  106508. * @returns the current particle system
  106509. */
  106510. removeColorGradient(gradient: number): GPUParticleSystem;
  106511. private _angularSpeedGradientsTexture;
  106512. private _sizeGradientsTexture;
  106513. private _velocityGradientsTexture;
  106514. private _limitVelocityGradientsTexture;
  106515. private _dragGradientsTexture;
  106516. private _addFactorGradient;
  106517. /**
  106518. * Adds a new size gradient
  106519. * @param gradient defines the gradient to use (between 0 and 1)
  106520. * @param factor defines the size factor to affect to the specified gradient
  106521. * @returns the current particle system
  106522. */
  106523. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106524. /**
  106525. * Remove a specific size gradient
  106526. * @param gradient defines the gradient to remove
  106527. * @returns the current particle system
  106528. */
  106529. removeSizeGradient(gradient: number): GPUParticleSystem;
  106530. /**
  106531. * Adds a new angular speed gradient
  106532. * @param gradient defines the gradient to use (between 0 and 1)
  106533. * @param factor defines the angular speed to affect to the specified gradient
  106534. * @returns the current particle system
  106535. */
  106536. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106537. /**
  106538. * Remove a specific angular speed gradient
  106539. * @param gradient defines the gradient to remove
  106540. * @returns the current particle system
  106541. */
  106542. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106543. /**
  106544. * Adds a new velocity gradient
  106545. * @param gradient defines the gradient to use (between 0 and 1)
  106546. * @param factor defines the velocity to affect to the specified gradient
  106547. * @returns the current particle system
  106548. */
  106549. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106550. /**
  106551. * Remove a specific velocity gradient
  106552. * @param gradient defines the gradient to remove
  106553. * @returns the current particle system
  106554. */
  106555. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106556. /**
  106557. * Adds a new limit velocity gradient
  106558. * @param gradient defines the gradient to use (between 0 and 1)
  106559. * @param factor defines the limit velocity value to affect to the specified gradient
  106560. * @returns the current particle system
  106561. */
  106562. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106563. /**
  106564. * Remove a specific limit velocity gradient
  106565. * @param gradient defines the gradient to remove
  106566. * @returns the current particle system
  106567. */
  106568. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106569. /**
  106570. * Adds a new drag gradient
  106571. * @param gradient defines the gradient to use (between 0 and 1)
  106572. * @param factor defines the drag value to affect to the specified gradient
  106573. * @returns the current particle system
  106574. */
  106575. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106576. /**
  106577. * Remove a specific drag gradient
  106578. * @param gradient defines the gradient to remove
  106579. * @returns the current particle system
  106580. */
  106581. removeDragGradient(gradient: number): GPUParticleSystem;
  106582. /**
  106583. * Not supported by GPUParticleSystem
  106584. * @param gradient defines the gradient to use (between 0 and 1)
  106585. * @param factor defines the emit rate value to affect to the specified gradient
  106586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106587. * @returns the current particle system
  106588. */
  106589. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106590. /**
  106591. * Not supported by GPUParticleSystem
  106592. * @param gradient defines the gradient to remove
  106593. * @returns the current particle system
  106594. */
  106595. removeEmitRateGradient(gradient: number): IParticleSystem;
  106596. /**
  106597. * Not supported by GPUParticleSystem
  106598. * @param gradient defines the gradient to use (between 0 and 1)
  106599. * @param factor defines the start size value to affect to the specified gradient
  106600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106601. * @returns the current particle system
  106602. */
  106603. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106604. /**
  106605. * Not supported by GPUParticleSystem
  106606. * @param gradient defines the gradient to remove
  106607. * @returns the current particle system
  106608. */
  106609. removeStartSizeGradient(gradient: number): IParticleSystem;
  106610. /**
  106611. * Not supported by GPUParticleSystem
  106612. * @param gradient defines the gradient to use (between 0 and 1)
  106613. * @param min defines the color remap minimal range
  106614. * @param max defines the color remap maximal range
  106615. * @returns the current particle system
  106616. */
  106617. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106618. /**
  106619. * Not supported by GPUParticleSystem
  106620. * @param gradient defines the gradient to remove
  106621. * @returns the current particle system
  106622. */
  106623. removeColorRemapGradient(): IParticleSystem;
  106624. /**
  106625. * Not supported by GPUParticleSystem
  106626. * @param gradient defines the gradient to use (between 0 and 1)
  106627. * @param min defines the alpha remap minimal range
  106628. * @param max defines the alpha remap maximal range
  106629. * @returns the current particle system
  106630. */
  106631. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106632. /**
  106633. * Not supported by GPUParticleSystem
  106634. * @param gradient defines the gradient to remove
  106635. * @returns the current particle system
  106636. */
  106637. removeAlphaRemapGradient(): IParticleSystem;
  106638. /**
  106639. * Not supported by GPUParticleSystem
  106640. * @param gradient defines the gradient to use (between 0 and 1)
  106641. * @param color defines the color to affect to the specified gradient
  106642. * @returns the current particle system
  106643. */
  106644. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  106645. /**
  106646. * Not supported by GPUParticleSystem
  106647. * @param gradient defines the gradient to remove
  106648. * @returns the current particle system
  106649. */
  106650. removeRampGradient(): IParticleSystem;
  106651. /**
  106652. * Not supported by GPUParticleSystem
  106653. * @returns the list of ramp gradients
  106654. */
  106655. getRampGradients(): Nullable<Array<Color3Gradient>>;
  106656. /**
  106657. * Not supported by GPUParticleSystem
  106658. * Gets or sets a boolean indicating that ramp gradients must be used
  106659. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106660. */
  106661. useRampGradients: boolean;
  106662. /**
  106663. * Not supported by GPUParticleSystem
  106664. * @param gradient defines the gradient to use (between 0 and 1)
  106665. * @param factor defines the life time factor to affect to the specified gradient
  106666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106667. * @returns the current particle system
  106668. */
  106669. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106670. /**
  106671. * Not supported by GPUParticleSystem
  106672. * @param gradient defines the gradient to remove
  106673. * @returns the current particle system
  106674. */
  106675. removeLifeTimeGradient(gradient: number): IParticleSystem;
  106676. /**
  106677. * Instantiates a GPU particle system.
  106678. * 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.
  106679. * @param name The name of the particle system
  106680. * @param options The options used to create the system
  106681. * @param scene The scene the particle system belongs to
  106682. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106683. */
  106684. constructor(name: string, options: Partial<{
  106685. capacity: number;
  106686. randomTextureSize: number;
  106687. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  106688. protected _reset(): void;
  106689. private _createUpdateVAO;
  106690. private _createRenderVAO;
  106691. private _initialize;
  106692. /** @hidden */
  106693. _recreateUpdateEffect(): void;
  106694. /** @hidden */
  106695. _recreateRenderEffect(): void;
  106696. /**
  106697. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106698. * @param preWarm defines if we are in the pre-warmimg phase
  106699. */
  106700. animate(preWarm?: boolean): void;
  106701. private _createFactorGradientTexture;
  106702. private _createSizeGradientTexture;
  106703. private _createAngularSpeedGradientTexture;
  106704. private _createVelocityGradientTexture;
  106705. private _createLimitVelocityGradientTexture;
  106706. private _createDragGradientTexture;
  106707. private _createColorGradientTexture;
  106708. /**
  106709. * Renders the particle system in its current state
  106710. * @param preWarm defines if the system should only update the particles but not render them
  106711. * @returns the current number of particles
  106712. */
  106713. render(preWarm?: boolean): number;
  106714. /**
  106715. * Rebuilds the particle system
  106716. */
  106717. rebuild(): void;
  106718. private _releaseBuffers;
  106719. private _releaseVAOs;
  106720. /**
  106721. * Disposes the particle system and free the associated resources
  106722. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106723. */
  106724. dispose(disposeTexture?: boolean): void;
  106725. /**
  106726. * Clones the particle system.
  106727. * @param name The name of the cloned object
  106728. * @param newEmitter The new emitter to use
  106729. * @returns the cloned particle system
  106730. */
  106731. clone(name: string, newEmitter: any): GPUParticleSystem;
  106732. /**
  106733. * Serializes the particle system to a JSON object.
  106734. * @returns the JSON object
  106735. */
  106736. serialize(): any;
  106737. /**
  106738. * Parses a JSON object to create a GPU particle system.
  106739. * @param parsedParticleSystem The JSON object to parse
  106740. * @param scene The scene to create the particle system in
  106741. * @param rootUrl The root url to use to load external dependencies like texture
  106742. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106743. * @returns the parsed GPU particle system
  106744. */
  106745. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  106746. }
  106747. }
  106748. declare module BABYLON {
  106749. /**
  106750. * Represents a set of particle systems working together to create a specific effect
  106751. */
  106752. export class ParticleSystemSet implements IDisposable {
  106753. private _emitterCreationOptions;
  106754. private _emitterNode;
  106755. /**
  106756. * Gets the particle system list
  106757. */
  106758. systems: IParticleSystem[];
  106759. /**
  106760. * Gets the emitter node used with this set
  106761. */
  106762. readonly emitterNode: Nullable<TransformNode>;
  106763. /**
  106764. * Creates a new emitter mesh as a sphere
  106765. * @param options defines the options used to create the sphere
  106766. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106767. * @param scene defines the hosting scene
  106768. */
  106769. setEmitterAsSphere(options: {
  106770. diameter: number;
  106771. segments: number;
  106772. color: Color3;
  106773. }, renderingGroupId: number, scene: Scene): void;
  106774. /**
  106775. * Starts all particle systems of the set
  106776. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106777. */
  106778. start(emitter?: AbstractMesh): void;
  106779. /**
  106780. * Release all associated resources
  106781. */
  106782. dispose(): void;
  106783. /**
  106784. * Serialize the set into a JSON compatible object
  106785. * @returns a JSON compatible representation of the set
  106786. */
  106787. serialize(): any;
  106788. /**
  106789. * Parse a new ParticleSystemSet from a serialized source
  106790. * @param data defines a JSON compatible representation of the set
  106791. * @param scene defines the hosting scene
  106792. * @param gpu defines if we want GPU particles or CPU particles
  106793. * @returns a new ParticleSystemSet
  106794. */
  106795. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  106796. }
  106797. }
  106798. declare module BABYLON {
  106799. /**
  106800. * This class is made for on one-liner static method to help creating particle system set.
  106801. */
  106802. export class ParticleHelper {
  106803. /**
  106804. * Gets or sets base Assets URL
  106805. */
  106806. static BaseAssetsUrl: string;
  106807. /**
  106808. * Create a default particle system that you can tweak
  106809. * @param emitter defines the emitter to use
  106810. * @param capacity defines the system capacity (default is 500 particles)
  106811. * @param scene defines the hosting scene
  106812. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106813. * @returns the new Particle system
  106814. */
  106815. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  106816. /**
  106817. * This is the main static method (one-liner) of this helper to create different particle systems
  106818. * @param type This string represents the type to the particle system to create
  106819. * @param scene The scene where the particle system should live
  106820. * @param gpu If the system will use gpu
  106821. * @returns the ParticleSystemSet created
  106822. */
  106823. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  106824. /**
  106825. * Static function used to export a particle system to a ParticleSystemSet variable.
  106826. * Please note that the emitter shape is not exported
  106827. * @param systems defines the particle systems to export
  106828. * @returns the created particle system set
  106829. */
  106830. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  106831. }
  106832. }
  106833. declare module BABYLON {
  106834. interface Engine {
  106835. /**
  106836. * Create an effect to use with particle systems.
  106837. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  106838. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  106839. * @param uniformsNames defines a list of attribute names
  106840. * @param samplers defines an array of string used to represent textures
  106841. * @param defines defines the string containing the defines to use to compile the shaders
  106842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106843. * @param onCompiled defines a function to call when the effect creation is successful
  106844. * @param onError defines a function to call when the effect creation has failed
  106845. * @returns the new Effect
  106846. */
  106847. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  106848. }
  106849. interface Mesh {
  106850. /**
  106851. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  106852. * @returns an array of IParticleSystem
  106853. */
  106854. getEmittedParticleSystems(): IParticleSystem[];
  106855. /**
  106856. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  106857. * @returns an array of IParticleSystem
  106858. */
  106859. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  106860. }
  106861. /**
  106862. * @hidden
  106863. */
  106864. export var _IDoNeedToBeInTheBuild: number;
  106865. }
  106866. declare module BABYLON {
  106867. interface Scene {
  106868. /** @hidden (Backing field) */
  106869. _physicsEngine: Nullable<IPhysicsEngine>;
  106870. /**
  106871. * Gets the current physics engine
  106872. * @returns a IPhysicsEngine or null if none attached
  106873. */
  106874. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  106875. /**
  106876. * Enables physics to the current scene
  106877. * @param gravity defines the scene's gravity for the physics engine
  106878. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  106879. * @return a boolean indicating if the physics engine was initialized
  106880. */
  106881. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  106882. /**
  106883. * Disables and disposes the physics engine associated with the scene
  106884. */
  106885. disablePhysicsEngine(): void;
  106886. /**
  106887. * Gets a boolean indicating if there is an active physics engine
  106888. * @returns a boolean indicating if there is an active physics engine
  106889. */
  106890. isPhysicsEnabled(): boolean;
  106891. /**
  106892. * Deletes a physics compound impostor
  106893. * @param compound defines the compound to delete
  106894. */
  106895. deleteCompoundImpostor(compound: any): void;
  106896. /**
  106897. * An event triggered when physic simulation is about to be run
  106898. */
  106899. onBeforePhysicsObservable: Observable<Scene>;
  106900. /**
  106901. * An event triggered when physic simulation has been done
  106902. */
  106903. onAfterPhysicsObservable: Observable<Scene>;
  106904. }
  106905. interface AbstractMesh {
  106906. /** @hidden */
  106907. _physicsImpostor: Nullable<PhysicsImpostor>;
  106908. /**
  106909. * Gets or sets impostor used for physic simulation
  106910. * @see http://doc.babylonjs.com/features/physics_engine
  106911. */
  106912. physicsImpostor: Nullable<PhysicsImpostor>;
  106913. /**
  106914. * Gets the current physics impostor
  106915. * @see http://doc.babylonjs.com/features/physics_engine
  106916. * @returns a physics impostor or null
  106917. */
  106918. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106919. /** Apply a physic impulse to the mesh
  106920. * @param force defines the force to apply
  106921. * @param contactPoint defines where to apply the force
  106922. * @returns the current mesh
  106923. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106924. */
  106925. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106926. /**
  106927. * Creates a physic joint between two meshes
  106928. * @param otherMesh defines the other mesh to use
  106929. * @param pivot1 defines the pivot to use on this mesh
  106930. * @param pivot2 defines the pivot to use on the other mesh
  106931. * @param options defines additional options (can be plugin dependent)
  106932. * @returns the current mesh
  106933. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106934. */
  106935. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106936. /** @hidden */
  106937. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106938. }
  106939. /**
  106940. * Defines the physics engine scene component responsible to manage a physics engine
  106941. */
  106942. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106943. /**
  106944. * The component name helpful to identify the component in the list of scene components.
  106945. */
  106946. readonly name: string;
  106947. /**
  106948. * The scene the component belongs to.
  106949. */
  106950. scene: Scene;
  106951. /**
  106952. * Creates a new instance of the component for the given scene
  106953. * @param scene Defines the scene to register the component in
  106954. */
  106955. constructor(scene: Scene);
  106956. /**
  106957. * Registers the component in a given scene
  106958. */
  106959. register(): void;
  106960. /**
  106961. * Rebuilds the elements related to this component in case of
  106962. * context lost for instance.
  106963. */
  106964. rebuild(): void;
  106965. /**
  106966. * Disposes the component and the associated ressources
  106967. */
  106968. dispose(): void;
  106969. }
  106970. }
  106971. declare module BABYLON {
  106972. /**
  106973. * A helper for physics simulations
  106974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106975. */
  106976. export class PhysicsHelper {
  106977. private _scene;
  106978. private _physicsEngine;
  106979. /**
  106980. * Initializes the Physics helper
  106981. * @param scene Babylon.js scene
  106982. */
  106983. constructor(scene: Scene);
  106984. /**
  106985. * Applies a radial explosion impulse
  106986. * @param origin the origin of the explosion
  106987. * @param radius the explosion radius
  106988. * @param strength the explosion strength
  106989. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106990. * @returns A physics radial explosion event, or null
  106991. */
  106992. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106993. /**
  106994. * Applies a radial explosion force
  106995. * @param origin the origin of the explosion
  106996. * @param radius the explosion radius
  106997. * @param strength the explosion strength
  106998. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106999. * @returns A physics radial explosion event, or null
  107000. */
  107001. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107002. /**
  107003. * Creates a gravitational field
  107004. * @param origin the origin of the explosion
  107005. * @param radius the explosion radius
  107006. * @param strength the explosion strength
  107007. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107008. * @returns A physics gravitational field event, or null
  107009. */
  107010. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107011. /**
  107012. * Creates a physics updraft event
  107013. * @param origin the origin of the updraft
  107014. * @param radius the radius of the updraft
  107015. * @param strength the strength of the updraft
  107016. * @param height the height of the updraft
  107017. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107018. * @returns A physics updraft event, or null
  107019. */
  107020. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107021. /**
  107022. * Creates a physics vortex event
  107023. * @param origin the of the vortex
  107024. * @param radius the radius of the vortex
  107025. * @param strength the strength of the vortex
  107026. * @param height the height of the vortex
  107027. * @returns a Physics vortex event, or null
  107028. * A physics vortex event or null
  107029. */
  107030. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107031. }
  107032. /**
  107033. * Represents a physics radial explosion event
  107034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107035. */
  107036. export class PhysicsRadialExplosionEvent {
  107037. private _scene;
  107038. private _sphere;
  107039. private _sphereOptions;
  107040. private _rays;
  107041. private _dataFetched;
  107042. /**
  107043. * Initializes a radial explosioin event
  107044. * @param scene BabylonJS scene
  107045. */
  107046. constructor(scene: Scene);
  107047. /**
  107048. * Returns the data related to the radial explosion event (sphere & rays).
  107049. * @returns The radial explosion event data
  107050. */
  107051. getData(): PhysicsRadialExplosionEventData;
  107052. /**
  107053. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107054. * @param impostor A physics imposter
  107055. * @param origin the origin of the explosion
  107056. * @param radius the explosion radius
  107057. * @param strength the explosion strength
  107058. * @param falloff possible options: Constant & Linear
  107059. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107060. */
  107061. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107062. /**
  107063. * Disposes the sphere.
  107064. * @param force Specifies if the sphere should be disposed by force
  107065. */
  107066. dispose(force?: boolean): void;
  107067. /*** Helpers ***/
  107068. private _prepareSphere;
  107069. private _intersectsWithSphere;
  107070. }
  107071. /**
  107072. * Represents a gravitational field event
  107073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107074. */
  107075. export class PhysicsGravitationalFieldEvent {
  107076. private _physicsHelper;
  107077. private _scene;
  107078. private _origin;
  107079. private _radius;
  107080. private _strength;
  107081. private _falloff;
  107082. private _tickCallback;
  107083. private _sphere;
  107084. private _dataFetched;
  107085. /**
  107086. * Initializes the physics gravitational field event
  107087. * @param physicsHelper A physics helper
  107088. * @param scene BabylonJS scene
  107089. * @param origin The origin position of the gravitational field event
  107090. * @param radius The radius of the gravitational field event
  107091. * @param strength The strength of the gravitational field event
  107092. * @param falloff The falloff for the gravitational field event
  107093. */
  107094. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107095. /**
  107096. * Returns the data related to the gravitational field event (sphere).
  107097. * @returns A gravitational field event
  107098. */
  107099. getData(): PhysicsGravitationalFieldEventData;
  107100. /**
  107101. * Enables the gravitational field.
  107102. */
  107103. enable(): void;
  107104. /**
  107105. * Disables the gravitational field.
  107106. */
  107107. disable(): void;
  107108. /**
  107109. * Disposes the sphere.
  107110. * @param force The force to dispose from the gravitational field event
  107111. */
  107112. dispose(force?: boolean): void;
  107113. private _tick;
  107114. }
  107115. /**
  107116. * Represents a physics updraft event
  107117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107118. */
  107119. export class PhysicsUpdraftEvent {
  107120. private _scene;
  107121. private _origin;
  107122. private _radius;
  107123. private _strength;
  107124. private _height;
  107125. private _updraftMode;
  107126. private _physicsEngine;
  107127. private _originTop;
  107128. private _originDirection;
  107129. private _tickCallback;
  107130. private _cylinder;
  107131. private _cylinderPosition;
  107132. private _dataFetched;
  107133. /**
  107134. * Initializes the physics updraft event
  107135. * @param _scene BabylonJS scene
  107136. * @param _origin The origin position of the updraft
  107137. * @param _radius The radius of the updraft
  107138. * @param _strength The strength of the updraft
  107139. * @param _height The height of the updraft
  107140. * @param _updraftMode The mode of the updraft
  107141. */
  107142. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107143. /**
  107144. * Returns the data related to the updraft event (cylinder).
  107145. * @returns A physics updraft event
  107146. */
  107147. getData(): PhysicsUpdraftEventData;
  107148. /**
  107149. * Enables the updraft.
  107150. */
  107151. enable(): void;
  107152. /**
  107153. * Disables the cortex.
  107154. */
  107155. disable(): void;
  107156. /**
  107157. * Disposes the sphere.
  107158. * @param force Specifies if the updraft should be disposed by force
  107159. */
  107160. dispose(force?: boolean): void;
  107161. private getImpostorForceAndContactPoint;
  107162. private _tick;
  107163. /*** Helpers ***/
  107164. private _prepareCylinder;
  107165. private _intersectsWithCylinder;
  107166. }
  107167. /**
  107168. * Represents a physics vortex event
  107169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107170. */
  107171. export class PhysicsVortexEvent {
  107172. private _scene;
  107173. private _origin;
  107174. private _radius;
  107175. private _strength;
  107176. private _height;
  107177. private _physicsEngine;
  107178. private _originTop;
  107179. private _centripetalForceThreshold;
  107180. private _updraftMultiplier;
  107181. private _tickCallback;
  107182. private _cylinder;
  107183. private _cylinderPosition;
  107184. private _dataFetched;
  107185. /**
  107186. * Initializes the physics vortex event
  107187. * @param _scene The BabylonJS scene
  107188. * @param _origin The origin position of the vortex
  107189. * @param _radius The radius of the vortex
  107190. * @param _strength The strength of the vortex
  107191. * @param _height The height of the vortex
  107192. */
  107193. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107194. /**
  107195. * Returns the data related to the vortex event (cylinder).
  107196. * @returns The physics vortex event data
  107197. */
  107198. getData(): PhysicsVortexEventData;
  107199. /**
  107200. * Enables the vortex.
  107201. */
  107202. enable(): void;
  107203. /**
  107204. * Disables the cortex.
  107205. */
  107206. disable(): void;
  107207. /**
  107208. * Disposes the sphere.
  107209. * @param force
  107210. */
  107211. dispose(force?: boolean): void;
  107212. private getImpostorForceAndContactPoint;
  107213. private _tick;
  107214. /*** Helpers ***/
  107215. private _prepareCylinder;
  107216. private _intersectsWithCylinder;
  107217. }
  107218. /**
  107219. * The strenght of the force in correspondence to the distance of the affected object
  107220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107221. */
  107222. export enum PhysicsRadialImpulseFalloff {
  107223. /** Defines that impulse is constant in strength across it's whole radius */
  107224. Constant = 0,
  107225. /** DEfines that impulse gets weaker if it's further from the origin */
  107226. Linear = 1
  107227. }
  107228. /**
  107229. * The strength of the force in correspondence to the distance of the affected object
  107230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107231. */
  107232. export enum PhysicsUpdraftMode {
  107233. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107234. Center = 0,
  107235. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107236. Perpendicular = 1
  107237. }
  107238. /**
  107239. * Interface for a physics force and contact point
  107240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107241. */
  107242. export interface PhysicsForceAndContactPoint {
  107243. /**
  107244. * The force applied at the contact point
  107245. */
  107246. force: Vector3;
  107247. /**
  107248. * The contact point
  107249. */
  107250. contactPoint: Vector3;
  107251. }
  107252. /**
  107253. * Interface for radial explosion event data
  107254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107255. */
  107256. export interface PhysicsRadialExplosionEventData {
  107257. /**
  107258. * A sphere used for the radial explosion event
  107259. */
  107260. sphere: Mesh;
  107261. /**
  107262. * An array of rays for the radial explosion event
  107263. */
  107264. rays: Array<Ray>;
  107265. }
  107266. /**
  107267. * Interface for gravitational field event data
  107268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107269. */
  107270. export interface PhysicsGravitationalFieldEventData {
  107271. /**
  107272. * A sphere mesh used for the gravitational field event
  107273. */
  107274. sphere: Mesh;
  107275. }
  107276. /**
  107277. * Interface for updraft event data
  107278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107279. */
  107280. export interface PhysicsUpdraftEventData {
  107281. /**
  107282. * A cylinder used for the updraft event
  107283. */
  107284. cylinder: Mesh;
  107285. }
  107286. /**
  107287. * Interface for vortex event data
  107288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107289. */
  107290. export interface PhysicsVortexEventData {
  107291. /**
  107292. * A cylinder used for the vortex event
  107293. */
  107294. cylinder: Mesh;
  107295. }
  107296. }
  107297. declare module BABYLON {
  107298. /**
  107299. * AmmoJS Physics plugin
  107300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107301. * @see https://github.com/kripken/ammo.js/
  107302. */
  107303. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107304. private _useDeltaForWorldStep;
  107305. /**
  107306. * Reference to the Ammo library
  107307. */
  107308. bjsAMMO: any;
  107309. /**
  107310. * Created ammoJS world which physics bodies are added to
  107311. */
  107312. world: any;
  107313. /**
  107314. * Name of the plugin
  107315. */
  107316. name: string;
  107317. private _timeStep;
  107318. private _fixedTimeStep;
  107319. private _maxSteps;
  107320. private _tmpQuaternion;
  107321. private _tmpAmmoTransform;
  107322. private _tmpAmmoQuaternion;
  107323. private _tmpAmmoConcreteContactResultCallback;
  107324. private _collisionConfiguration;
  107325. private _dispatcher;
  107326. private _overlappingPairCache;
  107327. private _solver;
  107328. private _tmpAmmoVectorA;
  107329. private _tmpAmmoVectorB;
  107330. private _tmpAmmoVectorC;
  107331. private _tmpContactCallbackResult;
  107332. private static readonly DISABLE_COLLISION_FLAG;
  107333. private static readonly KINEMATIC_FLAG;
  107334. private static readonly DISABLE_DEACTIVATION_FLAG;
  107335. /**
  107336. * Initializes the ammoJS plugin
  107337. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107338. * @param ammoInjection can be used to inject your own ammo reference
  107339. */
  107340. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107341. /**
  107342. * Sets the gravity of the physics world (m/(s^2))
  107343. * @param gravity Gravity to set
  107344. */
  107345. setGravity(gravity: Vector3): void;
  107346. /**
  107347. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107348. * @param timeStep timestep to use in seconds
  107349. */
  107350. setTimeStep(timeStep: number): void;
  107351. /**
  107352. * 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)
  107353. * @param fixedTimeStep fixedTimeStep to use in seconds
  107354. */
  107355. setFixedTimeStep(fixedTimeStep: number): void;
  107356. /**
  107357. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107358. * @param maxSteps the maximum number of steps by the physics engine per frame
  107359. */
  107360. setMaxSteps(maxSteps: number): void;
  107361. /**
  107362. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107363. * @returns the current timestep in seconds
  107364. */
  107365. getTimeStep(): number;
  107366. private _isImpostorInContact;
  107367. private _isImpostorPairInContact;
  107368. private _stepSimulation;
  107369. /**
  107370. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107371. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107372. * After the step the babylon meshes are set to the position of the physics imposters
  107373. * @param delta amount of time to step forward
  107374. * @param impostors array of imposters to update before/after the step
  107375. */
  107376. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107377. private _tmpVector;
  107378. private _tmpMatrix;
  107379. /**
  107380. * Applies an implulse on the imposter
  107381. * @param impostor imposter to apply impulse
  107382. * @param force amount of force to be applied to the imposter
  107383. * @param contactPoint the location to apply the impulse on the imposter
  107384. */
  107385. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107386. /**
  107387. * Applies a force on the imposter
  107388. * @param impostor imposter to apply force
  107389. * @param force amount of force to be applied to the imposter
  107390. * @param contactPoint the location to apply the force on the imposter
  107391. */
  107392. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107393. /**
  107394. * Creates a physics body using the plugin
  107395. * @param impostor the imposter to create the physics body on
  107396. */
  107397. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107398. /**
  107399. * Removes the physics body from the imposter and disposes of the body's memory
  107400. * @param impostor imposter to remove the physics body from
  107401. */
  107402. removePhysicsBody(impostor: PhysicsImpostor): void;
  107403. /**
  107404. * Generates a joint
  107405. * @param impostorJoint the imposter joint to create the joint with
  107406. */
  107407. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107408. /**
  107409. * Removes a joint
  107410. * @param impostorJoint the imposter joint to remove the joint from
  107411. */
  107412. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107413. private _addMeshVerts;
  107414. private _createShape;
  107415. /**
  107416. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107417. * @param impostor imposter containing the physics body and babylon object
  107418. */
  107419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107420. /**
  107421. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107422. * @param impostor imposter containing the physics body and babylon object
  107423. * @param newPosition new position
  107424. * @param newRotation new rotation
  107425. */
  107426. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107427. /**
  107428. * If this plugin is supported
  107429. * @returns true if its supported
  107430. */
  107431. isSupported(): boolean;
  107432. /**
  107433. * Sets the linear velocity of the physics body
  107434. * @param impostor imposter to set the velocity on
  107435. * @param velocity velocity to set
  107436. */
  107437. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107438. /**
  107439. * Sets the angular velocity of the physics body
  107440. * @param impostor imposter to set the velocity on
  107441. * @param velocity velocity to set
  107442. */
  107443. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107444. /**
  107445. * gets the linear velocity
  107446. * @param impostor imposter to get linear velocity from
  107447. * @returns linear velocity
  107448. */
  107449. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107450. /**
  107451. * gets the angular velocity
  107452. * @param impostor imposter to get angular velocity from
  107453. * @returns angular velocity
  107454. */
  107455. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107456. /**
  107457. * Sets the mass of physics body
  107458. * @param impostor imposter to set the mass on
  107459. * @param mass mass to set
  107460. */
  107461. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107462. /**
  107463. * Gets the mass of the physics body
  107464. * @param impostor imposter to get the mass from
  107465. * @returns mass
  107466. */
  107467. getBodyMass(impostor: PhysicsImpostor): number;
  107468. /**
  107469. * Gets friction of the impostor
  107470. * @param impostor impostor to get friction from
  107471. * @returns friction value
  107472. */
  107473. getBodyFriction(impostor: PhysicsImpostor): number;
  107474. /**
  107475. * Sets friction of the impostor
  107476. * @param impostor impostor to set friction on
  107477. * @param friction friction value
  107478. */
  107479. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107480. /**
  107481. * Gets restitution of the impostor
  107482. * @param impostor impostor to get restitution from
  107483. * @returns restitution value
  107484. */
  107485. getBodyRestitution(impostor: PhysicsImpostor): number;
  107486. /**
  107487. * Sets resitution of the impostor
  107488. * @param impostor impostor to set resitution on
  107489. * @param restitution resitution value
  107490. */
  107491. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107492. /**
  107493. * Sleeps the physics body and stops it from being active
  107494. * @param impostor impostor to sleep
  107495. */
  107496. sleepBody(impostor: PhysicsImpostor): void;
  107497. /**
  107498. * Activates the physics body
  107499. * @param impostor impostor to activate
  107500. */
  107501. wakeUpBody(impostor: PhysicsImpostor): void;
  107502. /**
  107503. * Updates the distance parameters of the joint
  107504. * @param joint joint to update
  107505. * @param maxDistance maximum distance of the joint
  107506. * @param minDistance minimum distance of the joint
  107507. */
  107508. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107509. /**
  107510. * Sets a motor on the joint
  107511. * @param joint joint to set motor on
  107512. * @param speed speed of the motor
  107513. * @param maxForce maximum force of the motor
  107514. * @param motorIndex index of the motor
  107515. */
  107516. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107517. /**
  107518. * Sets the motors limit
  107519. * @param joint joint to set limit on
  107520. * @param upperLimit upper limit
  107521. * @param lowerLimit lower limit
  107522. */
  107523. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107524. /**
  107525. * Syncs the position and rotation of a mesh with the impostor
  107526. * @param mesh mesh to sync
  107527. * @param impostor impostor to update the mesh with
  107528. */
  107529. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107530. /**
  107531. * Gets the radius of the impostor
  107532. * @param impostor impostor to get radius from
  107533. * @returns the radius
  107534. */
  107535. getRadius(impostor: PhysicsImpostor): number;
  107536. /**
  107537. * Gets the box size of the impostor
  107538. * @param impostor impostor to get box size from
  107539. * @param result the resulting box size
  107540. */
  107541. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107542. /**
  107543. * Disposes of the impostor
  107544. */
  107545. dispose(): void;
  107546. }
  107547. }
  107548. declare module BABYLON {
  107549. /** @hidden */
  107550. export var blackAndWhitePixelShader: {
  107551. name: string;
  107552. shader: string;
  107553. };
  107554. }
  107555. declare module BABYLON {
  107556. /**
  107557. * Post process used to render in black and white
  107558. */
  107559. export class BlackAndWhitePostProcess extends PostProcess {
  107560. /**
  107561. * Linear about to convert he result to black and white (default: 1)
  107562. */
  107563. degree: number;
  107564. /**
  107565. * Creates a black and white post process
  107566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107567. * @param name The name of the effect.
  107568. * @param options The required width/height ratio to downsize to before computing the render pass.
  107569. * @param camera The camera to apply the render pass to.
  107570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107571. * @param engine The engine which the post process will be applied. (default: current engine)
  107572. * @param reusable If the post process can be reused on the same frame. (default: false)
  107573. */
  107574. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107575. }
  107576. }
  107577. declare module BABYLON {
  107578. /**
  107579. * This represents a set of one or more post processes in Babylon.
  107580. * A post process can be used to apply a shader to a texture after it is rendered.
  107581. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107582. */
  107583. export class PostProcessRenderEffect {
  107584. private _postProcesses;
  107585. private _getPostProcesses;
  107586. private _singleInstance;
  107587. private _cameras;
  107588. private _indicesForCamera;
  107589. /**
  107590. * Name of the effect
  107591. * @hidden
  107592. */
  107593. _name: string;
  107594. /**
  107595. * Instantiates a post process render effect.
  107596. * A post process can be used to apply a shader to a texture after it is rendered.
  107597. * @param engine The engine the effect is tied to
  107598. * @param name The name of the effect
  107599. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  107600. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  107601. */
  107602. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  107603. /**
  107604. * Checks if all the post processes in the effect are supported.
  107605. */
  107606. readonly isSupported: boolean;
  107607. /**
  107608. * Updates the current state of the effect
  107609. * @hidden
  107610. */
  107611. _update(): void;
  107612. /**
  107613. * Attaches the effect on cameras
  107614. * @param cameras The camera to attach to.
  107615. * @hidden
  107616. */
  107617. _attachCameras(cameras: Camera): void;
  107618. /**
  107619. * Attaches the effect on cameras
  107620. * @param cameras The camera to attach to.
  107621. * @hidden
  107622. */
  107623. _attachCameras(cameras: Camera[]): void;
  107624. /**
  107625. * Detatches the effect on cameras
  107626. * @param cameras The camera to detatch from.
  107627. * @hidden
  107628. */
  107629. _detachCameras(cameras: Camera): void;
  107630. /**
  107631. * Detatches the effect on cameras
  107632. * @param cameras The camera to detatch from.
  107633. * @hidden
  107634. */
  107635. _detachCameras(cameras: Camera[]): void;
  107636. /**
  107637. * Enables the effect on given cameras
  107638. * @param cameras The camera to enable.
  107639. * @hidden
  107640. */
  107641. _enable(cameras: Camera): void;
  107642. /**
  107643. * Enables the effect on given cameras
  107644. * @param cameras The camera to enable.
  107645. * @hidden
  107646. */
  107647. _enable(cameras: Nullable<Camera[]>): void;
  107648. /**
  107649. * Disables the effect on the given cameras
  107650. * @param cameras The camera to disable.
  107651. * @hidden
  107652. */
  107653. _disable(cameras: Camera): void;
  107654. /**
  107655. * Disables the effect on the given cameras
  107656. * @param cameras The camera to disable.
  107657. * @hidden
  107658. */
  107659. _disable(cameras: Nullable<Camera[]>): void;
  107660. /**
  107661. * Gets a list of the post processes contained in the effect.
  107662. * @param camera The camera to get the post processes on.
  107663. * @returns The list of the post processes in the effect.
  107664. */
  107665. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  107666. }
  107667. }
  107668. declare module BABYLON {
  107669. /** @hidden */
  107670. export var extractHighlightsPixelShader: {
  107671. name: string;
  107672. shader: string;
  107673. };
  107674. }
  107675. declare module BABYLON {
  107676. /**
  107677. * 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.
  107678. */
  107679. export class ExtractHighlightsPostProcess extends PostProcess {
  107680. /**
  107681. * The luminance threshold, pixels below this value will be set to black.
  107682. */
  107683. threshold: number;
  107684. /** @hidden */
  107685. _exposure: number;
  107686. /**
  107687. * Post process which has the input texture to be used when performing highlight extraction
  107688. * @hidden
  107689. */
  107690. _inputPostProcess: Nullable<PostProcess>;
  107691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107692. }
  107693. }
  107694. declare module BABYLON {
  107695. /** @hidden */
  107696. export var bloomMergePixelShader: {
  107697. name: string;
  107698. shader: string;
  107699. };
  107700. }
  107701. declare module BABYLON {
  107702. /**
  107703. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107704. */
  107705. export class BloomMergePostProcess extends PostProcess {
  107706. /** Weight of the bloom to be added to the original input. */
  107707. weight: number;
  107708. /**
  107709. * Creates a new instance of @see BloomMergePostProcess
  107710. * @param name The name of the effect.
  107711. * @param originalFromInput Post process which's input will be used for the merge.
  107712. * @param blurred Blurred highlights post process which's output will be used.
  107713. * @param weight Weight of the bloom to be added to the original input.
  107714. * @param options The required width/height ratio to downsize to before computing the render pass.
  107715. * @param camera The camera to apply the render pass to.
  107716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107717. * @param engine The engine which the post process will be applied. (default: current engine)
  107718. * @param reusable If the post process can be reused on the same frame. (default: false)
  107719. * @param textureType Type of textures used when performing the post process. (default: 0)
  107720. * @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)
  107721. */
  107722. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  107723. /** Weight of the bloom to be added to the original input. */
  107724. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107725. }
  107726. }
  107727. declare module BABYLON {
  107728. /**
  107729. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  107730. */
  107731. export class BloomEffect extends PostProcessRenderEffect {
  107732. private bloomScale;
  107733. /**
  107734. * @hidden Internal
  107735. */
  107736. _effects: Array<PostProcess>;
  107737. /**
  107738. * @hidden Internal
  107739. */
  107740. _downscale: ExtractHighlightsPostProcess;
  107741. private _blurX;
  107742. private _blurY;
  107743. private _merge;
  107744. /**
  107745. * The luminance threshold to find bright areas of the image to bloom.
  107746. */
  107747. threshold: number;
  107748. /**
  107749. * The strength of the bloom.
  107750. */
  107751. weight: number;
  107752. /**
  107753. * Specifies the size of the bloom blur kernel, relative to the final output size
  107754. */
  107755. kernel: number;
  107756. /**
  107757. * Creates a new instance of @see BloomEffect
  107758. * @param scene The scene the effect belongs to.
  107759. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  107760. * @param bloomKernel The size of the kernel to be used when applying the blur.
  107761. * @param bloomWeight The the strength of bloom.
  107762. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107763. * @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)
  107764. */
  107765. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  107766. /**
  107767. * Disposes each of the internal effects for a given camera.
  107768. * @param camera The camera to dispose the effect on.
  107769. */
  107770. disposeEffects(camera: Camera): void;
  107771. /**
  107772. * @hidden Internal
  107773. */
  107774. _updateEffects(): void;
  107775. /**
  107776. * Internal
  107777. * @returns if all the contained post processes are ready.
  107778. * @hidden
  107779. */
  107780. _isReady(): boolean;
  107781. }
  107782. }
  107783. declare module BABYLON {
  107784. /** @hidden */
  107785. export var chromaticAberrationPixelShader: {
  107786. name: string;
  107787. shader: string;
  107788. };
  107789. }
  107790. declare module BABYLON {
  107791. /**
  107792. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  107793. */
  107794. export class ChromaticAberrationPostProcess extends PostProcess {
  107795. /**
  107796. * The amount of seperation of rgb channels (default: 30)
  107797. */
  107798. aberrationAmount: number;
  107799. /**
  107800. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  107801. */
  107802. radialIntensity: number;
  107803. /**
  107804. * 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))
  107805. */
  107806. direction: Vector2;
  107807. /**
  107808. * 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))
  107809. */
  107810. centerPosition: Vector2;
  107811. /**
  107812. * Creates a new instance ChromaticAberrationPostProcess
  107813. * @param name The name of the effect.
  107814. * @param screenWidth The width of the screen to apply the effect on.
  107815. * @param screenHeight The height of the screen to apply the effect on.
  107816. * @param options The required width/height ratio to downsize to before computing the render pass.
  107817. * @param camera The camera to apply the render pass to.
  107818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107819. * @param engine The engine which the post process will be applied. (default: current engine)
  107820. * @param reusable If the post process can be reused on the same frame. (default: false)
  107821. * @param textureType Type of textures used when performing the post process. (default: 0)
  107822. * @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)
  107823. */
  107824. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107825. }
  107826. }
  107827. declare module BABYLON {
  107828. /** @hidden */
  107829. export var circleOfConfusionPixelShader: {
  107830. name: string;
  107831. shader: string;
  107832. };
  107833. }
  107834. declare module BABYLON {
  107835. /**
  107836. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  107837. */
  107838. export class CircleOfConfusionPostProcess extends PostProcess {
  107839. /**
  107840. * 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.
  107841. */
  107842. lensSize: number;
  107843. /**
  107844. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107845. */
  107846. fStop: number;
  107847. /**
  107848. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107849. */
  107850. focusDistance: number;
  107851. /**
  107852. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  107853. */
  107854. focalLength: number;
  107855. private _depthTexture;
  107856. /**
  107857. * Creates a new instance CircleOfConfusionPostProcess
  107858. * @param name The name of the effect.
  107859. * @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.
  107860. * @param options The required width/height ratio to downsize to before computing the render pass.
  107861. * @param camera The camera to apply the render pass to.
  107862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107863. * @param engine The engine which the post process will be applied. (default: current engine)
  107864. * @param reusable If the post process can be reused on the same frame. (default: false)
  107865. * @param textureType Type of textures used when performing the post process. (default: 0)
  107866. * @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)
  107867. */
  107868. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107869. /**
  107870. * 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.
  107871. */
  107872. depthTexture: RenderTargetTexture;
  107873. }
  107874. }
  107875. declare module BABYLON {
  107876. /** @hidden */
  107877. export var colorCorrectionPixelShader: {
  107878. name: string;
  107879. shader: string;
  107880. };
  107881. }
  107882. declare module BABYLON {
  107883. /**
  107884. *
  107885. * This post-process allows the modification of rendered colors by using
  107886. * a 'look-up table' (LUT). This effect is also called Color Grading.
  107887. *
  107888. * The object needs to be provided an url to a texture containing the color
  107889. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  107890. * Use an image editing software to tweak the LUT to match your needs.
  107891. *
  107892. * For an example of a color LUT, see here:
  107893. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  107894. * For explanations on color grading, see here:
  107895. * @see http://udn.epicgames.com/Three/ColorGrading.html
  107896. *
  107897. */
  107898. export class ColorCorrectionPostProcess extends PostProcess {
  107899. private _colorTableTexture;
  107900. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107901. }
  107902. }
  107903. declare module BABYLON {
  107904. /** @hidden */
  107905. export var convolutionPixelShader: {
  107906. name: string;
  107907. shader: string;
  107908. };
  107909. }
  107910. declare module BABYLON {
  107911. /**
  107912. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  107913. * input texture to perform effects such as edge detection or sharpening
  107914. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107915. */
  107916. export class ConvolutionPostProcess extends PostProcess {
  107917. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107918. kernel: number[];
  107919. /**
  107920. * Creates a new instance ConvolutionPostProcess
  107921. * @param name The name of the effect.
  107922. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107923. * @param options The required width/height ratio to downsize to before computing the render pass.
  107924. * @param camera The camera to apply the render pass to.
  107925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107926. * @param engine The engine which the post process will be applied. (default: current engine)
  107927. * @param reusable If the post process can be reused on the same frame. (default: false)
  107928. * @param textureType Type of textures used when performing the post process. (default: 0)
  107929. */
  107930. constructor(name: string,
  107931. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107932. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107933. /**
  107934. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107935. */
  107936. static EdgeDetect0Kernel: number[];
  107937. /**
  107938. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107939. */
  107940. static EdgeDetect1Kernel: number[];
  107941. /**
  107942. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107943. */
  107944. static EdgeDetect2Kernel: number[];
  107945. /**
  107946. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107947. */
  107948. static SharpenKernel: number[];
  107949. /**
  107950. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107951. */
  107952. static EmbossKernel: number[];
  107953. /**
  107954. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107955. */
  107956. static GaussianKernel: number[];
  107957. }
  107958. }
  107959. declare module BABYLON {
  107960. /**
  107961. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107962. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107963. * based on samples that have a large difference in distance than the center pixel.
  107964. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107965. */
  107966. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107967. direction: Vector2;
  107968. /**
  107969. * Creates a new instance CircleOfConfusionPostProcess
  107970. * @param name The name of the effect.
  107971. * @param scene The scene the effect belongs to.
  107972. * @param direction The direction the blur should be applied.
  107973. * @param kernel The size of the kernel used to blur.
  107974. * @param options The required width/height ratio to downsize to before computing the render pass.
  107975. * @param camera The camera to apply the render pass to.
  107976. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107977. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107979. * @param engine The engine which the post process will be applied. (default: current engine)
  107980. * @param reusable If the post process can be reused on the same frame. (default: false)
  107981. * @param textureType Type of textures used when performing the post process. (default: 0)
  107982. * @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)
  107983. */
  107984. 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);
  107985. }
  107986. }
  107987. declare module BABYLON {
  107988. /** @hidden */
  107989. export var depthOfFieldMergePixelShader: {
  107990. name: string;
  107991. shader: string;
  107992. };
  107993. }
  107994. declare module BABYLON {
  107995. /**
  107996. * Options to be set when merging outputs from the default pipeline.
  107997. */
  107998. export class DepthOfFieldMergePostProcessOptions {
  107999. /**
  108000. * The original image to merge on top of
  108001. */
  108002. originalFromInput: PostProcess;
  108003. /**
  108004. * Parameters to perform the merge of the depth of field effect
  108005. */
  108006. depthOfField?: {
  108007. circleOfConfusion: PostProcess;
  108008. blurSteps: Array<PostProcess>;
  108009. };
  108010. /**
  108011. * Parameters to perform the merge of bloom effect
  108012. */
  108013. bloom?: {
  108014. blurred: PostProcess;
  108015. weight: number;
  108016. };
  108017. }
  108018. /**
  108019. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108020. */
  108021. export class DepthOfFieldMergePostProcess extends PostProcess {
  108022. private blurSteps;
  108023. /**
  108024. * Creates a new instance of DepthOfFieldMergePostProcess
  108025. * @param name The name of the effect.
  108026. * @param originalFromInput Post process which's input will be used for the merge.
  108027. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108028. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108029. * @param options The required width/height ratio to downsize to before computing the render pass.
  108030. * @param camera The camera to apply the render pass to.
  108031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108032. * @param engine The engine which the post process will be applied. (default: current engine)
  108033. * @param reusable If the post process can be reused on the same frame. (default: false)
  108034. * @param textureType Type of textures used when performing the post process. (default: 0)
  108035. * @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)
  108036. */
  108037. 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);
  108038. /**
  108039. * Updates the effect with the current post process compile time values and recompiles the shader.
  108040. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108041. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108042. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108043. * @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
  108044. * @param onCompiled Called when the shader has been compiled.
  108045. * @param onError Called if there is an error when compiling a shader.
  108046. */
  108047. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108048. }
  108049. }
  108050. declare module BABYLON {
  108051. /**
  108052. * Specifies the level of max blur that should be applied when using the depth of field effect
  108053. */
  108054. export enum DepthOfFieldEffectBlurLevel {
  108055. /**
  108056. * Subtle blur
  108057. */
  108058. Low = 0,
  108059. /**
  108060. * Medium blur
  108061. */
  108062. Medium = 1,
  108063. /**
  108064. * Large blur
  108065. */
  108066. High = 2
  108067. }
  108068. /**
  108069. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108070. */
  108071. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108072. private _circleOfConfusion;
  108073. /**
  108074. * @hidden Internal, blurs from high to low
  108075. */
  108076. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108077. private _depthOfFieldBlurY;
  108078. private _dofMerge;
  108079. /**
  108080. * @hidden Internal post processes in depth of field effect
  108081. */
  108082. _effects: Array<PostProcess>;
  108083. /**
  108084. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108085. */
  108086. focalLength: number;
  108087. /**
  108088. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108089. */
  108090. fStop: number;
  108091. /**
  108092. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108093. */
  108094. focusDistance: number;
  108095. /**
  108096. * 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.
  108097. */
  108098. lensSize: number;
  108099. /**
  108100. * Creates a new instance DepthOfFieldEffect
  108101. * @param scene The scene the effect belongs to.
  108102. * @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.
  108103. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108104. * @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)
  108105. */
  108106. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108107. /**
  108108. * 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.
  108109. */
  108110. depthTexture: RenderTargetTexture;
  108111. /**
  108112. * Disposes each of the internal effects for a given camera.
  108113. * @param camera The camera to dispose the effect on.
  108114. */
  108115. disposeEffects(camera: Camera): void;
  108116. /**
  108117. * @hidden Internal
  108118. */
  108119. _updateEffects(): void;
  108120. /**
  108121. * Internal
  108122. * @returns if all the contained post processes are ready.
  108123. * @hidden
  108124. */
  108125. _isReady(): boolean;
  108126. }
  108127. }
  108128. declare module BABYLON {
  108129. /** @hidden */
  108130. export var displayPassPixelShader: {
  108131. name: string;
  108132. shader: string;
  108133. };
  108134. }
  108135. declare module BABYLON {
  108136. /**
  108137. * DisplayPassPostProcess which produces an output the same as it's input
  108138. */
  108139. export class DisplayPassPostProcess extends PostProcess {
  108140. /**
  108141. * Creates the DisplayPassPostProcess
  108142. * @param name The name of the effect.
  108143. * @param options The required width/height ratio to downsize to before computing the render pass.
  108144. * @param camera The camera to apply the render pass to.
  108145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108146. * @param engine The engine which the post process will be applied. (default: current engine)
  108147. * @param reusable If the post process can be reused on the same frame. (default: false)
  108148. */
  108149. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108150. }
  108151. }
  108152. declare module BABYLON {
  108153. /** @hidden */
  108154. export var filterPixelShader: {
  108155. name: string;
  108156. shader: string;
  108157. };
  108158. }
  108159. declare module BABYLON {
  108160. /**
  108161. * Applies a kernel filter to the image
  108162. */
  108163. export class FilterPostProcess extends PostProcess {
  108164. /** The matrix to be applied to the image */
  108165. kernelMatrix: Matrix;
  108166. /**
  108167. *
  108168. * @param name The name of the effect.
  108169. * @param kernelMatrix The matrix to be applied to the image
  108170. * @param options The required width/height ratio to downsize to before computing the render pass.
  108171. * @param camera The camera to apply the render pass to.
  108172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108173. * @param engine The engine which the post process will be applied. (default: current engine)
  108174. * @param reusable If the post process can be reused on the same frame. (default: false)
  108175. */
  108176. constructor(name: string,
  108177. /** The matrix to be applied to the image */
  108178. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108179. }
  108180. }
  108181. declare module BABYLON {
  108182. /** @hidden */
  108183. export var fxaaPixelShader: {
  108184. name: string;
  108185. shader: string;
  108186. };
  108187. }
  108188. declare module BABYLON {
  108189. /** @hidden */
  108190. export var fxaaVertexShader: {
  108191. name: string;
  108192. shader: string;
  108193. };
  108194. }
  108195. declare module BABYLON {
  108196. /**
  108197. * Fxaa post process
  108198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108199. */
  108200. export class FxaaPostProcess extends PostProcess {
  108201. /** @hidden */
  108202. texelWidth: number;
  108203. /** @hidden */
  108204. texelHeight: number;
  108205. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108206. private _getDefines;
  108207. }
  108208. }
  108209. declare module BABYLON {
  108210. /** @hidden */
  108211. export var grainPixelShader: {
  108212. name: string;
  108213. shader: string;
  108214. };
  108215. }
  108216. declare module BABYLON {
  108217. /**
  108218. * The GrainPostProcess adds noise to the image at mid luminance levels
  108219. */
  108220. export class GrainPostProcess extends PostProcess {
  108221. /**
  108222. * The intensity of the grain added (default: 30)
  108223. */
  108224. intensity: number;
  108225. /**
  108226. * If the grain should be randomized on every frame
  108227. */
  108228. animated: boolean;
  108229. /**
  108230. * Creates a new instance of @see GrainPostProcess
  108231. * @param name The name of the effect.
  108232. * @param options The required width/height ratio to downsize to before computing the render pass.
  108233. * @param camera The camera to apply the render pass to.
  108234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108235. * @param engine The engine which the post process will be applied. (default: current engine)
  108236. * @param reusable If the post process can be reused on the same frame. (default: false)
  108237. * @param textureType Type of textures used when performing the post process. (default: 0)
  108238. * @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)
  108239. */
  108240. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108241. }
  108242. }
  108243. declare module BABYLON {
  108244. /** @hidden */
  108245. export var highlightsPixelShader: {
  108246. name: string;
  108247. shader: string;
  108248. };
  108249. }
  108250. declare module BABYLON {
  108251. /**
  108252. * Extracts highlights from the image
  108253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108254. */
  108255. export class HighlightsPostProcess extends PostProcess {
  108256. /**
  108257. * Extracts highlights from the image
  108258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108259. * @param name The name of the effect.
  108260. * @param options The required width/height ratio to downsize to before computing the render pass.
  108261. * @param camera The camera to apply the render pass to.
  108262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108263. * @param engine The engine which the post process will be applied. (default: current engine)
  108264. * @param reusable If the post process can be reused on the same frame. (default: false)
  108265. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108266. */
  108267. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108268. }
  108269. }
  108270. declare module BABYLON {
  108271. /** @hidden */
  108272. export var mrtFragmentDeclaration: {
  108273. name: string;
  108274. shader: string;
  108275. };
  108276. }
  108277. declare module BABYLON {
  108278. /** @hidden */
  108279. export var geometryPixelShader: {
  108280. name: string;
  108281. shader: string;
  108282. };
  108283. }
  108284. declare module BABYLON {
  108285. /** @hidden */
  108286. export var geometryVertexShader: {
  108287. name: string;
  108288. shader: string;
  108289. };
  108290. }
  108291. declare module BABYLON {
  108292. /**
  108293. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108294. */
  108295. export class GeometryBufferRenderer {
  108296. /**
  108297. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108298. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108299. */
  108300. static readonly POSITION_TEXTURE_TYPE: number;
  108301. /**
  108302. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108303. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108304. */
  108305. static readonly VELOCITY_TEXTURE_TYPE: number;
  108306. /**
  108307. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108308. * in order to compute objects velocities when enableVelocity is set to "true"
  108309. * @hidden
  108310. */
  108311. _previousTransformationMatrices: {
  108312. [index: number]: Matrix;
  108313. };
  108314. private _scene;
  108315. private _multiRenderTarget;
  108316. private _ratio;
  108317. private _enablePosition;
  108318. private _enableVelocity;
  108319. private _positionIndex;
  108320. private _velocityIndex;
  108321. protected _effect: Effect;
  108322. protected _cachedDefines: string;
  108323. /**
  108324. * Set the render list (meshes to be rendered) used in the G buffer.
  108325. */
  108326. renderList: Mesh[];
  108327. /**
  108328. * Gets wether or not G buffer are supported by the running hardware.
  108329. * This requires draw buffer supports
  108330. */
  108331. readonly isSupported: boolean;
  108332. /**
  108333. * Returns the index of the given texture type in the G-Buffer textures array
  108334. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108335. * @returns the index of the given texture type in the G-Buffer textures array
  108336. */
  108337. getTextureIndex(textureType: number): number;
  108338. /**
  108339. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108340. */
  108341. /**
  108342. * Sets whether or not objects positions are enabled for the G buffer.
  108343. */
  108344. enablePosition: boolean;
  108345. /**
  108346. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108347. */
  108348. /**
  108349. * Sets wether or not objects velocities are enabled for the G buffer.
  108350. */
  108351. enableVelocity: boolean;
  108352. /**
  108353. * Gets the scene associated with the buffer.
  108354. */
  108355. readonly scene: Scene;
  108356. /**
  108357. * Gets the ratio used by the buffer during its creation.
  108358. * How big is the buffer related to the main canvas.
  108359. */
  108360. readonly ratio: number;
  108361. /** @hidden */
  108362. static _SceneComponentInitialization: (scene: Scene) => void;
  108363. /**
  108364. * Creates a new G Buffer for the scene
  108365. * @param scene The scene the buffer belongs to
  108366. * @param ratio How big is the buffer related to the main canvas.
  108367. */
  108368. constructor(scene: Scene, ratio?: number);
  108369. /**
  108370. * Checks wether everything is ready to render a submesh to the G buffer.
  108371. * @param subMesh the submesh to check readiness for
  108372. * @param useInstances is the mesh drawn using instance or not
  108373. * @returns true if ready otherwise false
  108374. */
  108375. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108376. /**
  108377. * Gets the current underlying G Buffer.
  108378. * @returns the buffer
  108379. */
  108380. getGBuffer(): MultiRenderTarget;
  108381. /**
  108382. * Gets the number of samples used to render the buffer (anti aliasing).
  108383. */
  108384. /**
  108385. * Sets the number of samples used to render the buffer (anti aliasing).
  108386. */
  108387. samples: number;
  108388. /**
  108389. * Disposes the renderer and frees up associated resources.
  108390. */
  108391. dispose(): void;
  108392. protected _createRenderTargets(): void;
  108393. }
  108394. }
  108395. declare module BABYLON {
  108396. interface Scene {
  108397. /** @hidden (Backing field) */
  108398. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108399. /**
  108400. * Gets or Sets the current geometry buffer associated to the scene.
  108401. */
  108402. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108403. /**
  108404. * Enables a GeometryBufferRender and associates it with the scene
  108405. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108406. * @returns the GeometryBufferRenderer
  108407. */
  108408. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108409. /**
  108410. * Disables the GeometryBufferRender associated with the scene
  108411. */
  108412. disableGeometryBufferRenderer(): void;
  108413. }
  108414. /**
  108415. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108416. * in several rendering techniques.
  108417. */
  108418. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108419. /**
  108420. * The component name helpful to identify the component in the list of scene components.
  108421. */
  108422. readonly name: string;
  108423. /**
  108424. * The scene the component belongs to.
  108425. */
  108426. scene: Scene;
  108427. /**
  108428. * Creates a new instance of the component for the given scene
  108429. * @param scene Defines the scene to register the component in
  108430. */
  108431. constructor(scene: Scene);
  108432. /**
  108433. * Registers the component in a given scene
  108434. */
  108435. register(): void;
  108436. /**
  108437. * Rebuilds the elements related to this component in case of
  108438. * context lost for instance.
  108439. */
  108440. rebuild(): void;
  108441. /**
  108442. * Disposes the component and the associated ressources
  108443. */
  108444. dispose(): void;
  108445. private _gatherRenderTargets;
  108446. }
  108447. }
  108448. declare module BABYLON {
  108449. /** @hidden */
  108450. export var motionBlurPixelShader: {
  108451. name: string;
  108452. shader: string;
  108453. };
  108454. }
  108455. declare module BABYLON {
  108456. /**
  108457. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108458. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108459. * As an example, all you have to do is to create the post-process:
  108460. * var mb = new BABYLON.MotionBlurPostProcess(
  108461. * 'mb', // The name of the effect.
  108462. * scene, // The scene containing the objects to blur according to their velocity.
  108463. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108464. * camera // The camera to apply the render pass to.
  108465. * );
  108466. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108467. */
  108468. export class MotionBlurPostProcess extends PostProcess {
  108469. /**
  108470. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108471. */
  108472. motionStrength: number;
  108473. /**
  108474. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108475. */
  108476. /**
  108477. * Sets the number of iterations to be used for motion blur quality
  108478. */
  108479. motionBlurSamples: number;
  108480. private _motionBlurSamples;
  108481. private _geometryBufferRenderer;
  108482. /**
  108483. * Creates a new instance MotionBlurPostProcess
  108484. * @param name The name of the effect.
  108485. * @param scene The scene containing the objects to blur according to their velocity.
  108486. * @param options The required width/height ratio to downsize to before computing the render pass.
  108487. * @param camera The camera to apply the render pass to.
  108488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108489. * @param engine The engine which the post process will be applied. (default: current engine)
  108490. * @param reusable If the post process can be reused on the same frame. (default: false)
  108491. * @param textureType Type of textures used when performing the post process. (default: 0)
  108492. * @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)
  108493. */
  108494. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108495. /**
  108496. * Disposes the post process.
  108497. * @param camera The camera to dispose the post process on.
  108498. */
  108499. dispose(camera?: Camera): void;
  108500. }
  108501. }
  108502. declare module BABYLON {
  108503. /** @hidden */
  108504. export var refractionPixelShader: {
  108505. name: string;
  108506. shader: string;
  108507. };
  108508. }
  108509. declare module BABYLON {
  108510. /**
  108511. * Post process which applies a refractin texture
  108512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108513. */
  108514. export class RefractionPostProcess extends PostProcess {
  108515. /** the base color of the refraction (used to taint the rendering) */
  108516. color: Color3;
  108517. /** simulated refraction depth */
  108518. depth: number;
  108519. /** the coefficient of the base color (0 to remove base color tainting) */
  108520. colorLevel: number;
  108521. private _refTexture;
  108522. private _ownRefractionTexture;
  108523. /**
  108524. * Gets or sets the refraction texture
  108525. * Please note that you are responsible for disposing the texture if you set it manually
  108526. */
  108527. refractionTexture: Texture;
  108528. /**
  108529. * Initializes the RefractionPostProcess
  108530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108531. * @param name The name of the effect.
  108532. * @param refractionTextureUrl Url of the refraction texture to use
  108533. * @param color the base color of the refraction (used to taint the rendering)
  108534. * @param depth simulated refraction depth
  108535. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108536. * @param camera The camera to apply the render pass to.
  108537. * @param options The required width/height ratio to downsize to before computing the render pass.
  108538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108539. * @param engine The engine which the post process will be applied. (default: current engine)
  108540. * @param reusable If the post process can be reused on the same frame. (default: false)
  108541. */
  108542. constructor(name: string, refractionTextureUrl: string,
  108543. /** the base color of the refraction (used to taint the rendering) */
  108544. color: Color3,
  108545. /** simulated refraction depth */
  108546. depth: number,
  108547. /** the coefficient of the base color (0 to remove base color tainting) */
  108548. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108549. /**
  108550. * Disposes of the post process
  108551. * @param camera Camera to dispose post process on
  108552. */
  108553. dispose(camera: Camera): void;
  108554. }
  108555. }
  108556. declare module BABYLON {
  108557. /** @hidden */
  108558. export var sharpenPixelShader: {
  108559. name: string;
  108560. shader: string;
  108561. };
  108562. }
  108563. declare module BABYLON {
  108564. /**
  108565. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108566. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108567. */
  108568. export class SharpenPostProcess extends PostProcess {
  108569. /**
  108570. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108571. */
  108572. colorAmount: number;
  108573. /**
  108574. * How much sharpness should be applied (default: 0.3)
  108575. */
  108576. edgeAmount: number;
  108577. /**
  108578. * Creates a new instance ConvolutionPostProcess
  108579. * @param name The name of the effect.
  108580. * @param options The required width/height ratio to downsize to before computing the render pass.
  108581. * @param camera The camera to apply the render pass to.
  108582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108583. * @param engine The engine which the post process will be applied. (default: current engine)
  108584. * @param reusable If the post process can be reused on the same frame. (default: false)
  108585. * @param textureType Type of textures used when performing the post process. (default: 0)
  108586. * @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)
  108587. */
  108588. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108589. }
  108590. }
  108591. declare module BABYLON {
  108592. /**
  108593. * PostProcessRenderPipeline
  108594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108595. */
  108596. export class PostProcessRenderPipeline {
  108597. private engine;
  108598. private _renderEffects;
  108599. private _renderEffectsForIsolatedPass;
  108600. /**
  108601. * @hidden
  108602. */
  108603. protected _cameras: Camera[];
  108604. /** @hidden */
  108605. _name: string;
  108606. /**
  108607. * Gets pipeline name
  108608. */
  108609. readonly name: string;
  108610. /**
  108611. * Initializes a PostProcessRenderPipeline
  108612. * @param engine engine to add the pipeline to
  108613. * @param name name of the pipeline
  108614. */
  108615. constructor(engine: Engine, name: string);
  108616. /**
  108617. * Gets the class name
  108618. * @returns "PostProcessRenderPipeline"
  108619. */
  108620. getClassName(): string;
  108621. /**
  108622. * If all the render effects in the pipeline are supported
  108623. */
  108624. readonly isSupported: boolean;
  108625. /**
  108626. * Adds an effect to the pipeline
  108627. * @param renderEffect the effect to add
  108628. */
  108629. addEffect(renderEffect: PostProcessRenderEffect): void;
  108630. /** @hidden */
  108631. _rebuild(): void;
  108632. /** @hidden */
  108633. _enableEffect(renderEffectName: string, cameras: Camera): void;
  108634. /** @hidden */
  108635. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  108636. /** @hidden */
  108637. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108638. /** @hidden */
  108639. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108640. /** @hidden */
  108641. _attachCameras(cameras: Camera, unique: boolean): void;
  108642. /** @hidden */
  108643. _attachCameras(cameras: Camera[], unique: boolean): void;
  108644. /** @hidden */
  108645. _detachCameras(cameras: Camera): void;
  108646. /** @hidden */
  108647. _detachCameras(cameras: Nullable<Camera[]>): void;
  108648. /** @hidden */
  108649. _update(): void;
  108650. /** @hidden */
  108651. _reset(): void;
  108652. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  108653. /**
  108654. * Disposes of the pipeline
  108655. */
  108656. dispose(): void;
  108657. }
  108658. }
  108659. declare module BABYLON {
  108660. /**
  108661. * PostProcessRenderPipelineManager class
  108662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108663. */
  108664. export class PostProcessRenderPipelineManager {
  108665. private _renderPipelines;
  108666. /**
  108667. * Initializes a PostProcessRenderPipelineManager
  108668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108669. */
  108670. constructor();
  108671. /**
  108672. * Gets the list of supported render pipelines
  108673. */
  108674. readonly supportedPipelines: PostProcessRenderPipeline[];
  108675. /**
  108676. * Adds a pipeline to the manager
  108677. * @param renderPipeline The pipeline to add
  108678. */
  108679. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  108680. /**
  108681. * Attaches a camera to the pipeline
  108682. * @param renderPipelineName The name of the pipeline to attach to
  108683. * @param cameras the camera to attach
  108684. * @param unique if the camera can be attached multiple times to the pipeline
  108685. */
  108686. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  108687. /**
  108688. * Detaches a camera from the pipeline
  108689. * @param renderPipelineName The name of the pipeline to detach from
  108690. * @param cameras the camera to detach
  108691. */
  108692. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  108693. /**
  108694. * Enables an effect by name on a pipeline
  108695. * @param renderPipelineName the name of the pipeline to enable the effect in
  108696. * @param renderEffectName the name of the effect to enable
  108697. * @param cameras the cameras that the effect should be enabled on
  108698. */
  108699. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108700. /**
  108701. * Disables an effect by name on a pipeline
  108702. * @param renderPipelineName the name of the pipeline to disable the effect in
  108703. * @param renderEffectName the name of the effect to disable
  108704. * @param cameras the cameras that the effect should be disabled on
  108705. */
  108706. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108707. /**
  108708. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  108709. */
  108710. update(): void;
  108711. /** @hidden */
  108712. _rebuild(): void;
  108713. /**
  108714. * Disposes of the manager and pipelines
  108715. */
  108716. dispose(): void;
  108717. }
  108718. }
  108719. declare module BABYLON {
  108720. interface Scene {
  108721. /** @hidden (Backing field) */
  108722. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108723. /**
  108724. * Gets the postprocess render pipeline manager
  108725. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108726. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108727. */
  108728. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108729. }
  108730. /**
  108731. * Defines the Render Pipeline scene component responsible to rendering pipelines
  108732. */
  108733. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  108734. /**
  108735. * The component name helpfull to identify the component in the list of scene components.
  108736. */
  108737. readonly name: string;
  108738. /**
  108739. * The scene the component belongs to.
  108740. */
  108741. scene: Scene;
  108742. /**
  108743. * Creates a new instance of the component for the given scene
  108744. * @param scene Defines the scene to register the component in
  108745. */
  108746. constructor(scene: Scene);
  108747. /**
  108748. * Registers the component in a given scene
  108749. */
  108750. register(): void;
  108751. /**
  108752. * Rebuilds the elements related to this component in case of
  108753. * context lost for instance.
  108754. */
  108755. rebuild(): void;
  108756. /**
  108757. * Disposes the component and the associated ressources
  108758. */
  108759. dispose(): void;
  108760. private _gatherRenderTargets;
  108761. }
  108762. }
  108763. declare module BABYLON {
  108764. /**
  108765. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  108766. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108767. */
  108768. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108769. private _scene;
  108770. private _camerasToBeAttached;
  108771. /**
  108772. * ID of the sharpen post process,
  108773. */
  108774. private readonly SharpenPostProcessId;
  108775. /**
  108776. * @ignore
  108777. * ID of the image processing post process;
  108778. */
  108779. readonly ImageProcessingPostProcessId: string;
  108780. /**
  108781. * @ignore
  108782. * ID of the Fast Approximate Anti-Aliasing post process;
  108783. */
  108784. readonly FxaaPostProcessId: string;
  108785. /**
  108786. * ID of the chromatic aberration post process,
  108787. */
  108788. private readonly ChromaticAberrationPostProcessId;
  108789. /**
  108790. * ID of the grain post process
  108791. */
  108792. private readonly GrainPostProcessId;
  108793. /**
  108794. * Sharpen post process which will apply a sharpen convolution to enhance edges
  108795. */
  108796. sharpen: SharpenPostProcess;
  108797. private _sharpenEffect;
  108798. private bloom;
  108799. /**
  108800. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  108801. */
  108802. depthOfField: DepthOfFieldEffect;
  108803. /**
  108804. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108805. */
  108806. fxaa: FxaaPostProcess;
  108807. /**
  108808. * Image post processing pass used to perform operations such as tone mapping or color grading.
  108809. */
  108810. imageProcessing: ImageProcessingPostProcess;
  108811. /**
  108812. * Chromatic aberration post process which will shift rgb colors in the image
  108813. */
  108814. chromaticAberration: ChromaticAberrationPostProcess;
  108815. private _chromaticAberrationEffect;
  108816. /**
  108817. * Grain post process which add noise to the image
  108818. */
  108819. grain: GrainPostProcess;
  108820. private _grainEffect;
  108821. /**
  108822. * Glow post process which adds a glow to emissive areas of the image
  108823. */
  108824. private _glowLayer;
  108825. /**
  108826. * Animations which can be used to tweak settings over a period of time
  108827. */
  108828. animations: Animation[];
  108829. private _imageProcessingConfigurationObserver;
  108830. private _sharpenEnabled;
  108831. private _bloomEnabled;
  108832. private _depthOfFieldEnabled;
  108833. private _depthOfFieldBlurLevel;
  108834. private _fxaaEnabled;
  108835. private _imageProcessingEnabled;
  108836. private _defaultPipelineTextureType;
  108837. private _bloomScale;
  108838. private _chromaticAberrationEnabled;
  108839. private _grainEnabled;
  108840. private _buildAllowed;
  108841. /**
  108842. * Gets active scene
  108843. */
  108844. readonly scene: Scene;
  108845. /**
  108846. * Enable or disable the sharpen process from the pipeline
  108847. */
  108848. sharpenEnabled: boolean;
  108849. private _resizeObserver;
  108850. private _hardwareScaleLevel;
  108851. private _bloomKernel;
  108852. /**
  108853. * Specifies the size of the bloom blur kernel, relative to the final output size
  108854. */
  108855. bloomKernel: number;
  108856. /**
  108857. * Specifies the weight of the bloom in the final rendering
  108858. */
  108859. private _bloomWeight;
  108860. /**
  108861. * Specifies the luma threshold for the area that will be blurred by the bloom
  108862. */
  108863. private _bloomThreshold;
  108864. private _hdr;
  108865. /**
  108866. * The strength of the bloom.
  108867. */
  108868. bloomWeight: number;
  108869. /**
  108870. * The strength of the bloom.
  108871. */
  108872. bloomThreshold: number;
  108873. /**
  108874. * The scale of the bloom, lower value will provide better performance.
  108875. */
  108876. bloomScale: number;
  108877. /**
  108878. * Enable or disable the bloom from the pipeline
  108879. */
  108880. bloomEnabled: boolean;
  108881. private _rebuildBloom;
  108882. /**
  108883. * If the depth of field is enabled.
  108884. */
  108885. depthOfFieldEnabled: boolean;
  108886. /**
  108887. * Blur level of the depth of field effect. (Higher blur will effect performance)
  108888. */
  108889. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  108890. /**
  108891. * If the anti aliasing is enabled.
  108892. */
  108893. fxaaEnabled: boolean;
  108894. private _samples;
  108895. /**
  108896. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108897. */
  108898. samples: number;
  108899. /**
  108900. * If image processing is enabled.
  108901. */
  108902. imageProcessingEnabled: boolean;
  108903. /**
  108904. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  108905. */
  108906. glowLayerEnabled: boolean;
  108907. /**
  108908. * Enable or disable the chromaticAberration process from the pipeline
  108909. */
  108910. chromaticAberrationEnabled: boolean;
  108911. /**
  108912. * Enable or disable the grain process from the pipeline
  108913. */
  108914. grainEnabled: boolean;
  108915. /**
  108916. * @constructor
  108917. * @param name - The rendering pipeline name (default: "")
  108918. * @param hdr - If high dynamic range textures should be used (default: true)
  108919. * @param scene - The scene linked to this pipeline (default: the last created scene)
  108920. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  108921. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  108922. */
  108923. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  108924. /**
  108925. * Get the class name
  108926. * @returns "DefaultRenderingPipeline"
  108927. */
  108928. getClassName(): string;
  108929. /**
  108930. * Force the compilation of the entire pipeline.
  108931. */
  108932. prepare(): void;
  108933. private _hasCleared;
  108934. private _prevPostProcess;
  108935. private _prevPrevPostProcess;
  108936. private _setAutoClearAndTextureSharing;
  108937. private _depthOfFieldSceneObserver;
  108938. private _buildPipeline;
  108939. private _disposePostProcesses;
  108940. /**
  108941. * Adds a camera to the pipeline
  108942. * @param camera the camera to be added
  108943. */
  108944. addCamera(camera: Camera): void;
  108945. /**
  108946. * Removes a camera from the pipeline
  108947. * @param camera the camera to remove
  108948. */
  108949. removeCamera(camera: Camera): void;
  108950. /**
  108951. * Dispose of the pipeline and stop all post processes
  108952. */
  108953. dispose(): void;
  108954. /**
  108955. * Serialize the rendering pipeline (Used when exporting)
  108956. * @returns the serialized object
  108957. */
  108958. serialize(): any;
  108959. /**
  108960. * Parse the serialized pipeline
  108961. * @param source Source pipeline.
  108962. * @param scene The scene to load the pipeline to.
  108963. * @param rootUrl The URL of the serialized pipeline.
  108964. * @returns An instantiated pipeline from the serialized object.
  108965. */
  108966. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  108967. }
  108968. }
  108969. declare module BABYLON {
  108970. /** @hidden */
  108971. export var lensHighlightsPixelShader: {
  108972. name: string;
  108973. shader: string;
  108974. };
  108975. }
  108976. declare module BABYLON {
  108977. /** @hidden */
  108978. export var depthOfFieldPixelShader: {
  108979. name: string;
  108980. shader: string;
  108981. };
  108982. }
  108983. declare module BABYLON {
  108984. /**
  108985. * BABYLON.JS Chromatic Aberration GLSL Shader
  108986. * Author: Olivier Guyot
  108987. * Separates very slightly R, G and B colors on the edges of the screen
  108988. * Inspired by Francois Tarlier & Martins Upitis
  108989. */
  108990. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  108991. /**
  108992. * @ignore
  108993. * The chromatic aberration PostProcess id in the pipeline
  108994. */
  108995. LensChromaticAberrationEffect: string;
  108996. /**
  108997. * @ignore
  108998. * The highlights enhancing PostProcess id in the pipeline
  108999. */
  109000. HighlightsEnhancingEffect: string;
  109001. /**
  109002. * @ignore
  109003. * The depth-of-field PostProcess id in the pipeline
  109004. */
  109005. LensDepthOfFieldEffect: string;
  109006. private _scene;
  109007. private _depthTexture;
  109008. private _grainTexture;
  109009. private _chromaticAberrationPostProcess;
  109010. private _highlightsPostProcess;
  109011. private _depthOfFieldPostProcess;
  109012. private _edgeBlur;
  109013. private _grainAmount;
  109014. private _chromaticAberration;
  109015. private _distortion;
  109016. private _highlightsGain;
  109017. private _highlightsThreshold;
  109018. private _dofDistance;
  109019. private _dofAperture;
  109020. private _dofDarken;
  109021. private _dofPentagon;
  109022. private _blurNoise;
  109023. /**
  109024. * @constructor
  109025. *
  109026. * Effect parameters are as follow:
  109027. * {
  109028. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109029. * edge_blur: number; // from 0 to x (1 for realism)
  109030. * distortion: number; // from 0 to x (1 for realism)
  109031. * grain_amount: number; // from 0 to 1
  109032. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109033. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109034. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109035. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109036. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109037. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109038. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109039. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109040. * }
  109041. * Note: if an effect parameter is unset, effect is disabled
  109042. *
  109043. * @param name The rendering pipeline name
  109044. * @param parameters - An object containing all parameters (see above)
  109045. * @param scene The scene linked to this pipeline
  109046. * @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)
  109047. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109048. */
  109049. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109050. /**
  109051. * Sets the amount of blur at the edges
  109052. * @param amount blur amount
  109053. */
  109054. setEdgeBlur(amount: number): void;
  109055. /**
  109056. * Sets edge blur to 0
  109057. */
  109058. disableEdgeBlur(): void;
  109059. /**
  109060. * Sets the amout of grain
  109061. * @param amount Amount of grain
  109062. */
  109063. setGrainAmount(amount: number): void;
  109064. /**
  109065. * Set grain amount to 0
  109066. */
  109067. disableGrain(): void;
  109068. /**
  109069. * Sets the chromatic aberration amount
  109070. * @param amount amount of chromatic aberration
  109071. */
  109072. setChromaticAberration(amount: number): void;
  109073. /**
  109074. * Sets chromatic aberration amount to 0
  109075. */
  109076. disableChromaticAberration(): void;
  109077. /**
  109078. * Sets the EdgeDistortion amount
  109079. * @param amount amount of EdgeDistortion
  109080. */
  109081. setEdgeDistortion(amount: number): void;
  109082. /**
  109083. * Sets edge distortion to 0
  109084. */
  109085. disableEdgeDistortion(): void;
  109086. /**
  109087. * Sets the FocusDistance amount
  109088. * @param amount amount of FocusDistance
  109089. */
  109090. setFocusDistance(amount: number): void;
  109091. /**
  109092. * Disables depth of field
  109093. */
  109094. disableDepthOfField(): void;
  109095. /**
  109096. * Sets the Aperture amount
  109097. * @param amount amount of Aperture
  109098. */
  109099. setAperture(amount: number): void;
  109100. /**
  109101. * Sets the DarkenOutOfFocus amount
  109102. * @param amount amount of DarkenOutOfFocus
  109103. */
  109104. setDarkenOutOfFocus(amount: number): void;
  109105. /**
  109106. * Creates a pentagon bokeh effect
  109107. */
  109108. enablePentagonBokeh(): void;
  109109. /**
  109110. * Disables the pentagon bokeh effect
  109111. */
  109112. disablePentagonBokeh(): void;
  109113. /**
  109114. * Enables noise blur
  109115. */
  109116. enableNoiseBlur(): void;
  109117. /**
  109118. * Disables noise blur
  109119. */
  109120. disableNoiseBlur(): void;
  109121. /**
  109122. * Sets the HighlightsGain amount
  109123. * @param amount amount of HighlightsGain
  109124. */
  109125. setHighlightsGain(amount: number): void;
  109126. /**
  109127. * Sets the HighlightsThreshold amount
  109128. * @param amount amount of HighlightsThreshold
  109129. */
  109130. setHighlightsThreshold(amount: number): void;
  109131. /**
  109132. * Disables highlights
  109133. */
  109134. disableHighlights(): void;
  109135. /**
  109136. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109137. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109138. */
  109139. dispose(disableDepthRender?: boolean): void;
  109140. private _createChromaticAberrationPostProcess;
  109141. private _createHighlightsPostProcess;
  109142. private _createDepthOfFieldPostProcess;
  109143. private _createGrainTexture;
  109144. }
  109145. }
  109146. declare module BABYLON {
  109147. /** @hidden */
  109148. export var ssao2PixelShader: {
  109149. name: string;
  109150. shader: string;
  109151. };
  109152. }
  109153. declare module BABYLON {
  109154. /** @hidden */
  109155. export var ssaoCombinePixelShader: {
  109156. name: string;
  109157. shader: string;
  109158. };
  109159. }
  109160. declare module BABYLON {
  109161. /**
  109162. * Render pipeline to produce ssao effect
  109163. */
  109164. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109165. /**
  109166. * @ignore
  109167. * The PassPostProcess id in the pipeline that contains the original scene color
  109168. */
  109169. SSAOOriginalSceneColorEffect: string;
  109170. /**
  109171. * @ignore
  109172. * The SSAO PostProcess id in the pipeline
  109173. */
  109174. SSAORenderEffect: string;
  109175. /**
  109176. * @ignore
  109177. * The horizontal blur PostProcess id in the pipeline
  109178. */
  109179. SSAOBlurHRenderEffect: string;
  109180. /**
  109181. * @ignore
  109182. * The vertical blur PostProcess id in the pipeline
  109183. */
  109184. SSAOBlurVRenderEffect: string;
  109185. /**
  109186. * @ignore
  109187. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109188. */
  109189. SSAOCombineRenderEffect: string;
  109190. /**
  109191. * The output strength of the SSAO post-process. Default value is 1.0.
  109192. */
  109193. totalStrength: number;
  109194. /**
  109195. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109196. */
  109197. maxZ: number;
  109198. /**
  109199. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109200. */
  109201. minZAspect: number;
  109202. private _samples;
  109203. /**
  109204. * Number of samples used for the SSAO calculations. Default value is 8
  109205. */
  109206. samples: number;
  109207. private _textureSamples;
  109208. /**
  109209. * Number of samples to use for antialiasing
  109210. */
  109211. textureSamples: number;
  109212. /**
  109213. * Ratio object used for SSAO ratio and blur ratio
  109214. */
  109215. private _ratio;
  109216. /**
  109217. * Dynamically generated sphere sampler.
  109218. */
  109219. private _sampleSphere;
  109220. /**
  109221. * Blur filter offsets
  109222. */
  109223. private _samplerOffsets;
  109224. private _expensiveBlur;
  109225. /**
  109226. * If bilateral blur should be used
  109227. */
  109228. expensiveBlur: boolean;
  109229. /**
  109230. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109231. */
  109232. radius: number;
  109233. /**
  109234. * The base color of the SSAO post-process
  109235. * The final result is "base + ssao" between [0, 1]
  109236. */
  109237. base: number;
  109238. /**
  109239. * Support test.
  109240. */
  109241. static readonly IsSupported: boolean;
  109242. private _scene;
  109243. private _depthTexture;
  109244. private _normalTexture;
  109245. private _randomTexture;
  109246. private _originalColorPostProcess;
  109247. private _ssaoPostProcess;
  109248. private _blurHPostProcess;
  109249. private _blurVPostProcess;
  109250. private _ssaoCombinePostProcess;
  109251. private _firstUpdate;
  109252. /**
  109253. * Gets active scene
  109254. */
  109255. readonly scene: Scene;
  109256. /**
  109257. * @constructor
  109258. * @param name The rendering pipeline name
  109259. * @param scene The scene linked to this pipeline
  109260. * @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 }
  109261. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109262. */
  109263. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109264. /**
  109265. * Get the class name
  109266. * @returns "SSAO2RenderingPipeline"
  109267. */
  109268. getClassName(): string;
  109269. /**
  109270. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109271. */
  109272. dispose(disableGeometryBufferRenderer?: boolean): void;
  109273. private _createBlurPostProcess;
  109274. /** @hidden */
  109275. _rebuild(): void;
  109276. private _bits;
  109277. private _radicalInverse_VdC;
  109278. private _hammersley;
  109279. private _hemisphereSample_uniform;
  109280. private _generateHemisphere;
  109281. private _createSSAOPostProcess;
  109282. private _createSSAOCombinePostProcess;
  109283. private _createRandomTexture;
  109284. /**
  109285. * Serialize the rendering pipeline (Used when exporting)
  109286. * @returns the serialized object
  109287. */
  109288. serialize(): any;
  109289. /**
  109290. * Parse the serialized pipeline
  109291. * @param source Source pipeline.
  109292. * @param scene The scene to load the pipeline to.
  109293. * @param rootUrl The URL of the serialized pipeline.
  109294. * @returns An instantiated pipeline from the serialized object.
  109295. */
  109296. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109297. }
  109298. }
  109299. declare module BABYLON {
  109300. /** @hidden */
  109301. export var ssaoPixelShader: {
  109302. name: string;
  109303. shader: string;
  109304. };
  109305. }
  109306. declare module BABYLON {
  109307. /**
  109308. * Render pipeline to produce ssao effect
  109309. */
  109310. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109311. /**
  109312. * @ignore
  109313. * The PassPostProcess id in the pipeline that contains the original scene color
  109314. */
  109315. SSAOOriginalSceneColorEffect: string;
  109316. /**
  109317. * @ignore
  109318. * The SSAO PostProcess id in the pipeline
  109319. */
  109320. SSAORenderEffect: string;
  109321. /**
  109322. * @ignore
  109323. * The horizontal blur PostProcess id in the pipeline
  109324. */
  109325. SSAOBlurHRenderEffect: string;
  109326. /**
  109327. * @ignore
  109328. * The vertical blur PostProcess id in the pipeline
  109329. */
  109330. SSAOBlurVRenderEffect: string;
  109331. /**
  109332. * @ignore
  109333. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109334. */
  109335. SSAOCombineRenderEffect: string;
  109336. /**
  109337. * The output strength of the SSAO post-process. Default value is 1.0.
  109338. */
  109339. totalStrength: number;
  109340. /**
  109341. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109342. */
  109343. radius: number;
  109344. /**
  109345. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109346. * Must not be equal to fallOff and superior to fallOff.
  109347. * Default value is 0.0075
  109348. */
  109349. area: number;
  109350. /**
  109351. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109352. * Must not be equal to area and inferior to area.
  109353. * Default value is 0.000001
  109354. */
  109355. fallOff: number;
  109356. /**
  109357. * The base color of the SSAO post-process
  109358. * The final result is "base + ssao" between [0, 1]
  109359. */
  109360. base: number;
  109361. private _scene;
  109362. private _depthTexture;
  109363. private _randomTexture;
  109364. private _originalColorPostProcess;
  109365. private _ssaoPostProcess;
  109366. private _blurHPostProcess;
  109367. private _blurVPostProcess;
  109368. private _ssaoCombinePostProcess;
  109369. private _firstUpdate;
  109370. /**
  109371. * Gets active scene
  109372. */
  109373. readonly scene: Scene;
  109374. /**
  109375. * @constructor
  109376. * @param name - The rendering pipeline name
  109377. * @param scene - The scene linked to this pipeline
  109378. * @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 }
  109379. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109380. */
  109381. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109382. /**
  109383. * Get the class name
  109384. * @returns "SSAORenderingPipeline"
  109385. */
  109386. getClassName(): string;
  109387. /**
  109388. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109389. */
  109390. dispose(disableDepthRender?: boolean): void;
  109391. private _createBlurPostProcess;
  109392. /** @hidden */
  109393. _rebuild(): void;
  109394. private _createSSAOPostProcess;
  109395. private _createSSAOCombinePostProcess;
  109396. private _createRandomTexture;
  109397. }
  109398. }
  109399. declare module BABYLON {
  109400. /** @hidden */
  109401. export var standardPixelShader: {
  109402. name: string;
  109403. shader: string;
  109404. };
  109405. }
  109406. declare module BABYLON {
  109407. /**
  109408. * Standard rendering pipeline
  109409. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109410. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109411. */
  109412. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109413. /**
  109414. * Public members
  109415. */
  109416. /**
  109417. * Post-process which contains the original scene color before the pipeline applies all the effects
  109418. */
  109419. originalPostProcess: Nullable<PostProcess>;
  109420. /**
  109421. * Post-process used to down scale an image x4
  109422. */
  109423. downSampleX4PostProcess: Nullable<PostProcess>;
  109424. /**
  109425. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109426. */
  109427. brightPassPostProcess: Nullable<PostProcess>;
  109428. /**
  109429. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109430. */
  109431. blurHPostProcesses: PostProcess[];
  109432. /**
  109433. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109434. */
  109435. blurVPostProcesses: PostProcess[];
  109436. /**
  109437. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109438. */
  109439. textureAdderPostProcess: Nullable<PostProcess>;
  109440. /**
  109441. * Post-process used to create volumetric lighting effect
  109442. */
  109443. volumetricLightPostProcess: Nullable<PostProcess>;
  109444. /**
  109445. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109446. */
  109447. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109448. /**
  109449. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109450. */
  109451. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109452. /**
  109453. * Post-process used to merge the volumetric light effect and the real scene color
  109454. */
  109455. volumetricLightMergePostProces: Nullable<PostProcess>;
  109456. /**
  109457. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109458. */
  109459. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109460. /**
  109461. * Base post-process used to calculate the average luminance of the final image for HDR
  109462. */
  109463. luminancePostProcess: Nullable<PostProcess>;
  109464. /**
  109465. * Post-processes used to create down sample post-processes in order to get
  109466. * the average luminance of the final image for HDR
  109467. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109468. */
  109469. luminanceDownSamplePostProcesses: PostProcess[];
  109470. /**
  109471. * Post-process used to create a HDR effect (light adaptation)
  109472. */
  109473. hdrPostProcess: Nullable<PostProcess>;
  109474. /**
  109475. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109476. */
  109477. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109478. /**
  109479. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109480. */
  109481. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109482. /**
  109483. * Post-process used to merge the final HDR post-process and the real scene color
  109484. */
  109485. hdrFinalPostProcess: Nullable<PostProcess>;
  109486. /**
  109487. * Post-process used to create a lens flare effect
  109488. */
  109489. lensFlarePostProcess: Nullable<PostProcess>;
  109490. /**
  109491. * Post-process that merges the result of the lens flare post-process and the real scene color
  109492. */
  109493. lensFlareComposePostProcess: Nullable<PostProcess>;
  109494. /**
  109495. * Post-process used to create a motion blur effect
  109496. */
  109497. motionBlurPostProcess: Nullable<PostProcess>;
  109498. /**
  109499. * Post-process used to create a depth of field effect
  109500. */
  109501. depthOfFieldPostProcess: Nullable<PostProcess>;
  109502. /**
  109503. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109504. */
  109505. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109506. /**
  109507. * Represents the brightness threshold in order to configure the illuminated surfaces
  109508. */
  109509. brightThreshold: number;
  109510. /**
  109511. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109512. */
  109513. blurWidth: number;
  109514. /**
  109515. * Sets if the blur for highlighted surfaces must be only horizontal
  109516. */
  109517. horizontalBlur: boolean;
  109518. /**
  109519. * Sets the overall exposure used by the pipeline
  109520. */
  109521. exposure: number;
  109522. /**
  109523. * Texture used typically to simulate "dirty" on camera lens
  109524. */
  109525. lensTexture: Nullable<Texture>;
  109526. /**
  109527. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109528. */
  109529. volumetricLightCoefficient: number;
  109530. /**
  109531. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109532. */
  109533. volumetricLightPower: number;
  109534. /**
  109535. * Used the set the blur intensity to smooth the volumetric lights
  109536. */
  109537. volumetricLightBlurScale: number;
  109538. /**
  109539. * Light (spot or directional) used to generate the volumetric lights rays
  109540. * The source light must have a shadow generate so the pipeline can get its
  109541. * depth map
  109542. */
  109543. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109544. /**
  109545. * For eye adaptation, represents the minimum luminance the eye can see
  109546. */
  109547. hdrMinimumLuminance: number;
  109548. /**
  109549. * For eye adaptation, represents the decrease luminance speed
  109550. */
  109551. hdrDecreaseRate: number;
  109552. /**
  109553. * For eye adaptation, represents the increase luminance speed
  109554. */
  109555. hdrIncreaseRate: number;
  109556. /**
  109557. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109558. */
  109559. lensColorTexture: Nullable<Texture>;
  109560. /**
  109561. * The overall strengh for the lens flare effect
  109562. */
  109563. lensFlareStrength: number;
  109564. /**
  109565. * Dispersion coefficient for lens flare ghosts
  109566. */
  109567. lensFlareGhostDispersal: number;
  109568. /**
  109569. * Main lens flare halo width
  109570. */
  109571. lensFlareHaloWidth: number;
  109572. /**
  109573. * Based on the lens distortion effect, defines how much the lens flare result
  109574. * is distorted
  109575. */
  109576. lensFlareDistortionStrength: number;
  109577. /**
  109578. * Lens star texture must be used to simulate rays on the flares and is available
  109579. * in the documentation
  109580. */
  109581. lensStarTexture: Nullable<Texture>;
  109582. /**
  109583. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109584. * flare effect by taking account of the dirt texture
  109585. */
  109586. lensFlareDirtTexture: Nullable<Texture>;
  109587. /**
  109588. * Represents the focal length for the depth of field effect
  109589. */
  109590. depthOfFieldDistance: number;
  109591. /**
  109592. * Represents the blur intensity for the blurred part of the depth of field effect
  109593. */
  109594. depthOfFieldBlurWidth: number;
  109595. /**
  109596. * For motion blur, defines how much the image is blurred by the movement
  109597. */
  109598. motionStrength: number;
  109599. /**
  109600. * List of animations for the pipeline (IAnimatable implementation)
  109601. */
  109602. animations: Animation[];
  109603. /**
  109604. * Private members
  109605. */
  109606. private _scene;
  109607. private _currentDepthOfFieldSource;
  109608. private _basePostProcess;
  109609. private _hdrCurrentLuminance;
  109610. private _floatTextureType;
  109611. private _ratio;
  109612. private _bloomEnabled;
  109613. private _depthOfFieldEnabled;
  109614. private _vlsEnabled;
  109615. private _lensFlareEnabled;
  109616. private _hdrEnabled;
  109617. private _motionBlurEnabled;
  109618. private _fxaaEnabled;
  109619. private _motionBlurSamples;
  109620. private _volumetricLightStepsCount;
  109621. private _samples;
  109622. /**
  109623. * @ignore
  109624. * Specifies if the bloom pipeline is enabled
  109625. */
  109626. BloomEnabled: boolean;
  109627. /**
  109628. * @ignore
  109629. * Specifies if the depth of field pipeline is enabed
  109630. */
  109631. DepthOfFieldEnabled: boolean;
  109632. /**
  109633. * @ignore
  109634. * Specifies if the lens flare pipeline is enabed
  109635. */
  109636. LensFlareEnabled: boolean;
  109637. /**
  109638. * @ignore
  109639. * Specifies if the HDR pipeline is enabled
  109640. */
  109641. HDREnabled: boolean;
  109642. /**
  109643. * @ignore
  109644. * Specifies if the volumetric lights scattering effect is enabled
  109645. */
  109646. VLSEnabled: boolean;
  109647. /**
  109648. * @ignore
  109649. * Specifies if the motion blur effect is enabled
  109650. */
  109651. MotionBlurEnabled: boolean;
  109652. /**
  109653. * Specifies if anti-aliasing is enabled
  109654. */
  109655. fxaaEnabled: boolean;
  109656. /**
  109657. * Specifies the number of steps used to calculate the volumetric lights
  109658. * Typically in interval [50, 200]
  109659. */
  109660. volumetricLightStepsCount: number;
  109661. /**
  109662. * Specifies the number of samples used for the motion blur effect
  109663. * Typically in interval [16, 64]
  109664. */
  109665. motionBlurSamples: number;
  109666. /**
  109667. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109668. */
  109669. samples: number;
  109670. /**
  109671. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109672. * @constructor
  109673. * @param name The rendering pipeline name
  109674. * @param scene The scene linked to this pipeline
  109675. * @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)
  109676. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  109677. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109678. */
  109679. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  109680. private _buildPipeline;
  109681. private _createDownSampleX4PostProcess;
  109682. private _createBrightPassPostProcess;
  109683. private _createBlurPostProcesses;
  109684. private _createTextureAdderPostProcess;
  109685. private _createVolumetricLightPostProcess;
  109686. private _createLuminancePostProcesses;
  109687. private _createHdrPostProcess;
  109688. private _createLensFlarePostProcess;
  109689. private _createDepthOfFieldPostProcess;
  109690. private _createMotionBlurPostProcess;
  109691. private _getDepthTexture;
  109692. private _disposePostProcesses;
  109693. /**
  109694. * Dispose of the pipeline and stop all post processes
  109695. */
  109696. dispose(): void;
  109697. /**
  109698. * Serialize the rendering pipeline (Used when exporting)
  109699. * @returns the serialized object
  109700. */
  109701. serialize(): any;
  109702. /**
  109703. * Parse the serialized pipeline
  109704. * @param source Source pipeline.
  109705. * @param scene The scene to load the pipeline to.
  109706. * @param rootUrl The URL of the serialized pipeline.
  109707. * @returns An instantiated pipeline from the serialized object.
  109708. */
  109709. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  109710. /**
  109711. * Luminance steps
  109712. */
  109713. static LuminanceSteps: number;
  109714. }
  109715. }
  109716. declare module BABYLON {
  109717. /** @hidden */
  109718. export var tonemapPixelShader: {
  109719. name: string;
  109720. shader: string;
  109721. };
  109722. }
  109723. declare module BABYLON {
  109724. /** Defines operator used for tonemapping */
  109725. export enum TonemappingOperator {
  109726. /** Hable */
  109727. Hable = 0,
  109728. /** Reinhard */
  109729. Reinhard = 1,
  109730. /** HejiDawson */
  109731. HejiDawson = 2,
  109732. /** Photographic */
  109733. Photographic = 3
  109734. }
  109735. /**
  109736. * Defines a post process to apply tone mapping
  109737. */
  109738. export class TonemapPostProcess extends PostProcess {
  109739. private _operator;
  109740. /** Defines the required exposure adjustement */
  109741. exposureAdjustment: number;
  109742. /**
  109743. * Creates a new TonemapPostProcess
  109744. * @param name defines the name of the postprocess
  109745. * @param _operator defines the operator to use
  109746. * @param exposureAdjustment defines the required exposure adjustement
  109747. * @param camera defines the camera to use (can be null)
  109748. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  109749. * @param engine defines the hosting engine (can be ignore if camera is set)
  109750. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109751. */
  109752. constructor(name: string, _operator: TonemappingOperator,
  109753. /** Defines the required exposure adjustement */
  109754. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  109755. }
  109756. }
  109757. declare module BABYLON {
  109758. /** @hidden */
  109759. export var depthVertexShader: {
  109760. name: string;
  109761. shader: string;
  109762. };
  109763. }
  109764. declare module BABYLON {
  109765. /** @hidden */
  109766. export var volumetricLightScatteringPixelShader: {
  109767. name: string;
  109768. shader: string;
  109769. };
  109770. }
  109771. declare module BABYLON {
  109772. /** @hidden */
  109773. export var volumetricLightScatteringPassPixelShader: {
  109774. name: string;
  109775. shader: string;
  109776. };
  109777. }
  109778. declare module BABYLON {
  109779. /**
  109780. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  109781. */
  109782. export class VolumetricLightScatteringPostProcess extends PostProcess {
  109783. private _volumetricLightScatteringPass;
  109784. private _volumetricLightScatteringRTT;
  109785. private _viewPort;
  109786. private _screenCoordinates;
  109787. private _cachedDefines;
  109788. /**
  109789. * If not undefined, the mesh position is computed from the attached node position
  109790. */
  109791. attachedNode: {
  109792. position: Vector3;
  109793. };
  109794. /**
  109795. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  109796. */
  109797. customMeshPosition: Vector3;
  109798. /**
  109799. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  109800. */
  109801. useCustomMeshPosition: boolean;
  109802. /**
  109803. * If the post-process should inverse the light scattering direction
  109804. */
  109805. invert: boolean;
  109806. /**
  109807. * The internal mesh used by the post-process
  109808. */
  109809. mesh: Mesh;
  109810. /**
  109811. * @hidden
  109812. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  109813. */
  109814. useDiffuseColor: boolean;
  109815. /**
  109816. * Array containing the excluded meshes not rendered in the internal pass
  109817. */
  109818. excludedMeshes: AbstractMesh[];
  109819. /**
  109820. * Controls the overall intensity of the post-process
  109821. */
  109822. exposure: number;
  109823. /**
  109824. * Dissipates each sample's contribution in range [0, 1]
  109825. */
  109826. decay: number;
  109827. /**
  109828. * Controls the overall intensity of each sample
  109829. */
  109830. weight: number;
  109831. /**
  109832. * Controls the density of each sample
  109833. */
  109834. density: number;
  109835. /**
  109836. * @constructor
  109837. * @param name The post-process name
  109838. * @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)
  109839. * @param camera The camera that the post-process will be attached to
  109840. * @param mesh The mesh used to create the light scattering
  109841. * @param samples The post-process quality, default 100
  109842. * @param samplingModeThe post-process filtering mode
  109843. * @param engine The babylon engine
  109844. * @param reusable If the post-process is reusable
  109845. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  109846. */
  109847. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  109848. /**
  109849. * Returns the string "VolumetricLightScatteringPostProcess"
  109850. * @returns "VolumetricLightScatteringPostProcess"
  109851. */
  109852. getClassName(): string;
  109853. private _isReady;
  109854. /**
  109855. * Sets the new light position for light scattering effect
  109856. * @param position The new custom light position
  109857. */
  109858. setCustomMeshPosition(position: Vector3): void;
  109859. /**
  109860. * Returns the light position for light scattering effect
  109861. * @return Vector3 The custom light position
  109862. */
  109863. getCustomMeshPosition(): Vector3;
  109864. /**
  109865. * Disposes the internal assets and detaches the post-process from the camera
  109866. */
  109867. dispose(camera: Camera): void;
  109868. /**
  109869. * Returns the render target texture used by the post-process
  109870. * @return the render target texture used by the post-process
  109871. */
  109872. getPass(): RenderTargetTexture;
  109873. private _meshExcluded;
  109874. private _createPass;
  109875. private _updateMeshScreenCoordinates;
  109876. /**
  109877. * Creates a default mesh for the Volumeric Light Scattering post-process
  109878. * @param name The mesh name
  109879. * @param scene The scene where to create the mesh
  109880. * @return the default mesh
  109881. */
  109882. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  109883. }
  109884. }
  109885. declare module BABYLON {
  109886. interface Scene {
  109887. /** @hidden (Backing field) */
  109888. _boundingBoxRenderer: BoundingBoxRenderer;
  109889. /** @hidden (Backing field) */
  109890. _forceShowBoundingBoxes: boolean;
  109891. /**
  109892. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  109893. */
  109894. forceShowBoundingBoxes: boolean;
  109895. /**
  109896. * Gets the bounding box renderer associated with the scene
  109897. * @returns a BoundingBoxRenderer
  109898. */
  109899. getBoundingBoxRenderer(): BoundingBoxRenderer;
  109900. }
  109901. interface AbstractMesh {
  109902. /** @hidden (Backing field) */
  109903. _showBoundingBox: boolean;
  109904. /**
  109905. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  109906. */
  109907. showBoundingBox: boolean;
  109908. }
  109909. /**
  109910. * Component responsible of rendering the bounding box of the meshes in a scene.
  109911. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  109912. */
  109913. export class BoundingBoxRenderer implements ISceneComponent {
  109914. /**
  109915. * The component name helpfull to identify the component in the list of scene components.
  109916. */
  109917. readonly name: string;
  109918. /**
  109919. * The scene the component belongs to.
  109920. */
  109921. scene: Scene;
  109922. /**
  109923. * Color of the bounding box lines placed in front of an object
  109924. */
  109925. frontColor: Color3;
  109926. /**
  109927. * Color of the bounding box lines placed behind an object
  109928. */
  109929. backColor: Color3;
  109930. /**
  109931. * Defines if the renderer should show the back lines or not
  109932. */
  109933. showBackLines: boolean;
  109934. /**
  109935. * @hidden
  109936. */
  109937. renderList: SmartArray<BoundingBox>;
  109938. private _colorShader;
  109939. private _vertexBuffers;
  109940. private _indexBuffer;
  109941. /**
  109942. * Instantiates a new bounding box renderer in a scene.
  109943. * @param scene the scene the renderer renders in
  109944. */
  109945. constructor(scene: Scene);
  109946. /**
  109947. * Registers the component in a given scene
  109948. */
  109949. register(): void;
  109950. private _evaluateSubMesh;
  109951. private _activeMesh;
  109952. private _prepareRessources;
  109953. private _createIndexBuffer;
  109954. /**
  109955. * Rebuilds the elements related to this component in case of
  109956. * context lost for instance.
  109957. */
  109958. rebuild(): void;
  109959. /**
  109960. * @hidden
  109961. */
  109962. reset(): void;
  109963. /**
  109964. * Render the bounding boxes of a specific rendering group
  109965. * @param renderingGroupId defines the rendering group to render
  109966. */
  109967. render(renderingGroupId: number): void;
  109968. /**
  109969. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109970. * @param mesh Define the mesh to render the occlusion bounding box for
  109971. */
  109972. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109973. /**
  109974. * Dispose and release the resources attached to this renderer.
  109975. */
  109976. dispose(): void;
  109977. }
  109978. }
  109979. declare module BABYLON {
  109980. /** @hidden */
  109981. export var depthPixelShader: {
  109982. name: string;
  109983. shader: string;
  109984. };
  109985. }
  109986. declare module BABYLON {
  109987. /**
  109988. * This represents a depth renderer in Babylon.
  109989. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109990. */
  109991. export class DepthRenderer {
  109992. private _scene;
  109993. private _depthMap;
  109994. private _effect;
  109995. private _cachedDefines;
  109996. private _camera;
  109997. /**
  109998. * Specifiess that the depth renderer will only be used within
  109999. * the camera it is created for.
  110000. * This can help forcing its rendering during the camera processing.
  110001. */
  110002. useOnlyInActiveCamera: boolean;
  110003. /** @hidden */
  110004. static _SceneComponentInitialization: (scene: Scene) => void;
  110005. /**
  110006. * Instantiates a depth renderer
  110007. * @param scene The scene the renderer belongs to
  110008. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110009. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110010. */
  110011. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110012. /**
  110013. * Creates the depth rendering effect and checks if the effect is ready.
  110014. * @param subMesh The submesh to be used to render the depth map of
  110015. * @param useInstances If multiple world instances should be used
  110016. * @returns if the depth renderer is ready to render the depth map
  110017. */
  110018. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110019. /**
  110020. * Gets the texture which the depth map will be written to.
  110021. * @returns The depth map texture
  110022. */
  110023. getDepthMap(): RenderTargetTexture;
  110024. /**
  110025. * Disposes of the depth renderer.
  110026. */
  110027. dispose(): void;
  110028. }
  110029. }
  110030. declare module BABYLON {
  110031. interface Scene {
  110032. /** @hidden (Backing field) */
  110033. _depthRenderer: {
  110034. [id: string]: DepthRenderer;
  110035. };
  110036. /**
  110037. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110038. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110039. * @returns the created depth renderer
  110040. */
  110041. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110042. /**
  110043. * Disables a depth renderer for a given camera
  110044. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110045. */
  110046. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110047. }
  110048. /**
  110049. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110050. * in several rendering techniques.
  110051. */
  110052. export class DepthRendererSceneComponent implements ISceneComponent {
  110053. /**
  110054. * The component name helpfull to identify the component in the list of scene components.
  110055. */
  110056. readonly name: string;
  110057. /**
  110058. * The scene the component belongs to.
  110059. */
  110060. scene: Scene;
  110061. /**
  110062. * Creates a new instance of the component for the given scene
  110063. * @param scene Defines the scene to register the component in
  110064. */
  110065. constructor(scene: Scene);
  110066. /**
  110067. * Registers the component in a given scene
  110068. */
  110069. register(): void;
  110070. /**
  110071. * Rebuilds the elements related to this component in case of
  110072. * context lost for instance.
  110073. */
  110074. rebuild(): void;
  110075. /**
  110076. * Disposes the component and the associated ressources
  110077. */
  110078. dispose(): void;
  110079. private _gatherRenderTargets;
  110080. private _gatherActiveCameraRenderTargets;
  110081. }
  110082. }
  110083. declare module BABYLON {
  110084. /** @hidden */
  110085. export var outlinePixelShader: {
  110086. name: string;
  110087. shader: string;
  110088. };
  110089. }
  110090. declare module BABYLON {
  110091. /** @hidden */
  110092. export var outlineVertexShader: {
  110093. name: string;
  110094. shader: string;
  110095. };
  110096. }
  110097. declare module BABYLON {
  110098. interface Scene {
  110099. /** @hidden */
  110100. _outlineRenderer: OutlineRenderer;
  110101. /**
  110102. * Gets the outline renderer associated with the scene
  110103. * @returns a OutlineRenderer
  110104. */
  110105. getOutlineRenderer(): OutlineRenderer;
  110106. }
  110107. interface AbstractMesh {
  110108. /** @hidden (Backing field) */
  110109. _renderOutline: boolean;
  110110. /**
  110111. * Gets or sets a boolean indicating if the outline must be rendered as well
  110112. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110113. */
  110114. renderOutline: boolean;
  110115. /** @hidden (Backing field) */
  110116. _renderOverlay: boolean;
  110117. /**
  110118. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110119. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110120. */
  110121. renderOverlay: boolean;
  110122. }
  110123. /**
  110124. * This class is responsible to draw bothe outline/overlay of meshes.
  110125. * It should not be used directly but through the available method on mesh.
  110126. */
  110127. export class OutlineRenderer implements ISceneComponent {
  110128. /**
  110129. * The name of the component. Each component must have a unique name.
  110130. */
  110131. name: string;
  110132. /**
  110133. * The scene the component belongs to.
  110134. */
  110135. scene: Scene;
  110136. /**
  110137. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110138. */
  110139. zOffset: number;
  110140. private _engine;
  110141. private _effect;
  110142. private _cachedDefines;
  110143. private _savedDepthWrite;
  110144. /**
  110145. * Instantiates a new outline renderer. (There could be only one per scene).
  110146. * @param scene Defines the scene it belongs to
  110147. */
  110148. constructor(scene: Scene);
  110149. /**
  110150. * Register the component to one instance of a scene.
  110151. */
  110152. register(): void;
  110153. /**
  110154. * Rebuilds the elements related to this component in case of
  110155. * context lost for instance.
  110156. */
  110157. rebuild(): void;
  110158. /**
  110159. * Disposes the component and the associated ressources.
  110160. */
  110161. dispose(): void;
  110162. /**
  110163. * Renders the outline in the canvas.
  110164. * @param subMesh Defines the sumesh to render
  110165. * @param batch Defines the batch of meshes in case of instances
  110166. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110167. */
  110168. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110169. /**
  110170. * Returns whether or not the outline renderer is ready for a given submesh.
  110171. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110172. * @param subMesh Defines the submesh to check readyness for
  110173. * @param useInstances Defines wheter wee are trying to render instances or not
  110174. * @returns true if ready otherwise false
  110175. */
  110176. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110177. private _beforeRenderingMesh;
  110178. private _afterRenderingMesh;
  110179. }
  110180. }
  110181. declare module BABYLON {
  110182. /**
  110183. * Defines the list of states available for a task inside a AssetsManager
  110184. */
  110185. export enum AssetTaskState {
  110186. /**
  110187. * Initialization
  110188. */
  110189. INIT = 0,
  110190. /**
  110191. * Running
  110192. */
  110193. RUNNING = 1,
  110194. /**
  110195. * Done
  110196. */
  110197. DONE = 2,
  110198. /**
  110199. * Error
  110200. */
  110201. ERROR = 3
  110202. }
  110203. /**
  110204. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110205. */
  110206. export abstract class AbstractAssetTask {
  110207. /**
  110208. * Task name
  110209. */ name: string;
  110210. /**
  110211. * Callback called when the task is successful
  110212. */
  110213. onSuccess: (task: any) => void;
  110214. /**
  110215. * Callback called when the task is not successful
  110216. */
  110217. onError: (task: any, message?: string, exception?: any) => void;
  110218. /**
  110219. * Creates a new AssetsManager
  110220. * @param name defines the name of the task
  110221. */
  110222. constructor(
  110223. /**
  110224. * Task name
  110225. */ name: string);
  110226. private _isCompleted;
  110227. private _taskState;
  110228. private _errorObject;
  110229. /**
  110230. * Get if the task is completed
  110231. */
  110232. readonly isCompleted: boolean;
  110233. /**
  110234. * Gets the current state of the task
  110235. */
  110236. readonly taskState: AssetTaskState;
  110237. /**
  110238. * Gets the current error object (if task is in error)
  110239. */
  110240. readonly errorObject: {
  110241. message?: string;
  110242. exception?: any;
  110243. };
  110244. /**
  110245. * Internal only
  110246. * @hidden
  110247. */
  110248. _setErrorObject(message?: string, exception?: any): void;
  110249. /**
  110250. * Execute the current task
  110251. * @param scene defines the scene where you want your assets to be loaded
  110252. * @param onSuccess is a callback called when the task is successfully executed
  110253. * @param onError is a callback called if an error occurs
  110254. */
  110255. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110256. /**
  110257. * Execute the current task
  110258. * @param scene defines the scene where you want your assets to be loaded
  110259. * @param onSuccess is a callback called when the task is successfully executed
  110260. * @param onError is a callback called if an error occurs
  110261. */
  110262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110263. /**
  110264. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110265. * This can be used with failed tasks that have the reason for failure fixed.
  110266. */
  110267. reset(): void;
  110268. private onErrorCallback;
  110269. private onDoneCallback;
  110270. }
  110271. /**
  110272. * Define the interface used by progress events raised during assets loading
  110273. */
  110274. export interface IAssetsProgressEvent {
  110275. /**
  110276. * Defines the number of remaining tasks to process
  110277. */
  110278. remainingCount: number;
  110279. /**
  110280. * Defines the total number of tasks
  110281. */
  110282. totalCount: number;
  110283. /**
  110284. * Defines the task that was just processed
  110285. */
  110286. task: AbstractAssetTask;
  110287. }
  110288. /**
  110289. * Class used to share progress information about assets loading
  110290. */
  110291. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110292. /**
  110293. * Defines the number of remaining tasks to process
  110294. */
  110295. remainingCount: number;
  110296. /**
  110297. * Defines the total number of tasks
  110298. */
  110299. totalCount: number;
  110300. /**
  110301. * Defines the task that was just processed
  110302. */
  110303. task: AbstractAssetTask;
  110304. /**
  110305. * Creates a AssetsProgressEvent
  110306. * @param remainingCount defines the number of remaining tasks to process
  110307. * @param totalCount defines the total number of tasks
  110308. * @param task defines the task that was just processed
  110309. */
  110310. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110311. }
  110312. /**
  110313. * Define a task used by AssetsManager to load meshes
  110314. */
  110315. export class MeshAssetTask extends AbstractAssetTask {
  110316. /**
  110317. * Defines the name of the task
  110318. */
  110319. name: string;
  110320. /**
  110321. * Defines the list of mesh's names you want to load
  110322. */
  110323. meshesNames: any;
  110324. /**
  110325. * Defines the root url to use as a base to load your meshes and associated resources
  110326. */
  110327. rootUrl: string;
  110328. /**
  110329. * Defines the filename of the scene to load from
  110330. */
  110331. sceneFilename: string;
  110332. /**
  110333. * Gets the list of loaded meshes
  110334. */
  110335. loadedMeshes: Array<AbstractMesh>;
  110336. /**
  110337. * Gets the list of loaded particle systems
  110338. */
  110339. loadedParticleSystems: Array<IParticleSystem>;
  110340. /**
  110341. * Gets the list of loaded skeletons
  110342. */
  110343. loadedSkeletons: Array<Skeleton>;
  110344. /**
  110345. * Gets the list of loaded animation groups
  110346. */
  110347. loadedAnimationGroups: Array<AnimationGroup>;
  110348. /**
  110349. * Callback called when the task is successful
  110350. */
  110351. onSuccess: (task: MeshAssetTask) => void;
  110352. /**
  110353. * Callback called when the task is successful
  110354. */
  110355. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110356. /**
  110357. * Creates a new MeshAssetTask
  110358. * @param name defines the name of the task
  110359. * @param meshesNames defines the list of mesh's names you want to load
  110360. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110361. * @param sceneFilename defines the filename of the scene to load from
  110362. */
  110363. constructor(
  110364. /**
  110365. * Defines the name of the task
  110366. */
  110367. name: string,
  110368. /**
  110369. * Defines the list of mesh's names you want to load
  110370. */
  110371. meshesNames: any,
  110372. /**
  110373. * Defines the root url to use as a base to load your meshes and associated resources
  110374. */
  110375. rootUrl: string,
  110376. /**
  110377. * Defines the filename of the scene to load from
  110378. */
  110379. sceneFilename: string);
  110380. /**
  110381. * Execute the current task
  110382. * @param scene defines the scene where you want your assets to be loaded
  110383. * @param onSuccess is a callback called when the task is successfully executed
  110384. * @param onError is a callback called if an error occurs
  110385. */
  110386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110387. }
  110388. /**
  110389. * Define a task used by AssetsManager to load text content
  110390. */
  110391. export class TextFileAssetTask extends AbstractAssetTask {
  110392. /**
  110393. * Defines the name of the task
  110394. */
  110395. name: string;
  110396. /**
  110397. * Defines the location of the file to load
  110398. */
  110399. url: string;
  110400. /**
  110401. * Gets the loaded text string
  110402. */
  110403. text: string;
  110404. /**
  110405. * Callback called when the task is successful
  110406. */
  110407. onSuccess: (task: TextFileAssetTask) => void;
  110408. /**
  110409. * Callback called when the task is successful
  110410. */
  110411. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110412. /**
  110413. * Creates a new TextFileAssetTask object
  110414. * @param name defines the name of the task
  110415. * @param url defines the location of the file to load
  110416. */
  110417. constructor(
  110418. /**
  110419. * Defines the name of the task
  110420. */
  110421. name: string,
  110422. /**
  110423. * Defines the location of the file to load
  110424. */
  110425. url: string);
  110426. /**
  110427. * Execute the current task
  110428. * @param scene defines the scene where you want your assets to be loaded
  110429. * @param onSuccess is a callback called when the task is successfully executed
  110430. * @param onError is a callback called if an error occurs
  110431. */
  110432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110433. }
  110434. /**
  110435. * Define a task used by AssetsManager to load binary data
  110436. */
  110437. export class BinaryFileAssetTask extends AbstractAssetTask {
  110438. /**
  110439. * Defines the name of the task
  110440. */
  110441. name: string;
  110442. /**
  110443. * Defines the location of the file to load
  110444. */
  110445. url: string;
  110446. /**
  110447. * Gets the lodaded data (as an array buffer)
  110448. */
  110449. data: ArrayBuffer;
  110450. /**
  110451. * Callback called when the task is successful
  110452. */
  110453. onSuccess: (task: BinaryFileAssetTask) => void;
  110454. /**
  110455. * Callback called when the task is successful
  110456. */
  110457. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110458. /**
  110459. * Creates a new BinaryFileAssetTask object
  110460. * @param name defines the name of the new task
  110461. * @param url defines the location of the file to load
  110462. */
  110463. constructor(
  110464. /**
  110465. * Defines the name of the task
  110466. */
  110467. name: string,
  110468. /**
  110469. * Defines the location of the file to load
  110470. */
  110471. url: string);
  110472. /**
  110473. * Execute the current task
  110474. * @param scene defines the scene where you want your assets to be loaded
  110475. * @param onSuccess is a callback called when the task is successfully executed
  110476. * @param onError is a callback called if an error occurs
  110477. */
  110478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110479. }
  110480. /**
  110481. * Define a task used by AssetsManager to load images
  110482. */
  110483. export class ImageAssetTask extends AbstractAssetTask {
  110484. /**
  110485. * Defines the name of the task
  110486. */
  110487. name: string;
  110488. /**
  110489. * Defines the location of the image to load
  110490. */
  110491. url: string;
  110492. /**
  110493. * Gets the loaded images
  110494. */
  110495. image: HTMLImageElement;
  110496. /**
  110497. * Callback called when the task is successful
  110498. */
  110499. onSuccess: (task: ImageAssetTask) => void;
  110500. /**
  110501. * Callback called when the task is successful
  110502. */
  110503. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110504. /**
  110505. * Creates a new ImageAssetTask
  110506. * @param name defines the name of the task
  110507. * @param url defines the location of the image to load
  110508. */
  110509. constructor(
  110510. /**
  110511. * Defines the name of the task
  110512. */
  110513. name: string,
  110514. /**
  110515. * Defines the location of the image to load
  110516. */
  110517. url: string);
  110518. /**
  110519. * Execute the current task
  110520. * @param scene defines the scene where you want your assets to be loaded
  110521. * @param onSuccess is a callback called when the task is successfully executed
  110522. * @param onError is a callback called if an error occurs
  110523. */
  110524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110525. }
  110526. /**
  110527. * Defines the interface used by texture loading tasks
  110528. */
  110529. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110530. /**
  110531. * Gets the loaded texture
  110532. */
  110533. texture: TEX;
  110534. }
  110535. /**
  110536. * Define a task used by AssetsManager to load 2D textures
  110537. */
  110538. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110539. /**
  110540. * Defines the name of the task
  110541. */
  110542. name: string;
  110543. /**
  110544. * Defines the location of the file to load
  110545. */
  110546. url: string;
  110547. /**
  110548. * Defines if mipmap should not be generated (default is false)
  110549. */
  110550. noMipmap?: boolean | undefined;
  110551. /**
  110552. * Defines if texture must be inverted on Y axis (default is false)
  110553. */
  110554. invertY?: boolean | undefined;
  110555. /**
  110556. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110557. */
  110558. samplingMode: number;
  110559. /**
  110560. * Gets the loaded texture
  110561. */
  110562. texture: Texture;
  110563. /**
  110564. * Callback called when the task is successful
  110565. */
  110566. onSuccess: (task: TextureAssetTask) => void;
  110567. /**
  110568. * Callback called when the task is successful
  110569. */
  110570. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110571. /**
  110572. * Creates a new TextureAssetTask object
  110573. * @param name defines the name of the task
  110574. * @param url defines the location of the file to load
  110575. * @param noMipmap defines if mipmap should not be generated (default is false)
  110576. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110577. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110578. */
  110579. constructor(
  110580. /**
  110581. * Defines the name of the task
  110582. */
  110583. name: string,
  110584. /**
  110585. * Defines the location of the file to load
  110586. */
  110587. url: string,
  110588. /**
  110589. * Defines if mipmap should not be generated (default is false)
  110590. */
  110591. noMipmap?: boolean | undefined,
  110592. /**
  110593. * Defines if texture must be inverted on Y axis (default is false)
  110594. */
  110595. invertY?: boolean | undefined,
  110596. /**
  110597. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110598. */
  110599. samplingMode?: number);
  110600. /**
  110601. * Execute the current task
  110602. * @param scene defines the scene where you want your assets to be loaded
  110603. * @param onSuccess is a callback called when the task is successfully executed
  110604. * @param onError is a callback called if an error occurs
  110605. */
  110606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110607. }
  110608. /**
  110609. * Define a task used by AssetsManager to load cube textures
  110610. */
  110611. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  110612. /**
  110613. * Defines the name of the task
  110614. */
  110615. name: string;
  110616. /**
  110617. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110618. */
  110619. url: string;
  110620. /**
  110621. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110622. */
  110623. extensions?: string[] | undefined;
  110624. /**
  110625. * Defines if mipmaps should not be generated (default is false)
  110626. */
  110627. noMipmap?: boolean | undefined;
  110628. /**
  110629. * Defines the explicit list of files (undefined by default)
  110630. */
  110631. files?: string[] | undefined;
  110632. /**
  110633. * Gets the loaded texture
  110634. */
  110635. texture: CubeTexture;
  110636. /**
  110637. * Callback called when the task is successful
  110638. */
  110639. onSuccess: (task: CubeTextureAssetTask) => void;
  110640. /**
  110641. * Callback called when the task is successful
  110642. */
  110643. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  110644. /**
  110645. * Creates a new CubeTextureAssetTask
  110646. * @param name defines the name of the task
  110647. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110648. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110649. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110650. * @param files defines the explicit list of files (undefined by default)
  110651. */
  110652. constructor(
  110653. /**
  110654. * Defines the name of the task
  110655. */
  110656. name: string,
  110657. /**
  110658. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110659. */
  110660. url: string,
  110661. /**
  110662. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110663. */
  110664. extensions?: string[] | undefined,
  110665. /**
  110666. * Defines if mipmaps should not be generated (default is false)
  110667. */
  110668. noMipmap?: boolean | undefined,
  110669. /**
  110670. * Defines the explicit list of files (undefined by default)
  110671. */
  110672. files?: string[] | undefined);
  110673. /**
  110674. * Execute the current task
  110675. * @param scene defines the scene where you want your assets to be loaded
  110676. * @param onSuccess is a callback called when the task is successfully executed
  110677. * @param onError is a callback called if an error occurs
  110678. */
  110679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110680. }
  110681. /**
  110682. * Define a task used by AssetsManager to load HDR cube textures
  110683. */
  110684. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  110685. /**
  110686. * Defines the name of the task
  110687. */
  110688. name: string;
  110689. /**
  110690. * Defines the location of the file to load
  110691. */
  110692. url: string;
  110693. /**
  110694. * Defines the desired size (the more it increases the longer the generation will be)
  110695. */
  110696. size: number;
  110697. /**
  110698. * Defines if mipmaps should not be generated (default is false)
  110699. */
  110700. noMipmap: boolean;
  110701. /**
  110702. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110703. */
  110704. generateHarmonics: boolean;
  110705. /**
  110706. * 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)
  110707. */
  110708. gammaSpace: boolean;
  110709. /**
  110710. * Internal Use Only
  110711. */
  110712. reserved: boolean;
  110713. /**
  110714. * Gets the loaded texture
  110715. */
  110716. texture: HDRCubeTexture;
  110717. /**
  110718. * Callback called when the task is successful
  110719. */
  110720. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  110721. /**
  110722. * Callback called when the task is successful
  110723. */
  110724. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  110725. /**
  110726. * Creates a new HDRCubeTextureAssetTask object
  110727. * @param name defines the name of the task
  110728. * @param url defines the location of the file to load
  110729. * @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.
  110730. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110731. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110732. * @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)
  110733. * @param reserved Internal use only
  110734. */
  110735. constructor(
  110736. /**
  110737. * Defines the name of the task
  110738. */
  110739. name: string,
  110740. /**
  110741. * Defines the location of the file to load
  110742. */
  110743. url: string,
  110744. /**
  110745. * Defines the desired size (the more it increases the longer the generation will be)
  110746. */
  110747. size: number,
  110748. /**
  110749. * Defines if mipmaps should not be generated (default is false)
  110750. */
  110751. noMipmap?: boolean,
  110752. /**
  110753. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110754. */
  110755. generateHarmonics?: boolean,
  110756. /**
  110757. * 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)
  110758. */
  110759. gammaSpace?: boolean,
  110760. /**
  110761. * Internal Use Only
  110762. */
  110763. reserved?: boolean);
  110764. /**
  110765. * Execute the current task
  110766. * @param scene defines the scene where you want your assets to be loaded
  110767. * @param onSuccess is a callback called when the task is successfully executed
  110768. * @param onError is a callback called if an error occurs
  110769. */
  110770. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110771. }
  110772. /**
  110773. * This class can be used to easily import assets into a scene
  110774. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  110775. */
  110776. export class AssetsManager {
  110777. private _scene;
  110778. private _isLoading;
  110779. protected _tasks: AbstractAssetTask[];
  110780. protected _waitingTasksCount: number;
  110781. protected _totalTasksCount: number;
  110782. /**
  110783. * Callback called when all tasks are processed
  110784. */
  110785. onFinish: (tasks: AbstractAssetTask[]) => void;
  110786. /**
  110787. * Callback called when a task is successful
  110788. */
  110789. onTaskSuccess: (task: AbstractAssetTask) => void;
  110790. /**
  110791. * Callback called when a task had an error
  110792. */
  110793. onTaskError: (task: AbstractAssetTask) => void;
  110794. /**
  110795. * Callback called when a task is done (whatever the result is)
  110796. */
  110797. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  110798. /**
  110799. * Observable called when all tasks are processed
  110800. */
  110801. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  110802. /**
  110803. * Observable called when a task had an error
  110804. */
  110805. onTaskErrorObservable: Observable<AbstractAssetTask>;
  110806. /**
  110807. * Observable called when a task is successful
  110808. */
  110809. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  110810. /**
  110811. * Observable called when a task is done (whatever the result is)
  110812. */
  110813. onProgressObservable: Observable<IAssetsProgressEvent>;
  110814. /**
  110815. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  110816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110817. */
  110818. useDefaultLoadingScreen: boolean;
  110819. /**
  110820. * Creates a new AssetsManager
  110821. * @param scene defines the scene to work on
  110822. */
  110823. constructor(scene: Scene);
  110824. /**
  110825. * Add a MeshAssetTask to the list of active tasks
  110826. * @param taskName defines the name of the new task
  110827. * @param meshesNames defines the name of meshes to load
  110828. * @param rootUrl defines the root url to use to locate files
  110829. * @param sceneFilename defines the filename of the scene file
  110830. * @returns a new MeshAssetTask object
  110831. */
  110832. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  110833. /**
  110834. * Add a TextFileAssetTask to the list of active tasks
  110835. * @param taskName defines the name of the new task
  110836. * @param url defines the url of the file to load
  110837. * @returns a new TextFileAssetTask object
  110838. */
  110839. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  110840. /**
  110841. * Add a BinaryFileAssetTask to the list of active tasks
  110842. * @param taskName defines the name of the new task
  110843. * @param url defines the url of the file to load
  110844. * @returns a new BinaryFileAssetTask object
  110845. */
  110846. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  110847. /**
  110848. * Add a ImageAssetTask to the list of active tasks
  110849. * @param taskName defines the name of the new task
  110850. * @param url defines the url of the file to load
  110851. * @returns a new ImageAssetTask object
  110852. */
  110853. addImageTask(taskName: string, url: string): ImageAssetTask;
  110854. /**
  110855. * Add a TextureAssetTask to the list of active tasks
  110856. * @param taskName defines the name of the new task
  110857. * @param url defines the url of the file to load
  110858. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110859. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  110860. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  110861. * @returns a new TextureAssetTask object
  110862. */
  110863. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  110864. /**
  110865. * Add a CubeTextureAssetTask to the list of active tasks
  110866. * @param taskName defines the name of the new task
  110867. * @param url defines the url of the file to load
  110868. * @param extensions defines the extension to use to load the cube map (can be null)
  110869. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110870. * @param files defines the list of files to load (can be null)
  110871. * @returns a new CubeTextureAssetTask object
  110872. */
  110873. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  110874. /**
  110875. *
  110876. * Add a HDRCubeTextureAssetTask to the list of active tasks
  110877. * @param taskName defines the name of the new task
  110878. * @param url defines the url of the file to load
  110879. * @param size defines the size you want for the cubemap (can be null)
  110880. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110881. * @param generateHarmonics defines if you want to automatically generate (true by default)
  110882. * @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)
  110883. * @param reserved Internal use only
  110884. * @returns a new HDRCubeTextureAssetTask object
  110885. */
  110886. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  110887. /**
  110888. * Remove a task from the assets manager.
  110889. * @param task the task to remove
  110890. */
  110891. removeTask(task: AbstractAssetTask): void;
  110892. private _decreaseWaitingTasksCount;
  110893. private _runTask;
  110894. /**
  110895. * Reset the AssetsManager and remove all tasks
  110896. * @return the current instance of the AssetsManager
  110897. */
  110898. reset(): AssetsManager;
  110899. /**
  110900. * Start the loading process
  110901. * @return the current instance of the AssetsManager
  110902. */
  110903. load(): AssetsManager;
  110904. }
  110905. }
  110906. declare module BABYLON {
  110907. /**
  110908. * Wrapper class for promise with external resolve and reject.
  110909. */
  110910. export class Deferred<T> {
  110911. /**
  110912. * The promise associated with this deferred object.
  110913. */
  110914. readonly promise: Promise<T>;
  110915. private _resolve;
  110916. private _reject;
  110917. /**
  110918. * The resolve method of the promise associated with this deferred object.
  110919. */
  110920. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110921. /**
  110922. * The reject method of the promise associated with this deferred object.
  110923. */
  110924. readonly reject: (reason?: any) => void;
  110925. /**
  110926. * Constructor for this deferred object.
  110927. */
  110928. constructor();
  110929. }
  110930. }
  110931. declare module BABYLON {
  110932. /**
  110933. * Class used to help managing file picking and drag'n'drop
  110934. */
  110935. export class FilesInput {
  110936. /**
  110937. * List of files ready to be loaded
  110938. */
  110939. static readonly FilesToLoad: {
  110940. [key: string]: File;
  110941. };
  110942. /**
  110943. * Callback called when a file is processed
  110944. */
  110945. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110946. private _engine;
  110947. private _currentScene;
  110948. private _sceneLoadedCallback;
  110949. private _progressCallback;
  110950. private _additionalRenderLoopLogicCallback;
  110951. private _textureLoadingCallback;
  110952. private _startingProcessingFilesCallback;
  110953. private _onReloadCallback;
  110954. private _errorCallback;
  110955. private _elementToMonitor;
  110956. private _sceneFileToLoad;
  110957. private _filesToLoad;
  110958. /**
  110959. * Creates a new FilesInput
  110960. * @param engine defines the rendering engine
  110961. * @param scene defines the hosting scene
  110962. * @param sceneLoadedCallback callback called when scene is loaded
  110963. * @param progressCallback callback called to track progress
  110964. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110965. * @param textureLoadingCallback callback called when a texture is loading
  110966. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110967. * @param onReloadCallback callback called when a reload is requested
  110968. * @param errorCallback callback call if an error occurs
  110969. */
  110970. 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);
  110971. private _dragEnterHandler;
  110972. private _dragOverHandler;
  110973. private _dropHandler;
  110974. /**
  110975. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110976. * @param elementToMonitor defines the DOM element to track
  110977. */
  110978. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110979. /**
  110980. * Release all associated resources
  110981. */
  110982. dispose(): void;
  110983. private renderFunction;
  110984. private drag;
  110985. private drop;
  110986. private _traverseFolder;
  110987. private _processFiles;
  110988. /**
  110989. * Load files from a drop event
  110990. * @param event defines the drop event to use as source
  110991. */
  110992. loadFiles(event: any): void;
  110993. private _processReload;
  110994. /**
  110995. * Reload the current scene from the loaded files
  110996. */
  110997. reload(): void;
  110998. }
  110999. }
  111000. declare module BABYLON {
  111001. /**
  111002. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111004. */
  111005. export class SceneOptimization {
  111006. /**
  111007. * Defines the priority of this optimization (0 by default which means first in the list)
  111008. */
  111009. priority: number;
  111010. /**
  111011. * Gets a string describing the action executed by the current optimization
  111012. * @returns description string
  111013. */
  111014. getDescription(): string;
  111015. /**
  111016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111017. * @param scene defines the current scene where to apply this optimization
  111018. * @param optimizer defines the current optimizer
  111019. * @returns true if everything that can be done was applied
  111020. */
  111021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111022. /**
  111023. * Creates the SceneOptimization object
  111024. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111025. * @param desc defines the description associated with the optimization
  111026. */
  111027. constructor(
  111028. /**
  111029. * Defines the priority of this optimization (0 by default which means first in the list)
  111030. */
  111031. priority?: number);
  111032. }
  111033. /**
  111034. * Defines an optimization used to reduce the size of render target textures
  111035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111036. */
  111037. export class TextureOptimization extends SceneOptimization {
  111038. /**
  111039. * Defines the priority of this optimization (0 by default which means first in the list)
  111040. */
  111041. priority: number;
  111042. /**
  111043. * 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
  111044. */
  111045. maximumSize: number;
  111046. /**
  111047. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111048. */
  111049. step: number;
  111050. /**
  111051. * Gets a string describing the action executed by the current optimization
  111052. * @returns description string
  111053. */
  111054. getDescription(): string;
  111055. /**
  111056. * Creates the TextureOptimization object
  111057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111058. * @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
  111059. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111060. */
  111061. constructor(
  111062. /**
  111063. * Defines the priority of this optimization (0 by default which means first in the list)
  111064. */
  111065. priority?: number,
  111066. /**
  111067. * 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
  111068. */
  111069. maximumSize?: number,
  111070. /**
  111071. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111072. */
  111073. step?: number);
  111074. /**
  111075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111076. * @param scene defines the current scene where to apply this optimization
  111077. * @param optimizer defines the current optimizer
  111078. * @returns true if everything that can be done was applied
  111079. */
  111080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111081. }
  111082. /**
  111083. * Defines an optimization used to increase or decrease the rendering resolution
  111084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111085. */
  111086. export class HardwareScalingOptimization extends SceneOptimization {
  111087. /**
  111088. * Defines the priority of this optimization (0 by default which means first in the list)
  111089. */
  111090. priority: number;
  111091. /**
  111092. * Defines the maximum scale to use (2 by default)
  111093. */
  111094. maximumScale: number;
  111095. /**
  111096. * Defines the step to use between two passes (0.5 by default)
  111097. */
  111098. step: number;
  111099. private _currentScale;
  111100. private _directionOffset;
  111101. /**
  111102. * Gets a string describing the action executed by the current optimization
  111103. * @return description string
  111104. */
  111105. getDescription(): string;
  111106. /**
  111107. * Creates the HardwareScalingOptimization object
  111108. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111109. * @param maximumScale defines the maximum scale to use (2 by default)
  111110. * @param step defines the step to use between two passes (0.5 by default)
  111111. */
  111112. constructor(
  111113. /**
  111114. * Defines the priority of this optimization (0 by default which means first in the list)
  111115. */
  111116. priority?: number,
  111117. /**
  111118. * Defines the maximum scale to use (2 by default)
  111119. */
  111120. maximumScale?: number,
  111121. /**
  111122. * Defines the step to use between two passes (0.5 by default)
  111123. */
  111124. step?: number);
  111125. /**
  111126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111127. * @param scene defines the current scene where to apply this optimization
  111128. * @param optimizer defines the current optimizer
  111129. * @returns true if everything that can be done was applied
  111130. */
  111131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111132. }
  111133. /**
  111134. * Defines an optimization used to remove shadows
  111135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111136. */
  111137. export class ShadowsOptimization extends SceneOptimization {
  111138. /**
  111139. * Gets a string describing the action executed by the current optimization
  111140. * @return description string
  111141. */
  111142. getDescription(): string;
  111143. /**
  111144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111145. * @param scene defines the current scene where to apply this optimization
  111146. * @param optimizer defines the current optimizer
  111147. * @returns true if everything that can be done was applied
  111148. */
  111149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111150. }
  111151. /**
  111152. * Defines an optimization used to turn post-processes off
  111153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111154. */
  111155. export class PostProcessesOptimization extends SceneOptimization {
  111156. /**
  111157. * Gets a string describing the action executed by the current optimization
  111158. * @return description string
  111159. */
  111160. getDescription(): string;
  111161. /**
  111162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111163. * @param scene defines the current scene where to apply this optimization
  111164. * @param optimizer defines the current optimizer
  111165. * @returns true if everything that can be done was applied
  111166. */
  111167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111168. }
  111169. /**
  111170. * Defines an optimization used to turn lens flares off
  111171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111172. */
  111173. export class LensFlaresOptimization extends SceneOptimization {
  111174. /**
  111175. * Gets a string describing the action executed by the current optimization
  111176. * @return description string
  111177. */
  111178. getDescription(): string;
  111179. /**
  111180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111181. * @param scene defines the current scene where to apply this optimization
  111182. * @param optimizer defines the current optimizer
  111183. * @returns true if everything that can be done was applied
  111184. */
  111185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111186. }
  111187. /**
  111188. * Defines an optimization based on user defined callback.
  111189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111190. */
  111191. export class CustomOptimization extends SceneOptimization {
  111192. /**
  111193. * Callback called to apply the custom optimization.
  111194. */
  111195. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111196. /**
  111197. * Callback called to get custom description
  111198. */
  111199. onGetDescription: () => string;
  111200. /**
  111201. * Gets a string describing the action executed by the current optimization
  111202. * @returns description string
  111203. */
  111204. getDescription(): string;
  111205. /**
  111206. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111207. * @param scene defines the current scene where to apply this optimization
  111208. * @param optimizer defines the current optimizer
  111209. * @returns true if everything that can be done was applied
  111210. */
  111211. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111212. }
  111213. /**
  111214. * Defines an optimization used to turn particles off
  111215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111216. */
  111217. export class ParticlesOptimization extends SceneOptimization {
  111218. /**
  111219. * Gets a string describing the action executed by the current optimization
  111220. * @return description string
  111221. */
  111222. getDescription(): string;
  111223. /**
  111224. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111225. * @param scene defines the current scene where to apply this optimization
  111226. * @param optimizer defines the current optimizer
  111227. * @returns true if everything that can be done was applied
  111228. */
  111229. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111230. }
  111231. /**
  111232. * Defines an optimization used to turn render targets off
  111233. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111234. */
  111235. export class RenderTargetsOptimization extends SceneOptimization {
  111236. /**
  111237. * Gets a string describing the action executed by the current optimization
  111238. * @return description string
  111239. */
  111240. getDescription(): string;
  111241. /**
  111242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111243. * @param scene defines the current scene where to apply this optimization
  111244. * @param optimizer defines the current optimizer
  111245. * @returns true if everything that can be done was applied
  111246. */
  111247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111248. }
  111249. /**
  111250. * Defines an optimization used to merge meshes with compatible materials
  111251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111252. */
  111253. export class MergeMeshesOptimization extends SceneOptimization {
  111254. private static _UpdateSelectionTree;
  111255. /**
  111256. * Gets or sets a boolean which defines if optimization octree has to be updated
  111257. */
  111258. /**
  111259. * Gets or sets a boolean which defines if optimization octree has to be updated
  111260. */
  111261. static UpdateSelectionTree: boolean;
  111262. /**
  111263. * Gets a string describing the action executed by the current optimization
  111264. * @return description string
  111265. */
  111266. getDescription(): string;
  111267. private _canBeMerged;
  111268. /**
  111269. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111270. * @param scene defines the current scene where to apply this optimization
  111271. * @param optimizer defines the current optimizer
  111272. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111273. * @returns true if everything that can be done was applied
  111274. */
  111275. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111276. }
  111277. /**
  111278. * Defines a list of options used by SceneOptimizer
  111279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111280. */
  111281. export class SceneOptimizerOptions {
  111282. /**
  111283. * Defines the target frame rate to reach (60 by default)
  111284. */
  111285. targetFrameRate: number;
  111286. /**
  111287. * Defines the interval between two checkes (2000ms by default)
  111288. */
  111289. trackerDuration: number;
  111290. /**
  111291. * Gets the list of optimizations to apply
  111292. */
  111293. optimizations: SceneOptimization[];
  111294. /**
  111295. * Creates a new list of options used by SceneOptimizer
  111296. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111297. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111298. */
  111299. constructor(
  111300. /**
  111301. * Defines the target frame rate to reach (60 by default)
  111302. */
  111303. targetFrameRate?: number,
  111304. /**
  111305. * Defines the interval between two checkes (2000ms by default)
  111306. */
  111307. trackerDuration?: number);
  111308. /**
  111309. * Add a new optimization
  111310. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111311. * @returns the current SceneOptimizerOptions
  111312. */
  111313. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111314. /**
  111315. * Add a new custom optimization
  111316. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111317. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111318. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111319. * @returns the current SceneOptimizerOptions
  111320. */
  111321. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111322. /**
  111323. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111324. * @param targetFrameRate defines the target frame rate (60 by default)
  111325. * @returns a SceneOptimizerOptions object
  111326. */
  111327. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111328. /**
  111329. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111330. * @param targetFrameRate defines the target frame rate (60 by default)
  111331. * @returns a SceneOptimizerOptions object
  111332. */
  111333. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111334. /**
  111335. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111336. * @param targetFrameRate defines the target frame rate (60 by default)
  111337. * @returns a SceneOptimizerOptions object
  111338. */
  111339. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111340. }
  111341. /**
  111342. * Class used to run optimizations in order to reach a target frame rate
  111343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111344. */
  111345. export class SceneOptimizer implements IDisposable {
  111346. private _isRunning;
  111347. private _options;
  111348. private _scene;
  111349. private _currentPriorityLevel;
  111350. private _targetFrameRate;
  111351. private _trackerDuration;
  111352. private _currentFrameRate;
  111353. private _sceneDisposeObserver;
  111354. private _improvementMode;
  111355. /**
  111356. * Defines an observable called when the optimizer reaches the target frame rate
  111357. */
  111358. onSuccessObservable: Observable<SceneOptimizer>;
  111359. /**
  111360. * Defines an observable called when the optimizer enables an optimization
  111361. */
  111362. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111363. /**
  111364. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111365. */
  111366. onFailureObservable: Observable<SceneOptimizer>;
  111367. /**
  111368. * Gets a boolean indicating if the optimizer is in improvement mode
  111369. */
  111370. readonly isInImprovementMode: boolean;
  111371. /**
  111372. * Gets the current priority level (0 at start)
  111373. */
  111374. readonly currentPriorityLevel: number;
  111375. /**
  111376. * Gets the current frame rate checked by the SceneOptimizer
  111377. */
  111378. readonly currentFrameRate: number;
  111379. /**
  111380. * Gets or sets the current target frame rate (60 by default)
  111381. */
  111382. /**
  111383. * Gets or sets the current target frame rate (60 by default)
  111384. */
  111385. targetFrameRate: number;
  111386. /**
  111387. * Gets or sets the current interval between two checks (every 2000ms by default)
  111388. */
  111389. /**
  111390. * Gets or sets the current interval between two checks (every 2000ms by default)
  111391. */
  111392. trackerDuration: number;
  111393. /**
  111394. * Gets the list of active optimizations
  111395. */
  111396. readonly optimizations: SceneOptimization[];
  111397. /**
  111398. * Creates a new SceneOptimizer
  111399. * @param scene defines the scene to work on
  111400. * @param options defines the options to use with the SceneOptimizer
  111401. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111402. * @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)
  111403. */
  111404. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111405. /**
  111406. * Stops the current optimizer
  111407. */
  111408. stop(): void;
  111409. /**
  111410. * Reset the optimizer to initial step (current priority level = 0)
  111411. */
  111412. reset(): void;
  111413. /**
  111414. * Start the optimizer. By default it will try to reach a specific framerate
  111415. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111416. */
  111417. start(): void;
  111418. private _checkCurrentState;
  111419. /**
  111420. * Release all resources
  111421. */
  111422. dispose(): void;
  111423. /**
  111424. * Helper function to create a SceneOptimizer with one single line of code
  111425. * @param scene defines the scene to work on
  111426. * @param options defines the options to use with the SceneOptimizer
  111427. * @param onSuccess defines a callback to call on success
  111428. * @param onFailure defines a callback to call on failure
  111429. * @returns the new SceneOptimizer object
  111430. */
  111431. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111432. }
  111433. }
  111434. declare module BABYLON {
  111435. /**
  111436. * Class used to serialize a scene into a string
  111437. */
  111438. export class SceneSerializer {
  111439. /**
  111440. * Clear cache used by a previous serialization
  111441. */
  111442. static ClearCache(): void;
  111443. /**
  111444. * Serialize a scene into a JSON compatible object
  111445. * @param scene defines the scene to serialize
  111446. * @returns a JSON compatible object
  111447. */
  111448. static Serialize(scene: Scene): any;
  111449. /**
  111450. * Serialize a mesh into a JSON compatible object
  111451. * @param toSerialize defines the mesh to serialize
  111452. * @param withParents defines if parents must be serialized as well
  111453. * @param withChildren defines if children must be serialized as well
  111454. * @returns a JSON compatible object
  111455. */
  111456. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111457. }
  111458. }
  111459. declare module BABYLON {
  111460. /**
  111461. * This represents the different options avilable for the video capture.
  111462. */
  111463. export interface VideoRecorderOptions {
  111464. /** Defines the mime type of the video */
  111465. mimeType: string;
  111466. /** Defines the video the video should be recorded at */
  111467. fps: number;
  111468. /** Defines the chunk size for the recording data */
  111469. recordChunckSize: number;
  111470. /** The audio tracks to attach to the record */
  111471. audioTracks?: MediaStreamTrack[];
  111472. }
  111473. /**
  111474. * This can helps recording videos from BabylonJS.
  111475. * This is based on the available WebRTC functionalities of the browser.
  111476. *
  111477. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111478. */
  111479. export class VideoRecorder {
  111480. private static readonly _defaultOptions;
  111481. /**
  111482. * Returns wehther or not the VideoRecorder is available in your browser.
  111483. * @param engine Defines the Babylon Engine to check the support for
  111484. * @returns true if supported otherwise false
  111485. */
  111486. static IsSupported(engine: Engine): boolean;
  111487. private readonly _options;
  111488. private _canvas;
  111489. private _mediaRecorder;
  111490. private _recordedChunks;
  111491. private _fileName;
  111492. private _resolve;
  111493. private _reject;
  111494. /**
  111495. * True wether a recording is already in progress.
  111496. */
  111497. readonly isRecording: boolean;
  111498. /**
  111499. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111500. * a video file.
  111501. * @param engine Defines the BabylonJS Engine you wish to record
  111502. * @param options Defines options that can be used to customized the capture
  111503. */
  111504. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111505. /**
  111506. * Stops the current recording before the default capture timeout passed in the startRecording
  111507. * functions.
  111508. */
  111509. stopRecording(): void;
  111510. /**
  111511. * Starts recording the canvas for a max duration specified in parameters.
  111512. * @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.
  111513. * @param maxDuration Defines the maximum recording time in seconds.
  111514. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111515. * @return a promise callback at the end of the recording with the video data in Blob.
  111516. */
  111517. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111518. /**
  111519. * Releases internal resources used during the recording.
  111520. */
  111521. dispose(): void;
  111522. private _handleDataAvailable;
  111523. private _handleError;
  111524. private _handleStop;
  111525. }
  111526. }
  111527. declare module BABYLON {
  111528. /**
  111529. * Helper class to push actions to a pool of workers.
  111530. */
  111531. export class WorkerPool implements IDisposable {
  111532. private _workerInfos;
  111533. private _pendingActions;
  111534. /**
  111535. * Constructor
  111536. * @param workers Array of workers to use for actions
  111537. */
  111538. constructor(workers: Array<Worker>);
  111539. /**
  111540. * Terminates all workers and clears any pending actions.
  111541. */
  111542. dispose(): void;
  111543. /**
  111544. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111545. * pended until a worker has completed its action.
  111546. * @param action The action to perform. Call onComplete when the action is complete.
  111547. */
  111548. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111549. private _execute;
  111550. }
  111551. }
  111552. declare module BABYLON {
  111553. /**
  111554. * Class containing a set of static utilities functions for screenshots
  111555. */
  111556. export class ScreenshotTools {
  111557. /**
  111558. * Captures a screenshot of the current rendering
  111559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111560. * @param engine defines the rendering engine
  111561. * @param camera defines the source camera
  111562. * @param size This parameter can be set to a single number or to an object with the
  111563. * following (optional) properties: precision, width, height. If a single number is passed,
  111564. * it will be used for both width and height. If an object is passed, the screenshot size
  111565. * will be derived from the parameters. The precision property is a multiplier allowing
  111566. * rendering at a higher or lower resolution
  111567. * @param successCallback defines the callback receives a single parameter which contains the
  111568. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111569. * src parameter of an <img> to display it
  111570. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111571. * Check your browser for supported MIME types
  111572. */
  111573. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111574. /**
  111575. * Generates an image screenshot from the specified camera.
  111576. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111577. * @param engine The engine to use for rendering
  111578. * @param camera The camera to use for rendering
  111579. * @param size This parameter can be set to a single number or to an object with the
  111580. * following (optional) properties: precision, width, height. If a single number is passed,
  111581. * it will be used for both width and height. If an object is passed, the screenshot size
  111582. * will be derived from the parameters. The precision property is a multiplier allowing
  111583. * rendering at a higher or lower resolution
  111584. * @param successCallback The callback receives a single parameter which contains the
  111585. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111586. * src parameter of an <img> to display it
  111587. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111588. * Check your browser for supported MIME types
  111589. * @param samples Texture samples (default: 1)
  111590. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111591. * @param fileName A name for for the downloaded file.
  111592. */
  111593. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111594. }
  111595. }
  111596. declare module BABYLON {
  111597. /**
  111598. * A cursor which tracks a point on a path
  111599. */
  111600. export class PathCursor {
  111601. private path;
  111602. /**
  111603. * Stores path cursor callbacks for when an onchange event is triggered
  111604. */
  111605. private _onchange;
  111606. /**
  111607. * The value of the path cursor
  111608. */
  111609. value: number;
  111610. /**
  111611. * The animation array of the path cursor
  111612. */
  111613. animations: Animation[];
  111614. /**
  111615. * Initializes the path cursor
  111616. * @param path The path to track
  111617. */
  111618. constructor(path: Path2);
  111619. /**
  111620. * Gets the cursor point on the path
  111621. * @returns A point on the path cursor at the cursor location
  111622. */
  111623. getPoint(): Vector3;
  111624. /**
  111625. * Moves the cursor ahead by the step amount
  111626. * @param step The amount to move the cursor forward
  111627. * @returns This path cursor
  111628. */
  111629. moveAhead(step?: number): PathCursor;
  111630. /**
  111631. * Moves the cursor behind by the step amount
  111632. * @param step The amount to move the cursor back
  111633. * @returns This path cursor
  111634. */
  111635. moveBack(step?: number): PathCursor;
  111636. /**
  111637. * Moves the cursor by the step amount
  111638. * If the step amount is greater than one, an exception is thrown
  111639. * @param step The amount to move the cursor
  111640. * @returns This path cursor
  111641. */
  111642. move(step: number): PathCursor;
  111643. /**
  111644. * Ensures that the value is limited between zero and one
  111645. * @returns This path cursor
  111646. */
  111647. private ensureLimits;
  111648. /**
  111649. * Runs onchange callbacks on change (used by the animation engine)
  111650. * @returns This path cursor
  111651. */
  111652. private raiseOnChange;
  111653. /**
  111654. * Executes a function on change
  111655. * @param f A path cursor onchange callback
  111656. * @returns This path cursor
  111657. */
  111658. onchange(f: (cursor: PathCursor) => void): PathCursor;
  111659. }
  111660. }
  111661. declare module BABYLON {
  111662. /** @hidden */
  111663. export var blurPixelShader: {
  111664. name: string;
  111665. shader: string;
  111666. };
  111667. }
  111668. declare module BABYLON {
  111669. /** @hidden */
  111670. export var bones300Declaration: {
  111671. name: string;
  111672. shader: string;
  111673. };
  111674. }
  111675. declare module BABYLON {
  111676. /** @hidden */
  111677. export var instances300Declaration: {
  111678. name: string;
  111679. shader: string;
  111680. };
  111681. }
  111682. declare module BABYLON {
  111683. /** @hidden */
  111684. export var pointCloudVertexDeclaration: {
  111685. name: string;
  111686. shader: string;
  111687. };
  111688. }
  111689. // Mixins
  111690. interface Window {
  111691. mozIndexedDB: IDBFactory;
  111692. webkitIndexedDB: IDBFactory;
  111693. msIndexedDB: IDBFactory;
  111694. webkitURL: typeof URL;
  111695. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  111696. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  111697. WebGLRenderingContext: WebGLRenderingContext;
  111698. MSGesture: MSGesture;
  111699. CANNON: any;
  111700. AudioContext: AudioContext;
  111701. webkitAudioContext: AudioContext;
  111702. PointerEvent: any;
  111703. Math: Math;
  111704. Uint8Array: Uint8ArrayConstructor;
  111705. Float32Array: Float32ArrayConstructor;
  111706. mozURL: typeof URL;
  111707. msURL: typeof URL;
  111708. VRFrameData: any; // WebVR, from specs 1.1
  111709. DracoDecoderModule: any;
  111710. setImmediate(handler: (...args: any[]) => void): number;
  111711. }
  111712. interface HTMLCanvasElement {
  111713. requestPointerLock(): void;
  111714. msRequestPointerLock?(): void;
  111715. mozRequestPointerLock?(): void;
  111716. webkitRequestPointerLock?(): void;
  111717. /** Track wether a record is in progress */
  111718. isRecording: boolean;
  111719. /** Capture Stream method defined by some browsers */
  111720. captureStream(fps?: number): MediaStream;
  111721. }
  111722. interface CanvasRenderingContext2D {
  111723. msImageSmoothingEnabled: boolean;
  111724. }
  111725. interface MouseEvent {
  111726. mozMovementX: number;
  111727. mozMovementY: number;
  111728. webkitMovementX: number;
  111729. webkitMovementY: number;
  111730. msMovementX: number;
  111731. msMovementY: number;
  111732. }
  111733. interface Navigator {
  111734. mozGetVRDevices: (any: any) => any;
  111735. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111736. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111737. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111738. webkitGetGamepads(): Gamepad[];
  111739. msGetGamepads(): Gamepad[];
  111740. webkitGamepads(): Gamepad[];
  111741. }
  111742. interface HTMLVideoElement {
  111743. mozSrcObject: any;
  111744. }
  111745. interface Math {
  111746. fround(x: number): number;
  111747. imul(a: number, b: number): number;
  111748. }
  111749. interface WebGLProgram {
  111750. context?: WebGLRenderingContext;
  111751. vertexShader?: WebGLShader;
  111752. fragmentShader?: WebGLShader;
  111753. isParallelCompiled: boolean;
  111754. onCompiled?: () => void;
  111755. }
  111756. interface WebGLRenderingContext {
  111757. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  111758. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  111759. vertexAttribDivisor(index: number, divisor: number): void;
  111760. createVertexArray(): any;
  111761. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  111762. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  111763. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  111764. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  111765. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  111766. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  111767. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  111768. // Queries
  111769. createQuery(): WebGLQuery;
  111770. deleteQuery(query: WebGLQuery): void;
  111771. beginQuery(target: number, query: WebGLQuery): void;
  111772. endQuery(target: number): void;
  111773. getQueryParameter(query: WebGLQuery, pname: number): any;
  111774. getQuery(target: number, pname: number): any;
  111775. MAX_SAMPLES: number;
  111776. RGBA8: number;
  111777. READ_FRAMEBUFFER: number;
  111778. DRAW_FRAMEBUFFER: number;
  111779. UNIFORM_BUFFER: number;
  111780. HALF_FLOAT_OES: number;
  111781. RGBA16F: number;
  111782. RGBA32F: number;
  111783. R32F: number;
  111784. RG32F: number;
  111785. RGB32F: number;
  111786. R16F: number;
  111787. RG16F: number;
  111788. RGB16F: number;
  111789. RED: number;
  111790. RG: number;
  111791. R8: number;
  111792. RG8: number;
  111793. UNSIGNED_INT_24_8: number;
  111794. DEPTH24_STENCIL8: number;
  111795. /* Multiple Render Targets */
  111796. drawBuffers(buffers: number[]): void;
  111797. readBuffer(src: number): void;
  111798. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  111799. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  111800. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  111801. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  111802. // Occlusion Query
  111803. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  111804. ANY_SAMPLES_PASSED: number;
  111805. QUERY_RESULT_AVAILABLE: number;
  111806. QUERY_RESULT: number;
  111807. }
  111808. interface WebGLBuffer {
  111809. references: number;
  111810. capacity: number;
  111811. is32Bits: boolean;
  111812. }
  111813. interface WebGLProgram {
  111814. transformFeedback?: WebGLTransformFeedback | null;
  111815. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111816. }
  111817. interface EXT_disjoint_timer_query {
  111818. QUERY_COUNTER_BITS_EXT: number;
  111819. TIME_ELAPSED_EXT: number;
  111820. TIMESTAMP_EXT: number;
  111821. GPU_DISJOINT_EXT: number;
  111822. QUERY_RESULT_EXT: number;
  111823. QUERY_RESULT_AVAILABLE_EXT: number;
  111824. queryCounterEXT(query: WebGLQuery, target: number): void;
  111825. createQueryEXT(): WebGLQuery;
  111826. beginQueryEXT(target: number, query: WebGLQuery): void;
  111827. endQueryEXT(target: number): void;
  111828. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  111829. deleteQueryEXT(query: WebGLQuery): void;
  111830. }
  111831. interface WebGLUniformLocation {
  111832. _currentState: any;
  111833. }
  111834. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  111835. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  111836. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  111837. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111838. interface WebGLRenderingContext {
  111839. readonly RASTERIZER_DISCARD: number;
  111840. readonly DEPTH_COMPONENT24: number;
  111841. readonly TEXTURE_3D: number;
  111842. readonly TEXTURE_2D_ARRAY: number;
  111843. readonly TEXTURE_COMPARE_FUNC: number;
  111844. readonly TEXTURE_COMPARE_MODE: number;
  111845. readonly COMPARE_REF_TO_TEXTURE: number;
  111846. readonly TEXTURE_WRAP_R: number;
  111847. readonly HALF_FLOAT: number;
  111848. readonly RGB8: number;
  111849. readonly RED_INTEGER: number;
  111850. readonly RG_INTEGER: number;
  111851. readonly RGB_INTEGER: number;
  111852. readonly RGBA_INTEGER: number;
  111853. readonly R8_SNORM: number;
  111854. readonly RG8_SNORM: number;
  111855. readonly RGB8_SNORM: number;
  111856. readonly RGBA8_SNORM: number;
  111857. readonly R8I: number;
  111858. readonly RG8I: number;
  111859. readonly RGB8I: number;
  111860. readonly RGBA8I: number;
  111861. readonly R8UI: number;
  111862. readonly RG8UI: number;
  111863. readonly RGB8UI: number;
  111864. readonly RGBA8UI: number;
  111865. readonly R16I: number;
  111866. readonly RG16I: number;
  111867. readonly RGB16I: number;
  111868. readonly RGBA16I: number;
  111869. readonly R16UI: number;
  111870. readonly RG16UI: number;
  111871. readonly RGB16UI: number;
  111872. readonly RGBA16UI: number;
  111873. readonly R32I: number;
  111874. readonly RG32I: number;
  111875. readonly RGB32I: number;
  111876. readonly RGBA32I: number;
  111877. readonly R32UI: number;
  111878. readonly RG32UI: number;
  111879. readonly RGB32UI: number;
  111880. readonly RGBA32UI: number;
  111881. readonly RGB10_A2UI: number;
  111882. readonly R11F_G11F_B10F: number;
  111883. readonly RGB9_E5: number;
  111884. readonly RGB10_A2: number;
  111885. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  111886. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  111887. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  111888. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  111889. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  111890. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  111891. 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;
  111892. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  111893. readonly TRANSFORM_FEEDBACK: number;
  111894. readonly INTERLEAVED_ATTRIBS: number;
  111895. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  111896. createTransformFeedback(): WebGLTransformFeedback;
  111897. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  111898. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  111899. beginTransformFeedback(primitiveMode: number): void;
  111900. endTransformFeedback(): void;
  111901. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111902. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111903. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111904. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111905. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111906. }
  111907. interface ImageBitmap {
  111908. readonly width: number;
  111909. readonly height: number;
  111910. close(): void;
  111911. }
  111912. interface WebGLQuery extends WebGLObject {
  111913. }
  111914. declare var WebGLQuery: {
  111915. prototype: WebGLQuery;
  111916. new(): WebGLQuery;
  111917. };
  111918. interface WebGLSampler extends WebGLObject {
  111919. }
  111920. declare var WebGLSampler: {
  111921. prototype: WebGLSampler;
  111922. new(): WebGLSampler;
  111923. };
  111924. interface WebGLSync extends WebGLObject {
  111925. }
  111926. declare var WebGLSync: {
  111927. prototype: WebGLSync;
  111928. new(): WebGLSync;
  111929. };
  111930. interface WebGLTransformFeedback extends WebGLObject {
  111931. }
  111932. declare var WebGLTransformFeedback: {
  111933. prototype: WebGLTransformFeedback;
  111934. new(): WebGLTransformFeedback;
  111935. };
  111936. interface WebGLVertexArrayObject extends WebGLObject {
  111937. }
  111938. declare var WebGLVertexArrayObject: {
  111939. prototype: WebGLVertexArrayObject;
  111940. new(): WebGLVertexArrayObject;
  111941. };
  111942. // Type definitions for WebVR API
  111943. // Project: https://w3c.github.io/webvr/
  111944. // Definitions by: six a <https://github.com/lostfictions>
  111945. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111946. interface VRDisplay extends EventTarget {
  111947. /**
  111948. * Dictionary of capabilities describing the VRDisplay.
  111949. */
  111950. readonly capabilities: VRDisplayCapabilities;
  111951. /**
  111952. * z-depth defining the far plane of the eye view frustum
  111953. * enables mapping of values in the render target depth
  111954. * attachment to scene coordinates. Initially set to 10000.0.
  111955. */
  111956. depthFar: number;
  111957. /**
  111958. * z-depth defining the near plane of the eye view frustum
  111959. * enables mapping of values in the render target depth
  111960. * attachment to scene coordinates. Initially set to 0.01.
  111961. */
  111962. depthNear: number;
  111963. /**
  111964. * An identifier for this distinct VRDisplay. Used as an
  111965. * association point in the Gamepad API.
  111966. */
  111967. readonly displayId: number;
  111968. /**
  111969. * A display name, a user-readable name identifying it.
  111970. */
  111971. readonly displayName: string;
  111972. readonly isConnected: boolean;
  111973. readonly isPresenting: boolean;
  111974. /**
  111975. * If this VRDisplay supports room-scale experiences, the optional
  111976. * stage attribute contains details on the room-scale parameters.
  111977. */
  111978. readonly stageParameters: VRStageParameters | null;
  111979. /**
  111980. * Passing the value returned by `requestAnimationFrame` to
  111981. * `cancelAnimationFrame` will unregister the callback.
  111982. * @param handle Define the hanle of the request to cancel
  111983. */
  111984. cancelAnimationFrame(handle: number): void;
  111985. /**
  111986. * Stops presenting to the VRDisplay.
  111987. * @returns a promise to know when it stopped
  111988. */
  111989. exitPresent(): Promise<void>;
  111990. /**
  111991. * Return the current VREyeParameters for the given eye.
  111992. * @param whichEye Define the eye we want the parameter for
  111993. * @returns the eye parameters
  111994. */
  111995. getEyeParameters(whichEye: string): VREyeParameters;
  111996. /**
  111997. * Populates the passed VRFrameData with the information required to render
  111998. * the current frame.
  111999. * @param frameData Define the data structure to populate
  112000. * @returns true if ok otherwise false
  112001. */
  112002. getFrameData(frameData: VRFrameData): boolean;
  112003. /**
  112004. * Get the layers currently being presented.
  112005. * @returns the list of VR layers
  112006. */
  112007. getLayers(): VRLayer[];
  112008. /**
  112009. * Return a VRPose containing the future predicted pose of the VRDisplay
  112010. * when the current frame will be presented. The value returned will not
  112011. * change until JavaScript has returned control to the browser.
  112012. *
  112013. * The VRPose will contain the position, orientation, velocity,
  112014. * and acceleration of each of these properties.
  112015. * @returns the pose object
  112016. */
  112017. getPose(): VRPose;
  112018. /**
  112019. * Return the current instantaneous pose of the VRDisplay, with no
  112020. * prediction applied.
  112021. * @returns the current instantaneous pose
  112022. */
  112023. getImmediatePose(): VRPose;
  112024. /**
  112025. * The callback passed to `requestAnimationFrame` will be called
  112026. * any time a new frame should be rendered. When the VRDisplay is
  112027. * presenting the callback will be called at the native refresh
  112028. * rate of the HMD. When not presenting this function acts
  112029. * identically to how window.requestAnimationFrame acts. Content should
  112030. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112031. * asynchronously from other displays and at differing refresh rates.
  112032. * @param callback Define the eaction to run next frame
  112033. * @returns the request handle it
  112034. */
  112035. requestAnimationFrame(callback: FrameRequestCallback): number;
  112036. /**
  112037. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112038. * Repeat calls while already presenting will update the VRLayers being displayed.
  112039. * @param layers Define the list of layer to present
  112040. * @returns a promise to know when the request has been fulfilled
  112041. */
  112042. requestPresent(layers: VRLayer[]): Promise<void>;
  112043. /**
  112044. * Reset the pose for this display, treating its current position and
  112045. * orientation as the "origin/zero" values. VRPose.position,
  112046. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112047. * updated when calling resetPose(). This should be called in only
  112048. * sitting-space experiences.
  112049. */
  112050. resetPose(): void;
  112051. /**
  112052. * The VRLayer provided to the VRDisplay will be captured and presented
  112053. * in the HMD. Calling this function has the same effect on the source
  112054. * canvas as any other operation that uses its source image, and canvases
  112055. * created without preserveDrawingBuffer set to true will be cleared.
  112056. * @param pose Define the pose to submit
  112057. */
  112058. submitFrame(pose?: VRPose): void;
  112059. }
  112060. declare var VRDisplay: {
  112061. prototype: VRDisplay;
  112062. new(): VRDisplay;
  112063. };
  112064. interface VRLayer {
  112065. leftBounds?: number[] | Float32Array | null;
  112066. rightBounds?: number[] | Float32Array | null;
  112067. source?: HTMLCanvasElement | null;
  112068. }
  112069. interface VRDisplayCapabilities {
  112070. readonly canPresent: boolean;
  112071. readonly hasExternalDisplay: boolean;
  112072. readonly hasOrientation: boolean;
  112073. readonly hasPosition: boolean;
  112074. readonly maxLayers: number;
  112075. }
  112076. interface VREyeParameters {
  112077. /** @deprecated */
  112078. readonly fieldOfView: VRFieldOfView;
  112079. readonly offset: Float32Array;
  112080. readonly renderHeight: number;
  112081. readonly renderWidth: number;
  112082. }
  112083. interface VRFieldOfView {
  112084. readonly downDegrees: number;
  112085. readonly leftDegrees: number;
  112086. readonly rightDegrees: number;
  112087. readonly upDegrees: number;
  112088. }
  112089. interface VRFrameData {
  112090. readonly leftProjectionMatrix: Float32Array;
  112091. readonly leftViewMatrix: Float32Array;
  112092. readonly pose: VRPose;
  112093. readonly rightProjectionMatrix: Float32Array;
  112094. readonly rightViewMatrix: Float32Array;
  112095. readonly timestamp: number;
  112096. }
  112097. interface VRPose {
  112098. readonly angularAcceleration: Float32Array | null;
  112099. readonly angularVelocity: Float32Array | null;
  112100. readonly linearAcceleration: Float32Array | null;
  112101. readonly linearVelocity: Float32Array | null;
  112102. readonly orientation: Float32Array | null;
  112103. readonly position: Float32Array | null;
  112104. readonly timestamp: number;
  112105. }
  112106. interface VRStageParameters {
  112107. sittingToStandingTransform?: Float32Array;
  112108. sizeX?: number;
  112109. sizeY?: number;
  112110. }
  112111. interface Navigator {
  112112. getVRDisplays(): Promise<VRDisplay[]>;
  112113. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112114. }
  112115. interface Window {
  112116. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112117. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112118. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112119. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112120. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112121. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112122. }
  112123. interface Gamepad {
  112124. readonly displayId: number;
  112125. }
  112126. interface XRDevice {
  112127. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112128. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112129. }
  112130. interface XRSession {
  112131. getInputSources(): Array<any>;
  112132. baseLayer: XRWebGLLayer;
  112133. requestFrameOfReference(type: string): Promise<void>;
  112134. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112135. end(): Promise<void>;
  112136. requestAnimationFrame: Function;
  112137. addEventListener: Function;
  112138. }
  112139. interface XRSessionCreationOptions {
  112140. outputContext?: WebGLRenderingContext | null;
  112141. immersive?: boolean;
  112142. environmentIntegration?: boolean;
  112143. }
  112144. interface XRLayer {
  112145. getViewport: Function;
  112146. framebufferWidth: number;
  112147. framebufferHeight: number;
  112148. }
  112149. interface XRView {
  112150. projectionMatrix: Float32Array;
  112151. }
  112152. interface XRFrame {
  112153. getDevicePose: Function;
  112154. getInputPose: Function;
  112155. views: Array<XRView>;
  112156. baseLayer: XRLayer;
  112157. }
  112158. interface XRFrameOfReference {
  112159. }
  112160. interface XRWebGLLayer extends XRLayer {
  112161. framebuffer: WebGLFramebuffer;
  112162. }
  112163. declare var XRWebGLLayer: {
  112164. prototype: XRWebGLLayer;
  112165. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112166. };